TiDB Slow Query Monitoring common.bad_request

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb 慢查询监控common.bad_request

| username: TiDBer-lucy

[TiDB Usage Environment] Production Environment
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact] TiDB Dashboard - Slow Queries - Clicking on the title column to sort or adding several columns of data, then querying will result in an error common.bad_request
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots/Logs/Monitoring]

Subsequent Actions: Clear cookies, Slow Queries - Select any slow SQL and click into it

| username: ShawnYan | Original post link

Check the logs to see if it’s network jitter or a timeout. There should be more information.

| username: Billmay表妹 | Original post link

Based on the information you provided, “common.bad_request” is an error type in TiDB slow query monitoring. This error type indicates that the request is invalid, possibly due to syntax errors in the query statement or other reasons.

To resolve this issue, you can follow these steps:

  1. Check the query syntax: Ensure that the query statement conforms to TiDB’s syntax specifications. You can use the EXPLAIN command to check the query plan to determine if there are any syntax errors or performance issues.

  2. Check query parameters: If your query statement includes parameters, ensure that the parameter values are correct and match the query statement’s type. For example, if the query statement uses string parameters, make sure the parameter values are enclosed in quotes.

  3. Check TiDB configuration: Review TiDB’s configuration file to ensure that no restrictions or filters are set that could cause certain queries to be rejected or considered invalid.

  4. Check TiDB logs: Look at TiDB’s log files for error messages related to “common.bad_request.” The log files are usually located in TiDB’s log directory and can be identified by date and timestamp.

If the above steps do not resolve the issue, it is recommended that you provide more context, such as the specific query statement, TiDB version, and error messages from the log files, to better assist you in resolving the problem.

I hope this information is helpful to you. If you have any other questions, please feel free to ask.

| username: TiDBer-lucy | Original post link

When clicking on the slow log query error log, the following appears:
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”]

Clearing cookies, logging into the dashboard, and querying slow queries, selecting any slow query still reports an error.

| username: Fly-bird | Original post link

Restart the dashboard

| username: 像风一样的男子 | Original post link

Clearing the slow query logs, are there too many stored?

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.