Skip to content

Conversation

@djshow832
Copy link
Collaborator

@djshow832 djshow832 commented Nov 6, 2025

What problem does this PR solve?

Issue Number: close #964

Problem Summary:
There are 2 problems when generating InitDB when parsing:

  • The CPS may differ from the production cluster because the production cluster generally inits DB in handshake
  • When a connection disconnects, the subsequent commands in the connection are discarded, resulting in QPS drop during TiDB restarting.

So the better way is to initializing DB in the handshake when the backend connection creates or reconnects.

What is changed and how it works:

  • Do not generate InitDB command in the decode phase, set the CurDB in the command instead
  • In the replay phase, handshake with the initial DB or generate InitDB command if necessary
  • Remove the waitForQuitMode, reconnect before the next command if the connection disconnects
  • If a prepared statement is not found, do not send it to the server, just generate an exception

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code
  1. replay
  2. kill tidb and start another tidb
  3. check the failure count

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot requested review from YangKeao and bb7133 November 6, 2025 11:14
@ti-chi-bot ti-chi-bot bot added the size/XXL label Nov 6, 2025
@djshow832 djshow832 changed the title sqlreplay, backend: move init db packet from decode phase to replay phase sqlreplay, backend: reconnect after a replaying connection disconnects Nov 6, 2025
@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 77.96610% with 13 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@358165b). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/sqlreplay/conn/conn.go 81.08% 6 Missing and 1 partial ⚠️
pkg/sqlreplay/conn/backend_conn.go 45.45% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #972   +/-   ##
=======================================
  Coverage        ?   67.46%           
=======================================
  Files           ?      136           
  Lines           ?    13633           
  Branches        ?        0           
=======================================
  Hits            ?     9197           
  Misses          ?     3795           
  Partials        ?      641           
Flag Coverage Δ
unit 67.46% <77.96%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot
Copy link

ti-chi-bot bot commented Nov 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: YangKeao

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the lgtm label Nov 6, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Nov 6, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-11-06 15:01:21.586882813 +0000 UTC m=+368731.029912702: ☑️ agreed by YangKeao.

@ti-chi-bot ti-chi-bot bot added the approved label Nov 6, 2025
@ti-chi-bot ti-chi-bot bot merged commit 70a6283 into pingcap:main Nov 6, 2025
6 checks passed
@djshow832 djshow832 deleted the init_db branch November 7, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Init DB when replay instead of parsing

3 participants