Fix sequence number race when allowing writes during external SST ingestion (#435) - #437
Conversation
ref tikv/tikv#19891 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
@gengliqi This PR has conflicts, I have hold it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Signed-off-by: gengliqi <gengliqiii@gmail.com>
There was a problem hiding this comment.
Pull request overview
Fixes sequence-number races between foreground writes and external SST ingestion.
Changes:
- Reserves ingestion sequence numbers while writers are briefly blocked.
- Extends pending-write accounting to failed multi-batch writes.
- Adds concurrency, ordering, and snapshot tests plus API documentation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
include/rocksdb/options.h |
Documents concurrent ingestion constraints. |
db/external_sst_file_test.cc |
Adds concurrency regression tests. |
db/external_sst_file_ingestion_job.h |
Passes sequence baseline into ingestion jobs. |
db/external_sst_file_ingestion_job.cc |
Uses the reserved sequence baseline. |
db/db_impl/db_impl.h |
Clarifies pending-write accounting. |
db/db_impl/db_impl.cc |
Blocks writers and reserves ingestion sequences. |
db/db_impl/db_impl_write.cc |
Accounts for failed multi-batch writes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| WaitForPendingWrites(); | ||
| } | ||
|
|
||
| SequenceNumber last_seqno = versions_->LastSequence(); |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gengliqi, overvenus The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This is an automated cherry-pick of #435
Ref tikv/tikv#19891 (comment)
When
allow_write=true, external SST ingestion may assign sequence numbersconcurrently with foreground writes. This can cause duplicate sequence numbers
or make the global sequence-number state move backwards.
This change briefly blocks writers to reserve enough sequence numbers before
running the ingestion jobs. Writers are resumed immediately after the
reservation, so SST processing and MANIFEST updates remain outside the
write-blocking period.
The existing behavior for
allow_write=falseis unchanged.This also fixes an
enable_multi_batch_writeedge case where writers that failto write WAL still publish their allocated sequence numbers but were not counted
as pending. They are now included in pending-write accounting, preventing
ingestion from reserving sequence numbers before their sequence publication
completes.
Summary by CodeRabbit
Bug Fixes
Documentation
Tests