-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-28675 Fix flaky TxDeadlockCauseTest #testCause, #testCauseSeveralNodes #13136
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
Open
zstan
wants to merge
7
commits into
apache:master
Choose a base branch
from
zstan:ignite-28675
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
94b11ec
IGNITE-28675 Fix flaky TxDeadlockCauseTest#testCause
zstan f764e52
fix final change through reflection
zstan c4d175a
fix testCauseSeveralNodes
zstan d57f6c3
style fix
zstan 2fd5bb3
test enhacement
zstan 41500b0
fix after review
zstan 0a8be5a
fix after review 2
zstan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ | |
| import java.util.concurrent.atomic.AtomicReference; | ||
| import org.apache.ignite.Ignite; | ||
| import org.apache.ignite.IgniteCache; | ||
| import org.apache.ignite.IgniteCheckedException; | ||
| import org.apache.ignite.cache.CacheAtomicityMode; | ||
| import org.apache.ignite.configuration.CacheConfiguration; | ||
| import org.apache.ignite.configuration.DataRegionConfiguration; | ||
|
|
@@ -165,6 +164,9 @@ private void checkCauseObject( | |
| final TransactionIsolation isolation, | ||
| final boolean oneOp | ||
| ) throws Exception { | ||
| if (nodes > 1) | ||
| awaitPartitionMapExchange(); | ||
|
|
||
| final Ignite ignite = grid(new Random().nextInt(nodes)); | ||
|
|
||
| final IgniteCache<Integer, Account> cache = ignite.cache(DEFAULT_CACHE_NAME); | ||
|
|
@@ -183,7 +185,7 @@ private void checkCauseObject( | |
| final CyclicBarrier barrier = new CyclicBarrier(2); | ||
|
|
||
| IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new CAX() { | ||
| @Override public void applyx() throws IgniteCheckedException { | ||
| @Override public void applyx() { | ||
| try (Transaction tx = ignite.transactions().txStart(TransactionConcurrency.PESSIMISTIC, isolation, | ||
| timeout, keys.size())) { | ||
|
|
||
|
|
@@ -204,7 +206,9 @@ private void checkCauseObject( | |
| tx.commit(); | ||
| } | ||
| catch (Exception e) { | ||
| ex.compareAndSet(null, e); | ||
| // TransactionDeadlockException raised at least for one transaction involved in the deadlock | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is from our own documentation |
||
| if (X.hasCause(e, TransactionDeadlockException.class)) | ||
| ex.compareAndSet(null, e); | ||
| } | ||
| } | ||
| }, 2, "tx"); | ||
|
|
@@ -268,7 +272,7 @@ static class Account implements Serializable { | |
| /** | ||
| * Change balance by specified amount. | ||
| * | ||
| * @param amount Amount to add to balance (may be negative). | ||
| * @param amount Amount to add to balance (maybe negative). | ||
| */ | ||
| void update(double amount) { | ||
| balance += amount; | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's roll back adding the
finalqualifier here, because it changes the semantics ofTxDeadlockDetectionNoHangsTestand is not the main goal of this patch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and roll back renaming too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disagree, why do we need to support non-final definition only for test cases ?
test work properly well without this reflection changes, i run it multiple times, you can check it through TC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My position is not really about final/non-final definition itself. My point is that it is usually safer to keep PRs as minimal as possible for a specific purpose. The main goal here is to fix
TxDeadlockCauseTest, and for now it is not very clear why we also need to refactor an unrelated field and affect existing test behavior.Green TC runs are definitely a good sign, but some flaky tests fail once in weeks or even months. That's why I'd prefer to avoid introducing additional assumptions here unless this change is really required for the fix itself.
Could you provide more reasoning on why it is safe to remove before/afterTests from
TxDeadlockDetectionNoHangsTest?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appent additional checks into test, plz check last commit
Also, tests restore after for hardcoded - 60000, that equal to current default but can be changed in future thus there can be a situation when test restores not a default.