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
Resolves a deadlock scenario applying constraint #9110
Resolves a deadlock scenario applying constraint #9110
Conversation
The scenario, which takes place on database instance applying constraint creation as an external transaction, looks like this: - Transaction T1 creates the constraint index and population P starts - Transaction T2 which activates the constraint starts applying and now has a read lock on the counts store - Check point triggers, wants to rotate counts store and so acquires its write lock. It will have to block, but doing so will also blocks further read lock requests - T2 moves on to activate the constraint. Doing so means first waiting for the index to come online - P moves on to flip after population, something which includes initializing some sample data in counts store for this index. Will block on the counts store read lock, completing the deadlock The solution in this commit breaks the deadlock by having T2 unlock its read lock on the counts store before activating the constraint, i.e. as soon as it notices that it is a schema transaction. Schema transactions will not update the counts store anyway.
cab592c
to
4ebfb55
Compare
public final OtherThreadRule<Void> t3 = new OtherThreadRule<>( "T3" ); | ||
|
||
@Test | ||
public void shouldNotDeadlock() throws Exception |
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.
we need to add a timeout to this test just in case it will hang
|
||
@Test | ||
public void shouldNotDeadlock() throws Exception | ||
{ |
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.
also we need to add a bit of assertions to the test, now we do not have any
@@ -68,4 +74,15 @@ public boolean visitRelationshipCountsCommand( Command.RelationshipCountsCommand | |||
} | |||
return false; | |||
} | |||
|
|||
@Override | |||
public boolean visitSchemaRuleCommand( SchemaRuleCommand command ) throws IOException |
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.
also as we just talk, would be nice to have guarding assertion that will fail in case when this assumption will brake
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.
Yup, this has been added
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.
couple of comments, otherwise we can give it a try
ping @tinwelint |
@MishaDemianenko updated |
The scenario, which takes place on database instance applying constraint
creation as an external transaction, looks like this:
and now has a read lock on the counts store
its write lock. It will have to block, but doing so will also blocks
further read lock requests
the index to come online
some sample data in counts store for this index. Will block on the counts
store read lock, completing the deadlock
The solution in this commit breaks the deadlock by having T2 unlock its
read lock on the counts store before activating the constraint, i.e.
as soon as it notices that it is a schema transaction. Schema transactions
will not update the counts store anyway.