Use notifyAll in IOTaskRunnable.kick (CodeQL java/notify-instead-of-notify-all)#243
Open
vharseko wants to merge 3 commits into
Open
Use notifyAll in IOTaskRunnable.kick (CodeQL java/notify-instead-of-notify-all)#243vharseko wants to merge 3 commits into
vharseko wants to merge 3 commits into
Conversation
…otify-all) kick() woke a waiter with notify(). Today there is only ever a single waiter - the one background thread per IOTaskRunnable that blocks in run()'s wait() - so notify() and notifyAll() are equivalent, but notify() is fragile: if another thread ever waited on the same monitor, notify() could wake the wrong one. Switch to notifyAll(). It wakes the same single waiter now (no thundering herd), and the wait loop already re-checks its conditions (shouldStop / _notified / recomputed wait time), so any extra wake-ups are handled safely.
maximthomas
approved these changes
Jul 9, 2026
…order WarmupTest.testWarmup asserted that after a bufferinventory+bufferpreload restart every buffer slot holds the same page as before shutdown (getBufferCopy(i) before == getBufferCopy(i) after). That is not what warmup guarantees: preloadBufferInventory() sorts the recorded pages by read order (PageNode.READ_COMPARATOR) and reallocates buffers via the clock algorithm, so a page is reloaded into the pool but not necessarily into its original slot. The per-slot check only happened to pass when the allocation order coincided, and flaked on ubuntu-latest / JDK 17 (expected:<0> but was:<2> - an empty slot where the original held page 2) while passing on JDK 11/21/25/26. Assert the real invariant instead: every valid, recordable page (skipping temporary and lock volumes, matching recordBufferInventory) resident at shutdown is resident again after warmup, comparing the set of pages rather than their slot positions. A genuine failure to preload a page is still caught.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the
java/notify-instead-of-notify-allalert inIOTaskRunnable.kick()woke a blocked worker withnotify():Each
IOTaskRunnablehas exactly one background thread (created instart()),and that thread is the only one that ever calls
wait()on the monitor (inrun()), sonotify()andnotifyAll()are functionally equivalent today.However,
notify()is fragile — if any other thread ever waited on the samemonitor, it could wake the wrong one and leave the worker blocked.
Fix
Use
notifyAll(). With a single waiter it wakes exactly the same thread (nothundering herd), and the wait loop already re-checks its guards
(
shouldStop()/_notified/ recomputed wait time), so additional wake-ups arehandled correctly.
Testing
mvn -o -pl persistit/core compile— BUILD SUCCESS.