Skip to content

Commit 8986465

Browse files
evanlinjinclaude
andcommitted
fix(core): update checkpoint_does_not_leak test for skip pointers
Skip pointers at index 100+ create additional Arc references to earlier checkpoints. The test now expects 3 strong refs to genesis instead of 2. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e1f2ff4 commit 8986465

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

crates/core/src/checkpoint.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ where
360360
let skip = if needs_skip_pointer {
361361
// Skip pointer points back CHECKPOINT_SKIP_INTERVAL positions
362362
// e.g., checkpoint at index 200 points to checkpoint at index 100
363-
// We walk back CHECKPOINT_SKIP_INTERVAL - 1 steps since we start from self (index new_index - 1)
363+
// We walk back CHECKPOINT_SKIP_INTERVAL - 1 steps since we start from self (index
364+
// new_index - 1)
364365
let mut current = self.0.clone();
365366
for _ in 0..(CHECKPOINT_SKIP_INTERVAL - 1) {
366367
// This is safe: if we're at index >= 100, we must have at least 99 predecessors
@@ -448,12 +449,15 @@ mod tests {
448449
let genesis = cp.get(0).expect("genesis exists");
449450
let weak = Arc::downgrade(&genesis.0);
450451

451-
// At this point there should be exactly two strong references to the
452-
// genesis checkpoint: the variable `genesis` and the chain `cp`.
452+
// At this point there should be exactly three strong references to the
453+
// genesis checkpoint:
454+
// 1. The variable `genesis`
455+
// 2. The chain `cp` through checkpoint 1's prev pointer
456+
// 3. Checkpoint at index 100's skip pointer (points to index 0)
453457
assert_eq!(
454458
Arc::strong_count(&genesis.0),
455-
2,
456-
"`cp` and `genesis` should be the only strong references",
459+
3,
460+
"`cp`, `genesis`, and checkpoint 100's skip pointer should be the only strong references",
457461
);
458462

459463
// Dropping the chain should remove one strong reference.

0 commit comments

Comments
 (0)