Skip to content

sqlreplay: fix replaying with readonly mode still prepares DML statements#998

Merged
ti-chi-bot[bot] merged 3 commits intopingcap:mainfrom
djshow832:readonly
Nov 28, 2025
Merged

sqlreplay: fix replaying with readonly mode still prepares DML statements#998
ti-chi-bot[bot] merged 3 commits intopingcap:mainfrom
djshow832:readonly

Conversation

@djshow832
Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #997

Problem Summary:

  • Replaying with readonly mode still prepares and closes DML statements. If a readonly account is given, prepare will fail.
  • Replaying with readonly mode still replays set global and select for update statements. select for update may block CDC.
  • Replaying with readonly mode writes the report. It's risky if the downstream will be switched over to production.
  • The checkpoint is flushed finally when replay.Close(), which is not called in the service mode.
  • The report is never closed when stopping the replayer. It may start multiple times in the service mode.
  • The nopReport never reads the exceptionCh, which may block the dry-run.

What is changed and how it works:
Fix all the above problems.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Replay TPCC in the readonly mode with a readonly account.

[2025/11/28 19:46:29.624 +08:00] [INFO] [main.replay] [replay/replay.go:955] [replay finished]  [replayed_cmds=109531] [filtered_cmds=371223] [decoded_cmds=480755] [exceptions=0] [total_wait_time=1m22.072085635s] [extra_wait_time=0s] [replay_elapsed=1m25.865426083s] [decode_elapsed=1m25.855039s] [last_cmd_start_ts=2025-09-14 19:11:18.764892584 +0800 CST] [last_cmd_end_ts=2025-09-14 19:11:18.765 +0800 CST] [duplicated={}]

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 xhebox November 28, 2025 11:55
@ti-chi-bot ti-chi-bot Bot added the size/L label Nov 28, 2025
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 86.58537% with 11 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a15c5e0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pkg/util/lex/filter.go 84.61% 6 Missing ⚠️
pkg/sqlreplay/replay/replay.go 73.33% 3 Missing and 1 partial ⚠️
pkg/sqlreplay/replay/dry_run.go 94.44% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #998   +/-   ##
=======================================
  Coverage        ?   67.71%           
=======================================
  Files           ?      140           
  Lines           ?    14216           
  Branches        ?        0           
=======================================
  Hits            ?     9627           
  Misses          ?     3908           
  Partials        ?      681           
Flag Coverage Δ
unit 67.71% <86.58%> (?)

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
Copy Markdown
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 ti-chi-bot Bot added the lgtm label Nov 28, 2025
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Nov 28, 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

Details 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
Copy link
Copy Markdown

ti-chi-bot Bot commented Nov 28, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-11-28 14:37:10.569508949 +0000 UTC m=+14975.383286521: ☑️ agreed by YangKeao.

@ti-chi-bot ti-chi-bot Bot added the approved label Nov 28, 2025
@ti-chi-bot ti-chi-bot Bot merged commit a6be63d into pingcap:main Nov 28, 2025
6 checks passed
@djshow832 djshow832 deleted the readonly branch November 28, 2025 15:06
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.

Replaying in readonly mode still replays prepared DML statements

3 participants