tidb 慢查询监控common.bad_request

【 TiDB 使用环境】生产环境
【 TiDB 版本】
【复现路径】做过哪些操作出现的问题
【遇到的问题:问题现象及影响】TiDB Dashboard ——慢查询——点击标题列排序或新增几列数据,再查询会出现报错 common.bad_request
【资源配置】进入到 TiDB Dashboard -集群信息 (Cluster Info) -主机(Hosts) 截图此页面
【附件:截图/日志/监控】

后续操作:清除cookies 慢查询——选择随意一个慢sql点击进去

查查日志,是网络抖动还是超时了?应该会有更多信息

根据您提供的信息,“common.bad_request” 是 TiDB 慢查询监控中的一个错误类型。这个错误类型表示请求不合法,可能是由于查询语句的语法错误或者其他原因导致的。

要解决这个问题,您可以按照以下步骤进行排查:

  1. 检查查询语句的语法:确保查询语句符合 TiDB 的语法规范。您可以使用 EXPLAIN 命令来检查查询计划,以确定是否存在语法错误或者性能问题。

  2. 检查查询参数:如果您的查询语句中包含参数,确保参数的值正确,并且与查询语句的类型匹配。例如,如果查询语句中使用了字符串参数,确保参数的值用引号括起来。

  3. 检查 TiDB 配置:检查 TiDB 的配置文件,确保没有设置任何限制或者过滤条件,导致某些查询被拒绝或者被视为不合法。

  4. 检查 TiDB 日志:查看 TiDB 的日志文件,查找与 “common.bad_request” 相关的错误信息。日志文件通常位于 TiDB 的日志目录下,可以根据日期和时间戳来定位到特定的日志文件。

如果以上步骤无法解决问题,建议您提供更多的上下文信息,例如具体的查询语句、TiDB 版本、日志文件中的错误信息等,以便更好地帮助您解决问题。

希望这些信息对您有帮助。如果您还有其他问题,请随时提问。

1 个赞

点击慢日志查询时的错误日志,出现以下
2023-10-13 14:14:24 (UTC+08:00)PD xx.xx.xx.xx:2379[error.go:89] [“Error when handling request”] [uri=“/dashboard/api/slow_query/list?begin_time=1697175863&desc=false&digest=&end_time=1697177664&fields=query%2Ctimestamp%2Cquery_time%2Cmemory_max&limit=100&orderBy=timestamp&text=”] [remoteAddr=xx.xx.xx.xx:37834] [errorFullText=“common.bad_request\n at github.com/pingcap/tidb-dashboard/pkg/apiserver/slowquery.(*Service).getList()\n\t/go/pkg/mod/github.com/pingcap/tidb-dashboard@v0.0.0-20221201151320-ea3ee6971f2e/pkg/apiserver/slowquery/service.go:76\n at github.com/gin-gonic/gin.(*Context).Next()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168\n at github.com/pingcap/tidb-dashboard/pkg/apiserver/utils.MWConnectTiDB.func1()\n\t/go/pkg/mod/github.com/pingcap/tidb-dashboard@v0.0.0-20221201151320-ea3ee6971f2e/pkg/apiserver/utils/tidb_conn.go:66\n at github.com/gin-gonic/gin.(*Context).Next()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168\n at github.com/breeswish/gin-jwt/v2.(*GinJWTMiddleware).middlewareImpl()\n\t/go/pkg/mod/github.com/breeswish/gin-jwt/v2@v2.6.4-jwt-patch/auth_jwt.go:403\n at github.com/pingcap/tidb-dashboard/pkg/apiserver/user.(*AuthService).MWAuthRequired.func1()\n\t/go/pkg/mod/github.com/breeswish/gin-jwt/v2@v2.6.4-jwt-patch/auth_jwt.go:365\n at github.com/gin-gonic/gin.(*Context).Next()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168\n at github.com/pingcap/tidb-dashboard/util/rest.ErrorHandlerFn.func1()\n\t/go/pkg/mod/github.com/pingcap/tidb-dashboard@v0.0.0-20221201151320-ea3ee6971f2e/util/rest/error.go:70\n at github.com/gin-gonic/gin.(*Context).Next()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168\n at github.com/gin-contrib/gzip.Gzip.func2()\n\t/go/pkg/mod/github.com/gin-contrib/gzip@v0.0.1/gzip.go:47\n at github.com/gin-gonic/gin.(*Context).Next()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168\n at github.com/gin-gonic/gin.CustomRecoveryWithWriter.func1()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/recovery.go:99\n at github.com/gin-gonic/gin.(*Context).Next()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/context.go:168\n at github.com/gin-gonic/gin.(*Engine).handleHTTPRequest()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/gin.go:555\n at github.com/gin-gonic/gin.(*Engine).ServeHTTP()\n\t/go/pkg/mod/github.com/gin-gonic/gin@v1.7.7/gin.go:511\n at github.com/pingcap/tidb-dashboard/pkg/apiserver.(*Service).handler()\n\t/go/pkg/mod/github.com/pingcap/tidb-dashboard@v0.0.0-20221201151320-ea3ee6971f2e/pkg/apiserver/apiserver.go:244\n at net/http.HandlerFunc.ServeHTTP()\n\t/usr/local/go/src/net/http/server.go:2109\n at github.com/pingcap/tidb-dashboard/pkg/utils.(*ServiceStatus).NewStatusAwareHandler.func1()\n\t/go/pkg/mod/github.com/pingcap/tidb-dashboard@v0.0.0-20221201151320-ea3ee6971f2e/pkg/utils/service_status.go:67\n at net/http.HandlerFunc.ServeHTTP()\n\t/usr/local/go/src/net/http/server.go:2109\n at net/http.(*ServeMux).ServeHTTP()\n\t/usr/local/go/src/net/http/server.go:2487\n at go.etcd.io/etcd/embed.(*accessController).ServeHTTP()\n\t/go/pkg/mod/go.etcd.io/etcd@v0.5.0-alpha.5.0.20220915004622-85b640cee793/embed/serve.go:381\n at net/http.serverHandler.ServeHTTP()\n\t/usr/local/go/src/net/http/server.go:2947\n at net/http.(*conn).serve()\n\t/usr/local/go/src/net/http/server.go:1991\n at runtime.goexit()\n\t/usr/local/go/src/runtime/asm_amd64.s:1594”]

清除cookies 登录dashboard 查询慢查询,随意选择一个慢查询进去仍报错

重启dashboard

清理下慢查询日志,是不是存太多了

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。