Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: tidb连接报错
[TiDB Usage Environment] Production Environment
An error occurred using the connection to database ‘ProdRe’ on server ‘172.*’.
[TiDB Version]
v4.0.9
[Reproduction Path] Operations performed that led to the issue
JDBC connection to the database reported an error, not directly connected and reported an error
An error occurred using the connection to database ‘ProdRe’ on server ‘172.*’.
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]
What are the account permissions like? Could it be that the 172.* machines do not have access to this database?
It’s not a permissions issue. It’s that the connection can’t be established for a period of time, although normally it can. It feels like a long connection problem. I don’t have much experience with TiDB connections, so I’m not sure if it’s parameters related to this that are causing the connection timeout and disconnection.
[2022/11/14 10:34:44.168 +08:00]
[INFO] [conn.go:793] [“command dispatched failed”] [conn=1617584] [connInfo=“id:1617584, addr:172.:44714 status:11, collation:utf8mb4_general_ci, user:app_tidb"] [command=Query] [status=“inTxn:1, autocommit:1”] [sql=“INSERT INTO OrderAddServiceRecommandOperationLog
(CreationTime
, OperationPoint
, OperationType
, OperatorId
, OrderId
, OrderUserType
, Platform
)\nVALUES (timestamp(‘2022-11-14 10:34:21.614388’), 1, 1, ‘27886’, ‘1206554826’, 2, 1010967);\nSELECT Id
\nFROM OrderAddServiceRecommandOperationLog
\nWHERE ROW_COUNT() = 1 AND Id
= LAST_INSERT_ID();\n\n”] [txn_mode=PESSIMISTIC] [err="write tcp 172.33.6.60:4000->172.:44714: write: connection reset by peer\ngithub.com/pingcap/errors.AddStack\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201029093017-5a7df2af2ac7/errors.go:174\ngithub.com/pingcap/errors.Trace\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20201029093017-5a7df2af2ac7/juju_adaptor.go:15\ngithub.com/pingcap/tidb/server.(*packetIO).flush\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/packetio.go:172\ngithub.com/pingcap/tidb/server.(*clientConn).flush\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1054\ngithub.com/pingcap/tidb/server.(*clientConn).writeOkWith\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1087\ngithub.com/pingcap/tidb/server.(*clientConn).writeMultiResultset\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1666\ngithub.com/pingcap/tidb/server.(*clientConn).handleQuery\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1400\ngithub.com/pingcap/tidb/server.(*clientConn).dispatch\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:1005\ngithub.com/pingcap/tidb/server.(*clientConn).Run\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/conn.go:778\ngithub.com/pingcap/tidb/server.(*Server).onConn\n\t/home/jenkins/agent/workspace/optimization-build-tidb-linux-amd/go/src/github.com/pingcap/tidb/server/server.go:439\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1357”]
Logs retrieved from the TiDB Role
There is an error when using MySQL’s JDBC with TiDB. You should use TiDB’s own JDBC.
If you occasionally find that you can’t connect or the connection is refused, it is likely that TiDB is under too much pressure.