Skip to content

Fix collect on caches that other tasks modify - #10

Merged
lkdvos merged 1 commit into
mainfrom
collect-fix
Oct 2, 2026
Merged

lkdvos merged 1 commit into
mainfrom
collect-fix

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 2, 2026

Copy link
Copy Markdown
Member

collect(c) sized its result from length(c) and then iterated a snapshot taken separately under the lock. When another task inserted, evicted or emptied in between, collect threw an ArgumentError. With 2 threads it threw 207 times in 20,000 calls on a ClockCache. Caches now report Base.SizeUnknown(), so collect follows the snapshot.

The new test collects while another task writes. It fails without the fix and passes with it, for every container.

Found while investigating lock-free hits (#9).

🤖 Generated with Claude Code

`collect` sized its result from `length(c)` and then iterated a snapshot
taken separately, so it threw when another task changed the cache in
between. Caches now report an unknown iterator size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lkdvos
lkdvos merged commit 064a94a into main Oct 2, 2026
10 checks passed
@lkdvos
lkdvos deleted the collect-fix branch October 2, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant