Skip to content

Fix sequence publication race in allow-write external SST ingestion - #433

Draft
LykxSassinator wants to merge 1 commit into
tikv:8.10.tikvfrom
LykxSassinator:fix/allow-write-ingest-seq-linearization
Draft

Fix sequence publication race in allow-write external SST ingestion#433
LykxSassinator wants to merge 1 commit into
tikv:8.10.tikvfrom
LykxSassinator:fix/allow-write-ingest-seq-linearization

Conversation

@LykxSassinator

Copy link
Copy Markdown

Summary

IngestExternalFiles(..., allow_write=true) allowed foreground writes to run while external SST ingestion assigned and published global sequence numbers. A concurrent multi-key WriteBatch could complete after ingest read LastSequence() but before ingest published its consumed sequence number, causing the visible sequence to move backwards. New RocksDB snapshots could then miss committed data.

This change restores serialization only for the final ingestion phase:

  • Keep writes enabled during prepare, the initial overlap check, and any initial flush.
  • Enter the write-thread gates before Run() and wait for pending writes.
  • Recheck overlap under the gates and perform a fallback flush if needed.
  • Hold the gates through Run(), LogAndApply, sequence publication, and SuperVersion installation.

This preserves most of the latency benefit of allow_write while restoring the required global sequence linearization.

Tests

  • Added a deterministic sync-point regression test covering the stale sequence publication ordering.
  • Verified both default and two_write_queues paths, with and without atomic_flush.
  • Added explicit post-operation snapshot assertions for both WriteBatch keys and the ingested key.
  • make -j4 external_sst_file_test
  • Targeted tests: 8/8 passed
  • Full external_sst_file_test: 99/99 passed
  • git diff --check
  • clang-format --dry-run --Werror

Signed-off-by: lucasliang <nkcs_lykx@hotmail.com>
@ti-chi-bot

ti-chi-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has signed the dco. labels Jul 30, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bufferflies for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1248a85d-57dc-411c-96d6-0590d4c7b1c5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant