Skip to content

Wake Queue#pop(timeout:) waiters when the queue is closed - #9791

Merged
headius merged 1 commit into
jruby:masterfrom
sampokuokkanen:queue-close-wakes-timed-pop
Oct 15, 2026
Merged

headius merged 1 commit into
jruby:masterfrom
sampokuokkanen:queue-close-wakes-timed-pop

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

The timed poll loop only checked the item count, so the signal from closeInternal woke the waiter, it found the queue still empty, and went back to awaitNanos until the full timeout passed. A closed, empty queue now returns nil at once and passes the wakeup on to the next consumer, as takeInternal already does for the untimed pop.

Run into this while trying to run ONCE Campfire: https://github.com/basecamp/once-campfire/blob/05c5a2c0d72f7fd74d7c2ace23cc123000f956b9/lib/rails_ext/sqlite_wal_checkpoint.rb#L41-L49 and hit the "SQLite WAL checkpointer did not stop within #{timeout}s" error.

The timed poll loop only checked the item count, so the signal from
closeInternal woke the waiter, it found the queue still empty, and went
back to awaitNanos until the full timeout passed. A closed, empty queue
now returns nil at once and passes the wakeup on to the next consumer,
as takeInternal already does for the untimed pop.

@headius headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@headius headius added this to the JRuby 10.1.3.0 milestone Oct 15, 2026
@headius
headius merged commit 2e0024a into jruby:master Oct 15, 2026
135 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