Skip to content

[#358] TransactionAbandonedTest: read and write in the abandoned transaction - #366

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issue-358-txn-abandoned-test-flags
Oct 18, 2026
Merged

vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:issue-358-txn-abandoned-test-flags

Conversation

@vharseko

Copy link
Copy Markdown
Member

Problem

TransactionAbandonedTest.runAndCleanup(name, doRead, doWrite) ignored its flags and always started new TxnAbandoner(_persistit, false, false). So readOnly and readAndWrite ran the noReadsOrWrites scenario, and their assertions held whatever Persistit.cleanup() did with the abandoned transaction.

With the flags passed through, readAndWrite fails with Raw traversed after abandoned expected:<10> but was:<20>. A rolled back transaction is pruned by JournalManager.pruneObsoleteTransactions(), which replays it with ProactiveRollbackListener, not through the CleanupManager queue that the test ran. CleanupManager.poll() calls that method at most once every two seconds, and the test reaches the raw scan well before that.

Change

  • runAndCleanup() passes doRead and doWrite to TxnAbandoner.
  • After joining the thread and before cleanup(), while the abandoned transaction is still open, runAndCleanup() checks the raw key count: 2 * KEY_RANGE when the transaction wrote, KEY_RANGE otherwise. Nothing can prune the versions of a transaction that has not ended, so the check does not depend on when the product prunes, and it fails if the flags stop reaching the abandoned transaction.
  • readAndWrite prunes with pruneObsoleteTransactions(true) before the raw scan. The CleanupManager loop is removed: its queue is empty at that point (Buffer.enqueuePruningAction has no caller), so the loop never ran.

Testing (JDK 11, macOS)

  • TransactionAbandonedTest: all 3 tests pass, 15 consecutive runs green.
  • With the flags ignored again (false, false): Raw traversed before cleanup expected:<20> but was:<10>.
  • Without the pruneObsoleteTransactions(true) call: Raw traversed after abandoned expected:<10> but was:<20>.

Fixes #358

…n the abandoned transaction

runAndCleanup() passes doRead and doWrite to TxnAbandoner, so readOnly and
readAndWrite no longer run the noReadsOrWrites scenario, and checks the raw
key count while the abandoned transaction is still open. readAndWrite prunes
the rolled back transaction with JournalManager.pruneObsoleteTransactions()
instead of running the CleanupManager queue, which never holds it, and then
checks that only the committed keys remain.

Fixes OpenIdentityPlatform#358
@vharseko vharseko added tests Test code changes java Pull requests that update java code labels Oct 17, 2026
@vharseko
vharseko requested a review from maximthomas October 17, 2026 13:56

@maximthomas maximthomas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

praise: The flags now reach the abandoned transaction, and the assertions finally depend on what cleanup() does.

  • runAndCleanup() passes doRead/doWrite to TxnAbandoner (TransactionAbandonedTest.java:110); with that, deleting _persistit.cleanup() turns readAndWrite red (Raw traversed after abandoned expected:<10> but was:<20>).
  • The raw count before cleanup() (:112-113) is taken while the transaction is still open, so it cannot depend on prune timing.
  • pruneObsoleteTransactions(true) (:136) replaces a CleanupManager loop that never ran, and the class stayed green 50/50 on JDK 11 and on all 9 CI rows.

@vharseko
vharseko merged commit e262ca9 into OpenIdentityPlatform:master Oct 18, 2026
14 checks passed
@vharseko
vharseko deleted the issue-358-txn-abandoned-test-flags branch October 18, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update java code tests Test code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TransactionAbandonedTest: readOnly and readAndWrite never read or write in the abandoned transaction

2 participants