Skip to content

test: fix flaky DisaggReadSnapshot — skip background tasks during write+mergeDeltaAll (#10898) - #11035

Open
ti-chi-bot wants to merge 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-10898-to-release-8.5
Open

test: fix flaky DisaggReadSnapshot — skip background tasks during write+mergeDeltaAll (#10898)#11035
ti-chi-bot wants to merge 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-10898-to-release-8.5

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Aug 11, 2026

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #10898

What problem does this PR solve?

Issue Number: close #10897

Problem Summary:
DMStoreForSegmentReadTaskTest.DisaggReadSnapshot is flaky — the initial write(4096) schedules a background flush task
whose completion handler (placeDeltaIndex) and follow-up background merge delta both acquire is_updating on
DeltaValueSpace. When mergeDeltaAll() runs before these background tasks release the lock, it fails silently,
leaving 5 persisted column files instead of the expected 4.

What is changed and how it works?

Enable skip_check_segment_update failpoint before the initial write(4096) + mergeDeltaAll() block in the test,
with a scoped guard that disables it on exit. This prevents checkSegmentUpdate from scheduling any background
flush/merge tasks during the setup phase, eliminating the race entirely.

This is consistent with other tests in the same file (fetchPagesNoTinyNoInMem, fetchPagesTinyNoInMem,
fetchPagesTinyInMem) which already enable skip_check_segment_update via disableFlushCache() before their
write+mergeDeltaAll blocks.

Check List

Tests

  • Unit test

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Summary by CodeRabbit

  • Tests
    • Updated the disaggregated read snapshot test setup to bypass segment update checks during data preparation, then restore the checks afterward.

…g setup

skip_check_segment_update prevents write() from scheduling background
flush/merge tasks, avoiding a race where background placeDeltaIndex or
merge delta holds is_updating and causes mergeDeltaAll() to fail
silently, resulting in 5 persisted column files instead of the expected
4.

Close pingcap#10897.
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Aug 11, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The DisaggReadSnapshot test temporarily enables skip_check_segment_update during stable-data writes and delta merging. An RAII scope guard disables the failpoint after setup.

Changes

DisaggReadSnapshot test setup

Layer / File(s) Summary
Failpoint control during test setup
dbms/src/Storages/DeltaMerge/tests/gtest_segment_read_task.cpp
The test enables skip_check_segment_update before stable-data operations and disables it through a scope guard afterward.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit guards the segment gate,
Sets the failpoint, pauses fate.
Writes and merges proceed in line,
Then RAII makes the state benign.
Hop, hop—no flaky sign!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the flaky DisaggReadSnapshot test and the fix to skip background tasks during setup.
Description check ✅ Passed The description follows the template, explains the race and fix, records issue and test details, and addresses side effects and release notes.
Linked Issues check ✅ Passed The change addresses issue #10897 by preventing background flush and merge tasks from racing with mergeDeltaAll during test setup.
Out of Scope Changes check ✅ Passed The seven added lines are limited to the affected unit test and directly support the linked issue objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
dbms/src/Storages/DeltaMerge/tests/gtest_segment_read_task.cpp (1)

656-657: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use camelCase for the scope guard variable.

Rename fp_guard to fpGuard. The new local variable uses snake_case.

As per coding guidelines, “Method and variable names should use camelCase (e.g., readBlock, totalBytes).”

Proposed rename
-        auto fp_guard
+        auto fpGuard
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dbms/src/Storages/DeltaMerge/tests/gtest_segment_read_task.cpp` around lines
656 - 657, Rename the local scope guard variable in the segment read test from
fp_guard to fpGuard, leaving its fail-point disabling behavior unchanged.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@dbms/src/Storages/DeltaMerge/tests/gtest_segment_read_task.cpp`:
- Around line 656-657: Rename the local scope guard variable in the segment read
test from fp_guard to fpGuard, leaving its fail-point disabling behavior
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6dcf79e-e5e6-451a-ba0c-5df416a2686b

📥 Commits

Reviewing files that changed from the base of the PR and between 76536b2 and 379723b.

📒 Files selected for processing (1)
  • dbms/src/Storages/DeltaMerge/tests/gtest_segment_read_task.cpp

@ti-chi-bot

ti-chi-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, JinheLin

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:
  • OWNERS [JaySon-Huang,JinheLin]

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 11, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-08-11 05:15:30.128926166 +0000 UTC m=+3109916.165021222: ☑️ agreed by JaySon-Huang.
  • 2026-08-11 07:24:22.030277884 +0000 UTC m=+3117648.066372939: ☑️ agreed by JinheLin.

@JaySon-Huang

Copy link
Copy Markdown
Contributor

/test pull-integration-test

@ti-chi-bot

ti-chi-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@ti-chi-bot: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-test 379723b link true /test pull-integration-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved do-not-merge/cherry-pick-not-approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants