Skip to content

Fix in_bulk leaking thread local on exception - #25

Merged
svanhesteren merged 2 commits into
cheddar-me:mainfrom
julik:bulk-enqueue-fix
Feb 13, 2026
Merged

Fix in_bulk leaking thread local on exception#25
svanhesteren merged 2 commits into
cheddar-me:mainfrom
julik:bulk-enqueue-fix

Conversation

@julik

@julik julik commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

If the block passed to Gouda.in_bulk raised, the Thread.current[:gouda_bulk_buffer] was never reset to nil, causing all subsequent perform_later calls to silently buffer into a stale array and never actually enqueue. This could lead to jobs silently disappearing without enqueue and this would stay sticky inside the thread until another in_bulk call would be made.

Wrap the outermost call in an ensure block to guarantee cleanup.

If the block passed to Gouda.in_bulk raised, the
Thread.current[:gouda_bulk_buffer] was never reset to nil, causing all
subsequent perform_later calls to silently buffer into a stale array
and never actually enqueue.

Wrap the outermost call in an ensure block to guarantee cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@julik

julik commented Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

@jujustayfly @svanhesteren please do merge this, it's pretty serious

@svanhesteren

Copy link
Copy Markdown
Contributor

Good point. Thanks for noticing!

@svanhesteren
svanhesteren merged commit a849d14 into cheddar-me:main Feb 13, 2026
3 checks passed
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.

2 participants