-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][test] Avoid spying an instance that contains volatile fields in ManagedLedgerTest.testLockReleaseWhenTrimLedger() test to avoid flaky test #25144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
I occasionally found I was every confused since pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/ReadEntryUtils.java Lines 39 to 51 in 1fcdf8b
The pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java Lines 369 to 396 in 1fcdf8b
The only inconsistent cause in code is here, we returns old Lines 87 to 102 in 1fcdf8b
I searched all the call chains to this method, and came out to a reason: there should be exactly one invocation of the Finally, I found that the root cause of the issue was the interaction between the spy and volatile fields. I'll explain in the following comments. |







Motivation
Fix
ManagedLedgerTest.testLockReleaseWhenTrimLedger()flaky test.This test has the following problems:
assertEquals(ledger.ledgers.size() - 1, entries)orassertEquals(ledger.ledgerCache.size() - 1, entries - 1)may be flaky, see code comments.Modifications
Verifying this change
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: oneby-wang#24