Constantly getting "connection reset by peer" for TiKV -> TiFlash connection #66488
Replies: 12 comments
|
Original author: TiDB-AI-Assistant Based on the information you provided, it seems like you are encountering a “connection reset by peer” error for a query that uses TiFlash in your TiDB Cloud serverless environment. This error can occur due to various reasons, such as network issues, TiFlash replication problems, or configuration issues. Let’s troubleshoot this step by step based on the official documentation:
In conclusion, to address the “connection reset by peer” error for your TiKV → TiFlash connection in TiDB Cloud, you should verify the status of TiFlash replicas, ensure proper configuration alignment, optimize query performance, and investigate any network or connection issues. By following these steps and monitoring the system closely, you can troubleshoot and resolve the connectivity issues you are facing. |
|
Original author: Mini256
Do you still get the “connection reset by peer” error, and could you tell me the region where your cluster is located? As far as I know, the ap-northeast-1 region suffered a 10-minute outage yesterday, but it should be working fine now. |
|
Original author: Mini256
No
TIDB Serverless’s Tiflash nodes and TIDB nodes are under the same region. |
|
Original author: riverreal Thank you for checking and for the responses. My cluster is indeed located in I can confirm that many other queries failed during the outrage yesterday, but the one I posted doesn’t seem to relate to this outrage. In fact the above error was reproduced today and two days ago: And the following from only error monitoring logs (since the TiDB dashboard only shows the slow queries from the last 3 days) |
|
Original author: riverreal Not sure if it’s related but other TiKV queries (tables with no TiFlash replica set up) also get affected sometimes. So there is a time period or a spontaneous number of requests that become really slow for an unknown reason. Not exactly sure if that’s how TiDB works by design or not. |
|
Original author: Mini256 Thanks for your feedback, and sorry to bring trouble to your application. I have forwarded the relevant issues with TiFlash to the engineering team, and they have preliminarily identified the cause of the error, but this may require some hotfix and test work. Once there is a result, I will synchronize here. |
|
Original author: Mini256
Maybe you can find the actual parameter values in SQL from the execution plan of Slow Query for confirmation. In some cases, because the parameter value is different, the query may need to load more data (Check the Please also check: EXPLAIN Walkthrough | PingCAP Docs |
|
Original author: riverreal Thank you very much. As for the other slow query, This is for example one of the them (notice the 454 ms duration, and it’s just a table with 10000 records):
Seems to be indexed, and the data size is minimal because it’s a really simple table/query (it’s just an As far as I can see it happens about 1 to 4 times a day. |
|
Original author: Mini256
Could you also list the time period when the query slows down? In these time periods, will your application perform other heavy queries? |
|
Original author: Mini256
@riverreal Hi, from the message provided by the core team, region |
|
Original author: riverreal I will inform you here if it still reproduces. |


Uh oh!
There was an error while loading. Please reload this page.
Original author: riverreal
Original time: 2024-03-06 03:50:40.047897
Original ID/Slug: 798 / constantly-getting-connection-reset-by-peer-for-tikv-tiflash-connection
I am constantly getting “connection reset by peer” for a query that uses TiFlash.
I run this query around 3 times every hour as a cron job, and often times I encounter this error in my error monitoring tool along with the job failing.
When I run it manually it usually takes from 100~300ms.
But sometimes when the job fails it shows up in the slow queries section and one recent fail took 11 sec according to it.
The table in question is setup to work with 2 replicas of TiFlash.
And a quick check to
information_schema.tiflash_replicasays that it’s available (AVAILABLE: 1, PROGRESS: 1).The table is indexed, but since it’s being executed by TiFlash it does a full scan to the currently 15973 total number of records (which is not really “a lot”).
Also it took around 247 ms for a simple COUNT to the table in question.
I thought it would be a bit more faster to run COUNT on a table with just 15973 rows in TiFlash.
A EXPLAIN ANALYZE in
Chat2Queryshows that the execution time for the COUNT was about 123.8 ms (a more realistic number).But the
Query Logshows that the total duration for the query was higher (247ms, notice it’s almost about 123.8 * 2 for some reason).It shows similar numbers in repeated executions.
Does it have to do with locations maybe?
Do I have to specify the TiFlash replica location to be the same as the TiDB cluster region?
How can I check where are the TiFlash replicas?
information_schema.tiflash_replicashows nothing.I couldn’t find much information on that, specially for TiDB cloud serverless.
Application environment:
TiDB Cloud serverless tier (production)
TiDB version:
v7.1.1
Reproduction method:
This is the query I’m running.
Which is just getting the top 200 scores from a table.
Problem:
Getting this kind of error:
Attachment:
One of the recent slow queries.
Query Time11.0 s(everything else is in
µsorns, and most of them are 0, which shows it’s some connection problem rather than a bad optimized query)Is Success?NoMax Memory4.9 KiBPlanAll reactions