Conversation
…tests Deadlock detection in TransactionIndex.wwDependency is distributed: every waiter links its dependency and then checks for a cycle, with no victim selection. When both lockers of a two-way deadlock link their edges before either checks, both see the cycle and both roll back, so the assertion "exactly one committed" fails (seen on ubuntu-latest JDK 17). The same race applies to multiWayDeadlock. Assert the invariants that do hold instead: at most one locker commits, and every locker that did not commit was rolled back with a RollbackException. Include elapsed time, commit flags and exceptions in the assertion messages so a future failure is diagnosable. Fixes OpenIdentityPlatform#313
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
ExchangeLockTest.deadlockis flaky on CI (#313): it fails onassertTrue(a._committed ^ b._committed).Deadlock detection in
TransactionIndex.wwDependencyis distributed. Each waiter callssource.setDepends(target)and thenisDeadlocked(source), and no victim is selected. If both lockers of a two-way deadlock link their edges before either one checks, both see the cycle, both getUNCOMMITTED, and both roll back. The deadlock is still resolved, but with two victims instead of one, so "exactly one committed" does not hold.multiWayDeadlockhas the same race:assertEquals(1, succeeded)can see0.This is the same mechanism that #256 fixed test-side for
TransactionIndexTest.testDeadlockedWwDependency.Changes
deadlock: assert that at most one locker commits, instead of exactly one.multiWayDeadlock: assertsucceeded <= 1instead of== 1.RollbackException, so an unrelated failure is still caught.Locker._exceptionis nowvolatile, consistent with the other shared fields.No product code is changed. A deterministic victim choice in
wwDependencywould change library behavior and is not needed for correctness.Testing
mvn -pl persistit/core test -Dtest=ExchangeLockTest(JDK 17): 8 tests, 0 failures.deadlockandmultiWayDeadlockin one JVM: 0 failures. The race did not reproduce locally, so this run only shows that the tests do not regress.Fixes #313