Repository navigation
Fix a few file read cancellation bugs - #12643
Merged
Merged
Conversation
File read can't be cancelled, so we have to hold on the buffer and issue reads. This was found in apple#12642 test, seed: -f ./tests/slow/BulkDumpingS3WithChaos.toml -s 1554084314 -b off
Contributor
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Contributor
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Contributor
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Contributor
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Contributor
Result of foundationdb-pr-clang on Linux RHEL 9
|
Contributor
Result of foundationdb-pr on Linux RHEL 9
|
saintstack
approved these changes
Jan 17, 2026
Contributor
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
spraza
added a commit
to spraza/foundationdb
that referenced
this pull request
Aug 17, 2026
(cherry picked from commit 5789c55 on main)
spraza
added a commit
to spraza/foundationdb
that referenced
this pull request
Aug 18, 2026
(cherry picked from commit 5789c55 on main)
spraza
added a commit
that referenced
this pull request
Aug 18, 2026
, #12755) (#13871) * Fix circular recursion in Snapshot.Option (#12318) Authored-by: Baptiste Merliot <42059119+BMerliot@users.noreply.github.com> (cherry picked from commit fba84d9 on main) * Fix a few file read cancellation bugs (#12643) (cherry picked from commit 5789c55 on main) * Fix a DD shutdown crash (#12750) To reproduce clang build at 7.3.69 seed: -f ./tests/restarting/from_7.3.0_until_7.4.0/SnapTestAttrition-1.toml -s 1392115560 -b on Setup - dataDistribution is running its main loop. The actors vector (non-state) holds all the sub-actors including DataDistributionTracker::run. - trackerCancelled (state bool) is false. - The tracker has finished trackInitialShards and is sitting inside the loop choose, waiting on multiple futures including loggingTrigger. - loggingTrigger is state Future<Void>. It was initialized as Void() — an already-completed future. After the first firing, it gets reset to delay(...). So on the very first iteration of the loop, it fires immediately. The trigger — an error in another actor 1. Some other actor in actors throws (e.g. movekeys_conflict from a DDTeamCollection actor). waitForAll(actors) propagates this error out of wait(waitForAll(actors)). 2. Execution enters the catch block at DataDistribution.actor.cpp:1114. 3. Line 1115: trackerCancelled = true. 4. Team collection References are cleared (lines 1129–1131). This destroys DDTeamCollection objects synchronously. 5. The error is not actor_cancelled, so we reach line 1142: wait(shards.clearAsync()). The actor suspends here. shards is a state KeyRangeMap<ShardTrackedData> — clearing a large map is broken into async chunks to avoid starving the event loop. The pending network response fires during the yield 6. The FDB simulator event loop picks up the next task: a WaitMetrics reply from a storage server arrives for one of the trackShardMetrics actors. 7. SAV<StorageMetrics>::finishSendAndDelPromiseRef() fires its callbacks synchronously in a chain: - TrackShardMetricsActor receives the WaitMetrics reply and updates its AsyncVar<Optional<ShardMetrics>> via set(). - AsyncVar::set destroys the old onChange Promise<Void>, sends to the onChange listeners - The QuorumCallback inside changeSizes (or GetFirstSizeActor) fires, completing the quorum. changeSizes completes. - trackInitialShards resumes after wait(changeSizes(...)). It calls self->readyToStart.send(Void()), then hits wait(initialSize). If initialSize is already satisfied (all shards have reported), trackInitialShards returns. - DataDistributionTrackerImpl::run resumes at a_body1cont2 — i.e., after wait(trackInitialShards(...)). 8. Without any trackerCancelled check, run proceeds straight into the loop choose for the first time — a_body1cont2loopHead1 in the generated code. The crash 9. The loop choose evaluates which futures are ready. loggingTrigger was initialized as Void() and has never been reset yet (this is the first entry into the loop). It is already complete. 10. The when(wait(loggingTrigger)) branch fires immediately and executes: TraceEvent("DDTrackerStats", self->distributorId) .detail("Shards", self->shards->size()) // <-- CRASH 11. self->shards is a raw KeyRangeMap<ShardTrackedData>* pointing at the state shards variable back in dataDistribution. That shards is in the middle of clearAsync() — its internal structure is partially destroyed/invalid. 12. Accessing shards->size() on a partially-cleared KeyRangeMap causes a segfault. Signal 11 (SIGSEGV). (cherry picked from commit 3f15166 on main) * Track min popped version separately for system localities in TLog (#12755) (cherry picked from commit df5a98d on main)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
File read can't be cancelled, so we have to hold on the buffer and issue reads.
This was found in #12642 test, seed:
-f ./tests/slow/BulkDumpingS3WithChaos.toml -s 1554084314 -b off
20260116-223043-jzhou-860a6897a9eb32c2 compressed=True data_size=34489903 duration=4665976 ended=100000 fail=1 fail_fast=10 max_runs=100000 pass=99999 priority=100 remaining=0 runtime=0:53:38 sanity=False started=100000 stopped=20260116-232421 submitted=20260116-223043 timeout=5400 username=jzhou
-f ./tests/slow/ParallelRestoreOldBackupCorrectnessAtomicOp.toml -s 223090903 -b on, unrelated errorAssertion batchData.isValid() failed @ /root/src/foundationdb/fdbserver/RestoreApplier.actor.cpp 740:.Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.
For Release-Branches
If this PR is made against a release-branch, please also check the following:
release-branchormainif this is the youngest branch)