Repository navigation
Conversation
codelipenghui
left a comment
There was a problem hiding this comment.
A failed snapshot create with no ID should be a no-op for both BookKeeper and cursor metadata. I reproduced the remaining gap on this PR head: when 'clear()' was waiting for a snapshot that failed to create, it still tried to remove the cursor property, and an injected metadata error made 'clear()' fail. Moving property removal into the branch that has an ID fixed the regression locally without swallowing real delete errors. The gated clear test, the failed-create trim test, and the terminal-delete retry test all passed with that change.
|
Fixed in 86664a6. |
f1368a5 to
12da5a0
Compare
The missing-ledger handling (-25), the superseded-ledger delete before a replacement snapshot is allocated, and the compare-and-remove guards for the bucket cursor property moved to apache#27673, together with their tests, so this PR reviews only the cursor-reset semantics. The reset cleanup invokes those paths through unchanged APIs; re-add the reset-level missing-ledger regression after apache#27673 lands. Assisted-by: Claude Code
void-ptr974
left a comment
There was a problem hiding this comment.
Two timing cases around in-flight snapshot creation.
codelipenghui
left a comment
There was a problem hiding this comment.
The earlier no-ID cleanup issue remains fixed, and the new ownership check prevents a failed create from repopulating the queue after 'clear()' detaches its bucket. The reviewer’s second concern remains: an unfinished trim future does not prove trim has reached the gated bucket. I changed my recommendation from approve to request changes because the new cursor-property guard can still remove a replacement snapshot’s only durable reference. All 10 focused tests passed, but none exercises a replacement published between the property check and the removal.
| String currentBucketId = cursor.getCursorProperties().get(key); | ||
| if (currentBucketId == null || !currentBucketId.equals(deletedBucketId)) { | ||
| // The property has been replaced by a later snapshot; do not remove it. | ||
| return CompletableFuture.completedFuture(null); | ||
| } | ||
| return cursor.removeCursorProperty(key); |
There was a problem hiding this comment.
Make cursor-property compare-and-remove atomic
Residual snapshot cleanup reads property K → A after deleting ledger A. Before it calls 'removeCursorProperty(K)', another tracker publishes K → B for the same retained range. This can happen when backlog clear starts residual cleanup before tracker initialization, then a concurrent cursor reset and replay rebuild that range while the cleanup is still in flight. The stale cleanup can erase B’s only durable reference and report success. B remains allocated but cannot be discovered for recovery or residual cleanup after the tracker is lost. The broker must rebuild those delayed indexes from the backlog.
The factory sequencer is local to one cleanup call, separate from the tracker’s sequencer. The new helper compares the value and then calls unconditional removal. 'ManagedCursorImpl' takes a fresh map and metadata version inside that removal call, so a replacement fully published in between can be removed without any version conflict. The bucket helper at 'ImmutableBucket.java:212–219' has the same split across sequencers; rechecking on retry cannot help when the first removal succeeds. The new tests publish the replacement before the check, not between the check and the update.
Use a cursor-level conditional removal that compares the expected ledger ID against the same versioned snapshot used for the metadata update. Skip the write on a mismatch and re-evaluate the condition on conflict. Use it in both cleanup paths and add a gated test that publishes B after the old cleanup observes A.
There was a problem hiding this comment.
Deferred to a separate follow-up PR: the atomic conditional removal needs a cursor-level API (removeCursorPropertyIfValue-style, comparing the expected value against the same versioned metadata snapshot used for the write, rechecking on version conflict), which is a managed-ledger change on its own. For now 2f42930 adjusts the helper's javadoc to say it closes the common ordering (the replacement published before the check) rather than all of them, matching your [QUALITY] note. I will link the follow-up here once opened.
lhotari
left a comment
There was a problem hiding this comment.
Thanks for splitting this out and for the thorough tests. Replacing the INVALID_BUCKET_ID sentinel with exceptional completion is a clear improvement. I checked every consumer of getSnapshotCreateFuture() (merge, load, trim, clear, close), and each one either handles the exceptional completion or only checks isDone(). Treating -25 like -7 and the compare-and-remove of the cursor property also look right.
Nothing blocking. The inline comments are about the single-attempt superseded-ledger delete in asyncSaveBucketSnapshot, a trim test that does not pin the path it describes (and can hang teardown on failure), a slightly stronger race guarantee in the description than the factory code provides, and two nits.
codelipenghui
left a comment
There was a problem hiding this comment.
The head is unchanged at 'c09c4962f9'. The no-ID cleanup and the reported late requeue after 'clear()' remain fixed. The new review corroborates both open findings: the factory can still remove a replacement’s durable reference, and the trim test can pass without reaching the gated bucket. I still recommend request changes: the guard is safe for writes serialized by one tracker, but documenting the factory’s narrower guarantee would not prevent the orphaned snapshot.
| String currentBucketId = cursor.getCursorProperties().get(key); | ||
| if (currentBucketId == null || !currentBucketId.equals(deletedBucketId)) { | ||
| // The property has been replaced by a later snapshot; do not remove it. | ||
| return CompletableFuture.completedFuture(null); | ||
| } | ||
| return cursor.removeCursorProperty(key); |
There was a problem hiding this comment.
Make cursor-property compare-and-remove atomic
Residual cleanup sees K → A after deleting ledger A, then a tracker publishes K → B before cleanup calls the unconditional removal. Backlog clear can start residual cleanup before tracker initialization; a concurrent cursor reset and replay can rebuild the same retained range while that cleanup is pending. Cleanup can report success after erasing B’s only durable reference. The ledger remains allocated and cannot be found by recovery or residual cleanup after the tracker is lost.
The factory uses a sequencer local to one cleanup call, not the tracker’s sequencer. The cursor takes a fresh map and metadata version inside 'removeCursorProperty', so a completed publication between the compare and the call need not cause a version conflict. The new review independently confirms this interleaving. The prior focused test publishes the replacement before the compare and therefore does not cover it.
Use a cursor-level conditional removal that checks the expected ID against the same versioned state used for the write. Recheck on a version conflict, and add a gated test that publishes the replacement after cleanup reads the old value.
There was a problem hiding this comment.
Deferred to a separate follow-up PR: the atomic conditional removal needs a cursor-level API (removeCursorPropertyIfValue-style, comparing the expected value against the same versioned metadata snapshot used for the write, rechecking on version conflict), which is a managed-ledger change on its own. For now 2f42930 adjusts the helper's javadoc to say it closes the common ordering (the replacement published before the check) rather than all of them, matching your [QUALITY] note. I will link the follow-up here once opened.
codelipenghui
left a comment
There was a problem hiding this comment.
'2f42930d0d' fixes the superseded-ledger retry and the trim test’s wait and teardown. All seven focused tests passed. The author explicitly deferred atomic cursor-property removal; the new Javadoc accurately describes the remaining race but does not fix it. That is still my reason to request changes. The revised trim test also introduces an unlocked read of the live bucket map.
| String currentBucketId = cursor.getCursorProperties().get(key); | ||
| if (currentBucketId == null || !currentBucketId.equals(deletedBucketId)) { | ||
| // The property has been replaced by a later snapshot; do not remove it. | ||
| return CompletableFuture.completedFuture(null); | ||
| } | ||
| return cursor.removeCursorProperty(key); |
There was a problem hiding this comment.
Make cursor-property removal conditional on the value being deleted
While residual cleanup is in flight, cursor reset and replay can rebuild the same retained range. If the replacement is published after cleanup reads the old ledger ID but before it calls 'removeCursorProperty', the stale cleanup removes the new mapping. Cleanup can report success after removing the replacement ledger’s only durable reference. Recovery must rebuild the delayed indexes, and residual cleanup cannot discover the orphaned ledger.
The follow-up changes only the Javadoc here. The factory and the tracker use different sequencers, and the unconditional cursor removal reads a fresh map and metadata version. A publication that completes in the gap can therefore be removed without a version conflict. The passing factory test publishes the replacement before the comparison, not in that gap.
Land the proposed managed-ledger API as a prerequisite, then use it here: compare against the same versioned cursor state used for the removal and recheck on conflict. Add a gated test that publishes the replacement after cleanup observes the old ID.
There was a problem hiding this comment.
Fixed in bdf922b, on top of the now-merged #27703: both guarded removals go through ManagedCursor#updateCursorProperties, so the check that the property still references the deleted ledger and the removal are one cursor update — a replacement published between the check and the removal can no longer be erased. The factory-side two-step helper is gone entirely (cleanResidualSnapshots carries the closure from #27703), and ImmutableBucket#removeBucketCursorPropertyIfStillReferences applies the same conditional closure inside its existing executeWithRetry. testCleanResidualSnapshotsKeepsReplacementPublishedDuringDelete (from #27703) covers the factory call site with the delete held open and the replacement published mid-flight, and the bucket-level race tests pass through the closure.
There was a problem hiding this comment.
Follow-up in 7ba85c1: added testDeleteRemovesCursorPropertyThroughAtomicConditionalUpdate, which pins the bucket-level delete path to the closure — it captures the updateCursorProperties function the delete applies, verifies the conditional (removes only while the value still references the deleted ledger) and fails against the two-step check-then-remove. The narrow mid-window race itself is only deterministically observable with a real CAS-guarded cursor, which ManagedCursorUpdatePropertiesTest covers at the managed-ledger level; the bucket test pins the composition.
lhotari
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the quick turnaround. The superseded-ledger delete now retries and records delete metrics, the trim test pins the delete-claimed path and no longer strands teardown, and both nits are fixed. Deferring the atomic conditional removal to a separate managed-ledger change makes sense. Please link the follow-up here once it is open.
One small inline note: the new bucket lookup in testTrimSkipsFailedSnapshotCreation reads the range map outside the tracker lock and could be flaky.
codelipenghui
left a comment
There was a problem hiding this comment.
No code changed at '2f42930d0d'. The superseded-ledger retry, the trim test’s wait and teardown, and the earlier no-ID cleanup remain fixed. The new approval accepts deferring atomic removal and confirms the unlocked test lookup. My recommendation remains request changes: the factory can still erase a replacement snapshot’s only durable reference. The lookup is a separate, lower-severity test issue.
| String currentBucketId = cursor.getCursorProperties().get(key); | ||
| if (currentBucketId == null || !currentBucketId.equals(deletedBucketId)) { | ||
| // The property has been replaced by a later snapshot; do not remove it. | ||
| return CompletableFuture.completedFuture(null); | ||
| } | ||
| return cursor.removeCursorProperty(key); |
There was a problem hiding this comment.
Make cursor-property removal conditional on the value being deleted
Residual cleanup reads the old ledger ID, then a concurrent save publishes a replacement for the same retained range before cleanup calls 'removeCursorProperty'. A cursor reset and replay can rebuild that range while residual cleanup is pending. Cleanup can erase the replacement’s only durable reference and still report success. Recovery must rebuild the delayed indexes, and residual cleanup cannot discover the orphaned ledger.
The factory’s sequencer is separate from the tracker’s. The unconditional removal takes a fresh cursor map and metadata version, so it can remove a replacement published between the check and the call without a version conflict. The author acknowledged and deferred this window; no code has changed since the previous review.
Land the managed-ledger conditional removal as a prerequisite and use it here. Compare the expected ID against the same versioned cursor state used for the removal, recheck on conflict, and test publication between the old comparison and removal.
There was a problem hiding this comment.
The managed-ledger conditional removal is now up as #27703: removeCursorPropertyIfValue compares and removes inside one property-update application, fails with BadVersionException on conflict, and a retry re-evaluates the condition. The factory call site here will switch to it when this branch rebases onto #27703 (the factory currently carries the compare-then-remove with the recheck-on-retry, which #27703 makes atomic).
codelipenghui
left a comment
There was a problem hiding this comment.
'33a7922edd' fixes the test race: both gated bucket lookups now run under the tracker lock, and the tests wait outside it. All three focused tests passed. My recommendation remains request changes because this commit changes only tests; residual cleanup can still erase a replacement snapshot’s only durable reference.
The missing-ledger handling (-25), the superseded-ledger delete before a replacement snapshot is allocated, and the compare-and-remove guards for the bucket cursor property moved to apache#27673, together with their tests, so this PR reviews only the cursor-reset semantics. The reset cleanup invokes those paths through unchanged APIs; re-add the reset-level missing-ledger regression after apache#27673 lands. Assisted-by: Claude Code
…d creation Remove the INVALID_BUCKET_ID sentinel: a failed snapshot creation now propagates through the create future, ImmutableBucket.resolveBucketIdForDelete() converts it into nothing-to-delete, and the sequential trim chain keeps going. deleteBucketSnapshot() revalidates range-to-bucket ownership before and after the delete, and failed-create deletes no longer count delete metrics. Adds testTrimSkipsFailedSnapshotCreation. Assisted-by: Claude Code
…no snapshot ID asyncDeleteBucketSnapshot() ran removeBucketCursorProperty even when resolveBucketIdForDelete() returned Optional.empty() for a failed creation. A failed create should be a no-op for both BookKeeper and cursor metadata. Property removal now runs only in the branch that has a real snapshot ID to delete. Adds testFailedCreateClearDoesNotRemoveCursorProperty. Assisted-by: Claude Code
…aves Bucket-snapshot cleanup hardenings, split out of the cursor-reset PR (apache#26420) so each change reviews in its own domain: - BookkeeperBucketSnapshotStorage treated only NoSuchLedgerExistsException (-7) as "ledger gone"; the metadata-store BK driver reports NoSuchLedgerExistsOnMetadataServerException (-25) for a ledger whose metadata is gone, so a cleanup retry of a cursor property whose ledger was already deleted failed forever. deleteLedger and openLedger now use Errors.isNoSuchLedgerExistsException, which accepts both codes; recovery maps both to BucketNotExistException, so a stale property self-heals on the next tracker recovery. - The bucket cursor property is the only durable reference to a snapshot ledger. ImmutableBucket.asyncSaveBucketSnapshot deletes the superseded ledger the property still references before allocating the replacement; if that delete fails, the save fails before creating the replacement, so the property keeps referencing the superseded ledger until a later save retries, and no replacement ledger can be orphaned. - A delete that is racing a later snapshot save for the same bucket key must not remove the replaced property: both the bucket delete path and cleanResidualSnapshots recheck that the property still references the deleted ledger before removing it (inside the retried supplier at the bucket level, so a retry after a concurrent replacement also observes the current value). - Regression locks: a malformed bucket id in cleanResidualSnapshots fails the cleanup future instead of throwing synchronously (the parse must stay inside the sequenced supplier), and the entries scheduled before the malformed one are still cleaned. Assisted-by: Claude Code
…aimed delete A create-failure downgraded the bucket to memory mode unconditionally: when a trim or clear had already claimed the bucket's delete and was waiting on the pending create, the failure callback re-queued the bucket's indexes into the shared queue after the clear had emptied it, so the tracker kept delivering stale entries under a successful clear. The delete now claims the bucket when it starts (asyncDeleteBucketSnapshot sets a flag), and the failure callback skips the downgrade when the bucket is claimed or no longer mapped — the delete owns the cleanup. Also harden testTrimSkipsFailedSnapshotCreation against the ordering where the gate failed before the trim chain had reached the blocked create: the test now waits until the trim future is running before failing the creation, so the exercised path is a trim delete blocked on the pending create when it fails. Assisted-by: Claude Code
…st ordering - The superseded-ledger delete ran once with no retry and no metrics, so a single transient BookKeeper error failed the whole snapshot save and downgraded the bucket to memory mode. It now goes through the same bounded retry as the other snapshot deletes and records delete trigger/success/fail events; testSaveRetriesTransientSupersededLedgerDelete covers a first-attempt failure that the retry clears. - testTrimSkipsFailedSnapshotCreation waited only on the aggregate trim future, which can be pending on a different bucket; it now waits until the gated bucket is delete-claimed before failing the create, and both gated tests release the create gate in finally before closing the tracker so a failed assertion cannot strand teardown. - Removed the now-unused unconditional removeBucketCursorProperty, and the deleteStarted/factory-helper comments state their actual visibility and ordering guarantees. Assisted-by: Claude Code
The trim callback removes buckets from the live range map under the monitor, so streaming it to locate the gated bucket outside the lock can fail the lookup before the intended ordering is verified. Assisted-by: Claude Code
33a7922 to
bdf922b
Compare
The missing-ledger handling (-25), the superseded-ledger delete before a replacement snapshot is allocated, and the compare-and-remove guards for the bucket cursor property moved to apache#27673, together with their tests, so this PR reviews only the cursor-reset semantics. The reset cleanup invokes those paths through unchanged APIs; re-add the reset-level missing-ledger regression after apache#27673 lands. Assisted-by: Claude Code
bdf922b to
7ba85c1
Compare
| if (immutableBucket.isDeleteStarted() || immutableBuckets.asMapOfRanges() | ||
| .get(Range.closed(immutableBucket.getStartLedgerId(), | ||
| immutableBucket.getEndLedgerId())) != immutableBucket) { | ||
| return; |
There was a problem hiding this comment.
The merge and replay can overlap in this order.
- The tracker has recovered
[10,10]and[20,20]. Replay seals[1,1], and the tracker selects all three buckets for a merge. - While the merge reads those snapshots asynchronously, replay seals
[3,3]. Its first segment goes into the delivery queue, and its snapshot write is still pending. - The merge installs
[1,20]inimmutableBuckets. The new range replaces the[3,3]mapping, even though the merge only read the three buckets it selected in step 1. - If the
[3,3]write then fails, the exact-range lookup in this guard finds no entry and the callback returns before queuing the remaining segments.
When dispatch reaches the last entry of the first segment, getScheduledMessages also skips loading the next segment because the original bucket is no longer in the map. That can leave the rest of the messages in [3,3] undelivered even after they become due.
There was a problem hiding this comment.
Apologies for the late reply — I missed this comment when it was posted. Fixed in 1a1f8d3, together with @codelipenghui's identical finding: the merge install now revalidates under the tracker lock that the ranges covered by the merged enclosing range map to exactly the selected inputs, and aborts otherwise, so the [3,3] mapping is never displaced and your step-4 concern (the exact-range guard finding nothing after the displacement) cannot arise. testMergeAbortsWhenBucketAppearsInTheGap drives your ordering deterministically — inputs selected, merge held on a gated segment read, a bucket sealed into the gap, gate released — and fails against the unguarded install.
| .log("Failed to record bucketId to cursor property"); | ||
| return null; | ||
| }).thenApply(__ -> newBucketId); | ||
| }).thenApply(ignored -> newBucketId); |
There was a problem hiding this comment.
The cursor can lose access to both snapshots during a single replacement save.
- The cursor property for the bucket points to ledger A.
deleteSupersededSnapshotLedgerdeletes A from BookKeeper and leaves the property pointing to A. - BookKeeper successfully creates the replacement ledger B, and
setBucketIdrecords B in memory. - If
putBucketKeyIdfails before the new value is persisted,exceptionallylogs the error and completes normally. The followingthenApplyreturns B’s ID, so the caller sees a successful save.
After a tracker reload, recovery reads the ledger ID from the cursor property and tries to open the deleted ledger A. Ledger B remains allocated without a cursor reference, so the tracker cannot restore it on reload.
There was a problem hiding this comment.
Apologies for the late reply — I missed this comment when it was posted. Fixed in 1a1f8d3, together with @codelipenghui's identical finding: the .exceptionally swallow is removed, so durable cursor publication is the success point — your step 3 now fails the save instead of returning B's id, the property keeps pointing at the (already deleted) A, and the retry's superseded delete treats NoSuchLedgerExists as benign before creating and publishing the next replacement. testSaveFailsWhenCursorPublicationFails pins it and fails against the swallow.
codelipenghui
left a comment
There was a problem hiding this comment.
The rebase onto #27703 resolves the earlier atomic-removal finding, and the gated-test locking fix is still in place. My recommendation remains request changes, now for two separate cases raised in the new discussion: a merge can displace a bucket it did not read, and a replacement save can report success after deleting the old snapshot without publishing the new one. All 12 focused tests passed, but they do not force either failure path.
| if (immutableBucket.isDeleteStarted() || immutableBuckets.asMapOfRanges() | ||
| .get(Range.closed(immutableBucket.getStartLedgerId(), | ||
| immutableBucket.getEndLedgerId())) != immutableBucket) { | ||
| return; |
There was a problem hiding this comment.
Revalidate merge inputs before replacing the covered range
After recovery, a merge selects buckets with gaps, such as '[1,1]', '[10,10]', and '[20,20]'. While the merge reads those snapshots, replay seals a multi-segment bucket at '[3,3]'. The merge publishes '[1,20]' before the '[3,3]' create fails. The displaced bucket’s later segments are neither in the merged snapshot nor requeued on failure. Their messages can remain undelivered past their scheduled time while the tracker still has them marked as tracked.
The merge loads only its selected inputs (lines 652–665) and then installs the enclosing range (lines 666–696) without checking for a new overlapping bucket. 'putBucket' overwrites overlapping mappings. The new failure guard treats the lost mapping as proof that another operation owns cleanup and skips the in-memory fallback at lines 480–488. Delivery also refuses to load further segments for a bucket no longer in the map (lines 783–787).
Under the tracker lock, verify that the merge inputs are still the current buckets and that no other bucket overlaps the output range before creating or publishing it. Abort or reselect on a mismatch. Add a gated test that seals an intervening bucket during a merge read and verifies its later segments remain deliverable.
There was a problem hiding this comment.
Fixed in 1a1f8d3 — replying on this original thread as well: the merge install now revalidates under the tracker lock that the covered ranges map to exactly the selected inputs and aborts otherwise, with testMergeAbortsWhenBucketAppearsInTheGap covering the ordering (red against the unguarded install). Details in the reply on the re-opened thread.
| .log("Failed to create bucket snapshot"); | ||
| } | ||
| }), BucketSnapshotPersistenceException.class, MaxRetryTimes).thenCompose(newBucketId -> { | ||
| return deleteSupersededSnapshotLedger(bucketKey, stats) |
There was a problem hiding this comment.
Do not retire the old snapshot before the replacement is published
A cursor property still points to ledger A. The replacement save deletes A and successfully allocates B, but publishing B’s ID to the cursor fails before it is persisted. The caller sees a successful save even though recovery cannot find either snapshot: the property points to deleted A, and B remains allocated without a durable reference. A merge can also delete its source snapshots because it sees the save as successful.
The new pre-delete at line 144 runs before allocation. The existing 'exceptionally' at lines 160–168 logs a property-write failure but returns B’s ID anyway. Without this PR’s pre-delete, the same definite publication failure could leak B, but it did not delete A. The merge’s source cleanup at lines 705–714 treats normal completion as proof the replacement is recoverable.
Make durable cursor publication the success point. Keep A until B’s mapping is committed and retain a durable way to retry deleting A afterward. On a definite publication failure, surface it and clean up or track B; if the write outcome is ambiguous, verify the mapping before deleting B. If that handoff is out of scope, split out the pre-delete change. Add a regression that injects property-write failure after B is allocated.
There was a problem hiding this comment.
Fixed in 1a1f8d3 — replying on this original thread as well: the .exceptionally swallow is removed and durable cursor publication is the success point, with testSaveFailsWhenCursorPublicationFails pinning the failure (red against the swallow). Details in the reply on the re-opened thread.
2a90126 to
daa8b86
Compare
…nditional update Both guarded removals now go through ManagedCursor#updateCursorProperties from apache#27703: the check that the property still references the deleted ledger and the removal are one cursor update, so a save publishing a replacement for the same bucket key while the delete is in flight cannot lose its only durable reference even when the publication completes between the check and the removal. The factory-side helper is gone entirely - cleanResidualSnapshots already carries the closure from apache#27703 - and ImmutableBucket's helper applies the same closure inside its existing executeWithRetry. Assisted-by: Claude Code
daa8b86 to
5d5849f
Compare
codelipenghui
left a comment
There was a problem hiding this comment.
The history was rewritten, but '5d5849f270' changes only test import order relative to the last reviewed head. The author is right that atomic cursor-property removal is fixed; my last review closed that finding, and I found no unconditional removal in either cleanup path. I still recommend request changes for the two separate, unchanged issues: a merge can displace a bucket it did not read, and a save can delete the old snapshot before the replacement is recoverable. All three focused tests passed.
| if (immutableBucket.isDeleteStarted() || immutableBuckets.asMapOfRanges() | ||
| .get(Range.closed(immutableBucket.getStartLedgerId(), | ||
| immutableBucket.getEndLedgerId())) != immutableBucket) { | ||
| return; |
There was a problem hiding this comment.
Revalidate merge inputs before replacing the covered range
A merge starts reading selected snapshots whose ledger ranges contain a gap. Replay seals a multi-segment bucket in that gap. The merge installs its enclosing range before the intervening bucket’s snapshot create fails. The intervening bucket’s later segments are neither in the merged snapshot nor requeued on failure. The corresponding messages can remain undelivered after their scheduled time while the tracker still marks them as tracked.
The merge reads only the selected inputs (lines 652–665), then installs the enclosing range (lines 666–696) without checking for a new overlap. That replaces the intervening mapping. The failure guard returns without the in-memory fallback, and delivery will not load further segments from a bucket absent from the map (lines 783–787). This production code is unchanged from the previous review.
Under the tracker lock, revalidate the selected bucket identities and check for any unselected overlap before creating the merged bucket. Abort or reselect if the range changed. Add a gated regression that seals an intervening bucket during the merge read.
There was a problem hiding this comment.
Fixed in 1a1f8d3. The install now revalidates under the tracker lock before creating the merged bucket: the ranges covered by the enclosing merge range must map to exactly the selected inputs, otherwise the merge aborts (returns without touching the map) and the next trim cycle retries with fresh inputs — a bucket sealed into the gap stays mapped and its own create-failure guard keeps working.
testMergeAbortsWhenBucketAppearsInTheGap covers it deterministically: two source buckets with a ledger gap, trim+merge triggered and held on a gated segment read after the inputs were selected, a bucket installed into the gap, then the gate released — the gap bucket stays mapped and no enclosing range is installed. It fails against the unguarded install (the gap bucket is displaced).
| .log("Failed to create bucket snapshot"); | ||
| } | ||
| }), BucketSnapshotPersistenceException.class, MaxRetryTimes).thenCompose(newBucketId -> { | ||
| return deleteSupersededSnapshotLedger(bucketKey, stats) |
There was a problem hiding this comment.
Keep the old snapshot until its replacement is published
The cursor points to ledger A. A replacement save deletes A and allocates B, but writing B’s ID to the cursor fails before it is persisted. The save reports success even though recovery can open neither snapshot through the cursor: A is gone and B has no durable reference. A merge can also retire its source snapshots after this false success.
The pre-delete at line 144 precedes allocation. The handler at lines 160–168 still swallows cursor publication failure and returns B’s ID. The merge treats successful completion as permission to delete its sources (lines 705–714). The new head leaves all of these paths unchanged; conditional removal does not address failed publication.
Make durable cursor publication the success point. Keep A until B’s mapping is committed and retain a durable reference for retrying A’s cleanup. On publication failure, surface the failure and clean up or track B without deleting it on an ambiguous write outcome. If that handoff is out of scope, split out the pre-delete change.
There was a problem hiding this comment.
Fixed in 1a1f8d3: the .exceptionally swallow is gone — durable cursor publication is now the success point, so a failed putBucketKeyId fails the save. The chain you described then resolves itself: the save failure keeps the source indexes recoverable and re-queues them (the existing after-create failure machinery), the merge's createFailed branch takes keepUncleaned instead of retiring its sources on a false success, and the retry's deleteSupersededSnapshotLedger sees the property still referencing the already-deleted ledger and treats NoSuchLedgerExists as benign (this PR's -7/-25 mapping), so it proceeds to create and publish the next replacement.
testSaveFailsWhenCursorPublicationFails pins it: publication fails persistently, the save future fails instead of reporting success, and the property keeps referencing the superseded ledger. It fails against the swallow (the save reports false success).
… save success point A merge selects its inputs, reads their snapshots, and installs the merged enclosing range. A bucket sealed into a ledger gap between the selection and the install would be silently displaced by that range: its indexes are in neither the merged snapshot nor any source, so the messages can stay undelivered while the tracker still marks them tracked. The install now revalidates under the tracker lock that the covered ranges map to exactly the selected inputs and aborts the merge otherwise; the next trim cycle retries with fresh inputs. A replacement save deleted the superseded ledger, allocated the replacement, and swallowed a cursor-publication failure, reporting success while recovery could open neither snapshot: the old ledger is gone and the new one has no durable reference. Durable publication is now the success point — the save fails when the property write fails, the source indexes stay recoverable, and the retry's superseded delete treats the already-deleted ledger as benign. Assisted-by: Claude Code
codelipenghui
left a comment
There was a problem hiding this comment.
The merge now revalidates its inputs under the tracker lock, and a failed cursor write no longer reports a successful save or triggers merge-source deletion. The author’s replies are correct on those points. I still recommend request changes: the failed-publication path can leave the old snapshot deleted and the newly allocated ledger untracked. The new merge test also needs to wait for the merge to finish before asserting. All eight focused tests passed.
| .thenCompose(newBucketId -> { | ||
| setBucketId(newBucketId); | ||
|
|
||
| return putBucketKeyId(bucketKey, newBucketId).exceptionally(ex -> { | ||
| log.warn() | ||
| .attr("dispatcher", dispatcher) | ||
| // Durable cursor publication is the success point: the superseded ledger | ||
| // is already deleted, so swallowing a publication failure would leave | ||
| // recovery unable to open any snapshot for this bucket. | ||
| return putBucketKeyId(bucketKey, newBucketId).thenApply(ignored -> newBucketId); |
There was a problem hiding this comment.
Preserve a recoverable snapshot and account for the new ledger if publication fails
A same-range replacement deletes the ledger A named by the cursor property, allocates ledger B, and then fails to publish B’s ID. The orphaned-B case also occurs on a first save, with no A to delete. The same-range save leaves the cursor pointing to deleted A, so recovery cannot restore either snapshot. B remains allocated without a cursor reference, and normal trim or clear cannot reclaim it. Repeated publication failures can accumulate orphaned BookKeeper ledgers.
The pre-delete at line 144 remains. Lines 157–163 cache B’s ID but now complete the save exceptionally when publication fails. The tracker’s failure callback requeues indexes and detaches the bucket without scheduling a delete; if trim or clear already claimed it, 'resolveBucketIdForDelete()' returns empty for the failed future even though B’s ID is cached. Merge keeps only its source buckets for cleanup, not B. A later save can retry the already-deleted A, but that does not reclaim B. The passing regression checks the future and the old property value, not either ledger’s fate.
Keep A recoverable until B’s mapping is committed, or defer the pre-delete change. Distinguish a failure before allocation from a publication failure after allocation: delete or track B for retry when publication definitely failed, and verify authoritative metadata before deleting B if the write outcome is ambiguous. Extend the fault-injection test to verify which ledger remains recoverable and that cleanup accounts for B.
There was a problem hiding this comment.
Fixed in 7753781, taking your second prescription (distinguish the post-allocation failure): the publication-failure handler now checks the cursor property before acting — if it already carries the new bucket id, the publication landed despite the failure and the save completes with B; otherwise the handler reclaims B with a compensating deleteBucketSnapshot (a reclaim failure is logged, not propagated — the save already failed), and the save still fails so the source indexes stay requeued and the merge keeps its sources. Repeated publication failures can no longer accumulate orphaned ledgers.
On the first prescription (keep A recoverable until B is committed): with the pre-delete retained, a definite publication failure still leaves the cursor naming the deleted A, which the recovery path self-heals through NoSuchLedgerExists → property cleanup → rebuild from the log (the tracker is a derived cache). The test now verifies the ledger fates you asked for: testSaveFailsWhenCursorPublicationFails records every created/deleted ledger id and asserts the superseded ledger was pre-deleted, the property still names it, the replacement was allocated exactly once, and — the new part — the replacement id shows up in the deleted set (red against the plain-fail variant without the reclaim). If you prefer the strict reorder (publish-then-delete) despite the trade-off it makes on the superseded-delete retry path, say so and I will rework it.
There was a problem hiding this comment.
Strengthened in 7cc5d0c: the reclaim now goes through executeWithRetry(..., BucketSnapshotPersistenceException.class, MaxRetryTimes) and records the delete trigger/success/fail metrics, mirroring the superseded delete in the same method — a transient reclaim failure no longer leaks the ledger. testSaveRetriesReclaimOfUnpublishedLedger injects a one-shot delete failure for the replacement id and asserts the retry reclaims it (red against the single-shot reclaim).
Honest residual, narrower than before: after the publish failure AND all reclaim retries fail (a persistent storage outage), the ledger still leaks — there is no durable registry to track it in, and the cursor property cannot record it without publishing. The retry covers the transient case you described; if you want the persistent-outage case closed too, that needs a durable retry-tracking mechanism which I would rather design separately than bolt onto this save path.
There was a problem hiding this comment.
Follow-up in d348ce01c88: the exhausted-reclaim case is now covered by the existing cleanup machinery instead of leaking. resolveBucketIdForDelete() returns the cached ledger id when the create future failed but a replacement was allocated and is not the value the property references — so a tracked delete resolves and deletes it instead of skipping — and the create-failure callback keeps such a bucket in uncleanedBuckets, where clear() retries it through the normal tracked-delete path (a failed retry is re-added, in-process). This also repairs the claimed-delete paths (recovery and merge) that resolve through the same method. testFailedSaveKeepsUnpublishedLedgerReclaimableByClear pins the ordering: the immediate reclaim fails persistently, the ledger survives, and clear() reclaims it once deletes recover.
Boundary, stated plainly: uncleanedBuckets is in-process. If the publication failure, all reclaim retries, and every clear() retry happen to straddle a restart, the ledger leaks — the cursor property names the already-deleted superseded ledger and recovery self-heals it without ever learning about the unpublished one. Closing that needs either property-level bookkeeping of pending-delete ledgers (a metadata format change) or the publish-then-delete reorder (with the superseded-retry trade-off discussed earlier). I would treat that as a separate decision rather than stretch this save path.
| storage.gate.complete(null); | ||
|
|
||
| Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> { | ||
| synchronized (ts.tracker) { | ||
| assertThat(ts.tracker.getImmutableBuckets().asMapOfRanges()) | ||
| .containsKey(Range.closed(6L, 10L)) | ||
| .doesNotContainKey(Range.closed(1L, 15L)); | ||
| } |
There was a problem hiding this comment.
Wait for the merge to finish before checking the gap bucket
The test opens the gate, but the storage executor has not yet finished the segment reads when the assertion runs. The test can pass without exercising the new guard. It also checks for the wrong enclosing range, weakening the claimed deterministic regression coverage.
Opening the gate schedules the underlying reads; it does not wait for the trim/merge chain. The assertion is already true before the merge installs anything because the test just inserted the gap bucket. The three selected ranges end at ledger 20, so the enclosing range is '[1,20]', not '[1,15]'.
After opening the gate, await successful completion of the captured 'getTrimFuture()' with a timeout. Then assert that the same gap bucket is still mapped, the source buckets remain mapped, and '[1,20]' was not installed.
There was a problem hiding this comment.
You are right on both counts — the assertion was vacuous ([1,15] is never the installed range; the selection covers all three buckets) and the gate only scheduled the reads. Fixed in 7753781: the test now awaits getTrimFuture() before asserting, and asserts the gap bucket instance stays mapped, all three sources stay mapped, and the enclosing [1,20] is not installed. It still fails against the unguarded install (re-verified).
…he gap test A failed cursor publication after the replacement ledger was allocated left the replacement orphaned: no cursor property referenced it, trim and clear could not resolve it through the failed create future, and a later save only retried the already-deleted superseded ledger. Repeated publication failures could accumulate orphaned BookKeeper ledgers. The failure handler now verifies against the cursor property that the publication did not land, reclaims the unpublished ledger through executeWithRetry with the delete metrics — a transient reclaim failure is retried like every other ledger delete — and still fails the save. The gap test now waits for the trim/merge chain via getTrimFuture() before asserting — releasing the gate only schedules the reads — and asserts the correct enclosing range [1,20]: the selection covers all three buckets, so [1,15] was never the installed range and the old assertion was vacuous. Assisted-by: Claude Code
7753781 to
7cc5d0c
Compare
…gh clear When a snapshot save allocates a replacement ledger and cursor publication fails, the immediate reclaim now retries, but if those retries are exhausted the ledger is left unreachable: the create future has failed, so resolveBucketIdForDelete() returns empty and trim/clear skip the delete, and the cursor property still names the deleted superseded ledger. Make the unpublished allocation reclaimable by the existing cleanup machinery: resolveBucketIdForDelete() now returns the cached unpublished ledger id on create failure (unless the property already references it), and the create-failure callback keeps such a bucket in uncleanedBuckets so that clear() retries the delete through the normal tracked-delete path. testFailedSaveKeepsUnpublishedLedgerReclaimableByClear pins the ordering: the immediate reclaim fails persistently, the ledger is not deleted, then clear() (with deletes re-enabled) reclaims it. Assisted-by: Codex
…d-ledger reclaim A successful immediate reclaim leaves the cached bucket id set, so the create-failure callback still queues the bucket in uncleanedBuckets and a later clear() re-deletes a ledger that is already gone. Clear the cached id on reclaim success so the two mechanisms are strictly exclusive: testSuccessfulReclaimDoesNotQueueBucketForClearRetry pins that clear() makes no further delete attempt after the reclaim succeeded. Assisted-by: Codex
lhotari
left a comment
There was a problem hiding this comment.
Thanks for the follow-up commits. The merge revalidation closes the gap case, and making cursor publication the save's success point is the right direction.
One concern with the new reclaim: it decides that the replacement ledger was not published by reading the in-memory cursor properties. ManagedCursorImpl#computeCursorProperties only updates that map when the metadata write succeeds. If a write is committed but reported as failed (for example a timeout or connection loss), the reclaim deletes the ledger that the durable property now points to, and recovery cannot open the bucket. Before these commits that ledger was kept, so this case was safe. Details and two smaller points are inline.
| if (String.valueOf(newBucketId).equals( | ||
| ctx.cursor().getCursorProperties().get(bucketKey))) { |
There was a problem hiding this comment.
[MAJOR] the reclaim trusts the in-memory cursor properties after an ambiguous publication failure
ManagedCursorImpl#computeCursorProperties updates cursorProperties only in operationComplete. On operationFailed the cached map keeps the old value, even when the store actually committed the write (a metadata timeout or ZooKeeper connection loss can report a failure after the write landed).
Scenario: putBucketKeyId(bucketKey, newBucketId) commits the new id to the cursor ledger info, but the callback reports a failure. This check reads the stale cached map, finds no match, and the reclaim deletes newBucketId. The superseded ledger was already deleted by deleteSupersededSnapshotLedger, so after a topic reload the durable property points at a missing ledger and the bucket's delayed indexes cannot be recovered. resolveBucketIdForDelete (ImmutableBucket.java:459-461) makes the same decision from the same cache on the clear() path.
At bdf922b the failure was swallowed and the ledger was kept, so this case was safe at the cost of a possible leak. Could the reclaim re-read the durable cursor info before deleting, and skip the delete (or leave it to the clear() retry) when it cannot be confirmed? Leaking a ledger in the ambiguous case seems better than deleting a referenced one. The new publication-failure tests fail before any write, so a test where the write lands but the future fails would pin this.
There was a problem hiding this comment.
Agreed on both the severity and the direction: deleting a referenced ledger is worse than leaking one, and the reclaim cannot trust the cached properties after an ambiguous failure — operationFailed never refreshed them.
Fixed at the source in #27757 (managed-ledger, prerequisite for this PR): on a non-BadVersion failure of a property write, the cursor re-reads its info from the store and adopts the stored properties and version before the future fails, with the same not-older guard the publication reconciliation in persistPositionMetaStore uses. With that in place the cached map the reclaim (and resolveBucketIdForDelete on the clear() path) reads is the store's state at the moment the failure is observed, so your scenario — the write landed, the callback reported a failure — now resolves to "published" and the ledger is kept. BadVersion needs no refresh: the store rejected the write, so the cache is truthful about it.
Residual, stated plainly: if the write landed, the response was lost, and the immediate re-read fails, the cache stays stale and a cache-based delete is unconfirmed. Closing that needs a durable read at each decision site or a distinct "state unknown" signal to callers; I would rather keep that as a separate discussion than widen this PR.
The remaining three points (the double getBucketId() read and the unawaited reclaim racing the callback, the aborted merge counted as a success, the failure-injection arming order in the two sealing tests) are being fixed in this PR now; I will ping you when pushed.
There was a problem hiding this comment.
Thanks, refreshing the cache in #27757 is a good fix at the source, and testCursorPropertiesRefreshFromStoreWhenCommitResponseIsLost covers the scenario. Two follow-ups:
- This PR now depends on [fix][ml] Refresh cached cursor properties when a property write's response is lost #27757 for safety. Could you note that in the description, and rebase on top of it once it is merged, so this does not land first?
- About the residual: in [fix][ml] Refresh cached cursor properties when a property write's response is lost #27757 the refresh is also skipped when the ownership check fails or returns false, not only when the re-read fails. In those cases the reclaim here still deletes a ledger the durable property may point to. Before this PR, that ledger was kept. A small local guard would close the gap without widening [fix][ml] Refresh cached cursor properties when a property write's response is lost #27757: reclaim only when the failure is a
BadVersionException(the store definitely rejected the write) and leave the ledger in every other case. A leaked ledger is still reclaimed by theclear()and residual-snapshot cleanup.
One small mismatch: your reply says BadVersion needs no refresh, but #27757 refreshes on every failure and tests the version-conflict case. The #27757 description already says "any failure", so I think only the reply is out of date.
| if (immutableBucket.getBucketId().isPresent() | ||
| && !String.valueOf(immutableBucket.getBucketId().get()) | ||
| .equals(ctx.cursor().getCursorProperties() | ||
| .get(immutableBucket.bucketKey()))) { |
There was a problem hiding this comment.
[MINOR] the non-awaited reclaim races with this check, which reads getBucketId() twice
The reclaim in ImmutableBucket#asyncSaveBucketSnapshot is started but not awaited: the exceptionally rethrows right away, so this create-failure callback can run while the delete is still in flight. Two effects:
- If
setBucketId(null)lands betweengetBucketId().isPresent()andgetBucketId().get(),.get()throwsNoSuchElementExceptioninside the callback. Read the id once into a local. - With a real (asynchronous) BookKeeper delete the callback usually runs before the reclaim finishes, so the bucket is still added to
uncleanedBuckets. The comment atImmutableBucket.java:191-195sayssetBucketId(null)prevents that, which only holds when the delete completes synchronously, as in the mock.clear()then either no-ops or deletes the ledger a second time (missing ledgers are treated as success), so the behaviour is harmless, but the comment overstates it. Chaining the reclaim before rethrowing would make the ordering deterministic.
| if (covered.size() != buckets.size() || !covered.containsAll(buckets)) { | ||
| return CompletableFuture.completedFuture(null); | ||
| } |
There was a problem hiding this comment.
[NIT] an aborted merge is logged and counted as a successful merge
Returning completedFuture(null) here reaches the whenComplete at BucketDelayedDeliveryTracker.java:639-660 with ex == null, so it logs "Merge bucket snapshot finish" and calls recordSuccessEvent(Type.merge, ...) even though nothing was merged. A debug log line here and skipping the success stat (or a distinct outcome) would keep the merge metrics accurate.
| } | ||
| ts.tracker.addMessage(32, 1, 600L); // seals [31..31] | ||
| // The save fails on cursor publication and the immediate reclaim is made to fail | ||
| // persistently, so the unpublished ledger is left for the clear() retry. |
There was a problem hiding this comment.
[NIT] the reclaim delete failures are armed after the save has already started
addMessage(32, 1, 600L) seals the bucket and starts the asynchronous save before storage.failNextCreatedDelete is set. If the storage executor gets through create, the failed publication and the first reclaim attempt before this line runs, the replacement is deleted and doesNotContain(replacementId) fails. Setting the delete failure before the sealing addMessage removes the window. The transient-failure variant has the same ordering.
| if (String.valueOf(newBucketId).equals( | ||
| ctx.cursor().getCursorProperties().get(bucketKey))) { |
There was a problem hiding this comment.
Thanks, refreshing the cache in #27757 is a good fix at the source, and testCursorPropertiesRefreshFromStoreWhenCommitResponseIsLost covers the scenario. Two follow-ups:
- This PR now depends on [fix][ml] Refresh cached cursor properties when a property write's response is lost #27757 for safety. Could you note that in the description, and rebase on top of it once it is merged, so this does not land first?
- About the residual: in [fix][ml] Refresh cached cursor properties when a property write's response is lost #27757 the refresh is also skipped when the ownership check fails or returns false, not only when the re-read fails. In those cases the reclaim here still deletes a ledger the durable property may point to. Before this PR, that ledger was kept. A small local guard would close the gap without widening [fix][ml] Refresh cached cursor properties when a property write's response is lost #27757: reclaim only when the failure is a
BadVersionException(the store definitely rejected the write) and leave the ledger in every other case. A leaked ledger is still reclaimed by theclear()and residual-snapshot cleanup.
One small mismatch: your reply says BadVersion needs no refresh, but #27757 refreshes on every failure and tests the version-conflict case. The #27757 description already says "any failure", so I think only the reply is out of date.
Motivation
The
INVALID_BUCKET_IDsentinel blurred the outcome of snapshot creation: callers had to inspect the completed value for-1, and a failed creation could stall the sequential trim chain or leave state that a later delete treats inconsistently. Three further cleanup gaps made the delete/save paths unsafe on their own: a ledger already deleted from BookKeeper failed every later cleanup retry; the bucket cursor property — the only durable reference to a snapshot ledger — could be overwritten or removed while it still referenced an undeleted ledger; and a save that deleted the superseded ledger, allocated a replacement, and then failed to publish the replacement's id reported success while recovery could open neither snapshot.Modifications
INVALID_BUCKET_IDsentinel. A failed snapshot creation now propagates through the create future.ImmutableBucket#resolveBucketIdForDelete()resolves the id to delete through the create future: a successful creation resolves its id, a creation that failed before allocating anything resolves empty ("nothing to delete"), and a creation that failed after allocating a replacement resolves that cached id unless the cursor property already references it — so the tracked delete paths (trim, clear, recovery, merge) can reclaim an allocated-but-unpublished ledger instead of skipping it.deleteBucketSnapshot()revalidates range-to-bucket ownership before starting the delete and again before removing tracker state.BookkeeperBucketSnapshotStoragetreated onlyNoSuchLedgerExistsException(-7) as "ledger gone"; the metadata-store BK driver reportsNoSuchLedgerExistsOnMetadataServerException(-25) for a ledger whose metadata is gone, so a cleanup retry of a surviving cursor property failed forever.deleteLedgerandopenLedgernow useErrors.isNoSuchLedgerExistsException, which accepts both codes; recovery maps both toBucketNotExistException, so a stale property self-heals on the next tracker recovery. (Split out of [fix][broker] Clear delayed delivery state before resetting the cursor #26420.)ImmutableBucket#asyncSaveBucketSnapshotdeletes the superseded ledger the property still references before allocating the replacement; if that delete fails, the save fails before creating the replacement, so the property keeps referencing the superseded ledger until a later save retries, and no replacement ledger can be orphaned. (Split out of [fix][broker] Clear delayed delivery state before resetting the cursor #26420.)putBucketKeyIdfails the save instead of being swallowed, and a publication failure that landed despite the error (the property already carries the new id) still completes the save. When the publication did not land, the allocated replacement ledger is reclaimed immediately throughexecuteWithRetrywith the delete metrics; a successful immediate reclaim drops the cached id so the fallback below does not re-delete it.uncleanedBuckets, soclear()retries the delete through the normal tracked-delete path andresolveBucketIdForDelete()resolves the cached unpublished id. A failed retry is re-added, in-process; a ledger whose reclaim keeps failing across a restart is the documented residual (closing it needs property-level bookkeeping of pending deletes, or the publish-then-delete reorder).cleanResidualSnapshotsremove the property throughManagedCursor#updateCursorProperties([improve][ml] Add updateCursorProperties as an atomic read-modify-write closure #27703), so the check that the property still references the deleted ledger and the removal are one cursor update — inside the retried supplier at the bucket level, so a retry after a concurrent replacement also observes the current value. (Split out of [fix][broker] Clear delayed delivery state before resetting the cursor #26420, where the reset-cleanup/backlog-clear overlap makes the race reachable.)Verifying this change
Added tests:
testTrimSkipsFailedSnapshotCreationtestMissingLedgerOnMetadataServerIsTreatedAsAlreadyDeleted/testOpenLedgerMapsMissingOnMetadataServerToBucketNotExist(-25 handling)testSaveDoesNotAllocateReplacementWhenSupersededDeleteFails(superseded-ledger delete before replacement allocation)testDeleteDoesNotRemoveReplacementCursorProperty/testCleanResidualSnapshotsKeepsReplacementPublishedDuringDelete(compare-and-remove at both levels; the factory test holds the snapshot delete open and publishes the replacement mid-flight)testDeleteRemovesCursorPropertyThroughAtomicConditionalUpdate(the bucket delete path applies the conditionalupdateCursorPropertiesclosure; red against a two-step check-then-remove)testSaveFailsWhenCursorPublicationFails(publication failure fails the save, the property keeps the old value, the superseded ledger was pre-deleted, the replacement was allocated exactly once and reclaimed)testSaveRetriesReclaimOfUnpublishedLedger(a transient reclaim failure is retried and the ledger reclaimed; red against a single-shot reclaim)testFailedSaveKeepsUnpublishedLedgerReclaimableByClear(retries exhausted → the bucket stays reclaimable throughuncleanedBuckets, andclear()deletes the ledger once deletes recover)testSuccessfulReclaimDoesNotQueueBucketForClearRetry(a successful immediate reclaim drops the cached id;clear()makes no further delete attempt)testMergeAbortsWhenBucketAppearsInTheGap(a bucket sealed into a ledger gap during the merge reads is not displaced; waits for the trim/merge chain viagetTrimFuture()and asserts the enclosing[1,20]is not installed)testCleanResidualSnapshotsAccountsMalformedBucketIdInFuture(regression lock: a malformed bucket id fails the cleanup future, entries scheduled before it are still cleaned)Does this pull request potentially affect one of the following parts:
Check the boxes that apply
Documentation
docYour PR title contains the doc impact labeldoc-requiredYour PR changes the docsdoc-not-neededDocs are not requireddoc-completeDocs have been already added