Skip to content

Stabilize flaky JournalManagerTest.missingVolumePageHandling#261

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/journalmanager-flaky-missingvolume
Open

Stabilize flaky JournalManagerTest.missingVolumePageHandling#261
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/journalmanager-flaky-missingvolume

Conversation

@vharseko

Copy link
Copy Markdown
Member

Problem

JournalManagerTest.missingVolumePageHandling is flaky. It creates two volumes, writes non-transactional data, closes, deletes the volume files, restarts, and immediately asserts that startup generated missing-volume alerts:

_persistit = new Persistit(_config);
final AlertMonitor am = _persistit.getAlertMonitor();
assertTrue("Startup with missing volumes should have generated alerts",
        am.getHistory(AlertMonitor.MISSING_VOLUME_CATEGORY) != null);

The MISSING_VOLUME alert is posted by JournalManager.writeForCopy when the journal copier copies a page back to a now-deleted volume (VolumeNotFoundException). For the non-transactional pages this test writes, that copy-back is not part of the synchronous recovery in initialize() — it runs on the background JOURNAL_COPIER thread. So the assertion immediately after new Persistit(_config) races the copier: on a slow/loaded runner no alert has been posted yet and getHistory(...) returns null:

java.lang.AssertionError: Startup with missing volumes should have generated alerts
    at com.persistit.JournalManagerTest.missingVolumePageHandling(JournalManagerTest.java:481)

Observed on build-maven (macos-latest, 26); passes on the other 9 build jobs in the same run. (The sibling missingVolumeTransactionHandling* tests are not affected — their alert comes from synchronous transaction replay during recovery, not the background copier.)

Fix

Force the copy-back with copyBackPages() before the assertion, so the alert is generated deterministically instead of relying on the background copier having already run. ignoreMissingVolumes is still false at that point, so writeForCopy retains the missing-volume pages (it only drops them once ignore is set); the later ignoreMissingVolumes-behavior check (alertCount1 == alertCount2) is therefore unaffected.

Not caused by this PR's parent change

Unrelated to the PR it was blocking (#236, remove useless null checks): its only persistit change is in Persistit.crash() (dropping proven-non-null checks), not the startup/alert path.

Verification

  • missingVolumePageHandling 6/6 green (including the ignoreMissingVolumes count check, confirming the pages are retained).
  • Full JournalManagerTest class: 13/13.
  • Root cause is precisely identified (alert originates in background copy-back, not synchronous recovery), so this is a deterministic fix rather than a best-effort one.

The missing-volume alert asserted after startup is posted by
JournalManager.writeForCopy when the journal copier copies a page back to a
now-deleted volume. For the non-transactional pages this test writes, that copy
runs on the background JOURNAL_COPIER thread, so the assertion immediately after
new Persistit(_config) races it: on a slow/loaded runner no alert has been
posted yet and getHistory(MISSING_VOLUME_CATEGORY) returns null ("Startup with
missing volumes should have generated alerts", seen on macos-latest JDK 26).

Force the copy-back with copyBackPages() before the assertion so the alert is
generated deterministically. ignoreMissingVolumes is still false at that point,
so the missing-volume pages are retained and the later
ignoreMissingVolumes-behavior check is unaffected.
@vharseko vharseko requested a review from maximthomas July 10, 2026 06:58
@vharseko vharseko added the tests Test code changes label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants