Skip to content

Commit

Permalink
Fix race conditions in thin_replica_server_test.
Browse files Browse the repository at this point in the history
This commit is intended to fix a couple race conditions previously
observed in the thin_replica_server_test unit test suite in cases with
names of the form SubscribeTo*EventGroup*WithGapTwoClients. The root
cause of these race conditions was determined to be that these cases
make calls to the test suite's addMoreEventGroups helper function in
such a way that the addition of these event groups races with the
TestStateMachine helper object's logic for detecting that all event
group updates of interest to the test case have been streamed in order
to end the subscription.

This commit makes a couple changes to prevent the TestStateMachine from
incorrectly detecting the end of a subscription that may be running
concurrently with addMoreEventGroups calls. First, addMoreEventGroups's
existing behavior included alerting the TestStateMachine that there are
no more event groups to add with a call to
TestStateMachine::toggle_more_event_groups_to_add(false). This commit
adds a new optional bool parameter
even_more_event_groups_to_add_after_these to addMoreEventGroups in order
to allow test cases to avoid incorrectly notifying the TestStateMachine
that there are no more event groups to add in cases where the test case
will be making further calls to addMoreEventGroups after the current
one. Second, this commit shifts the responsibility for calling
TestStateMachine::set_expected_last_event_group_to_send from
addMoreEventGroups to the actual test cases that call it so that the
expected last event group to be sent can be correctly set strictly
before the Thin Replica subscription begins running in order to avoid
races between the final expected event group ID getting set correctly
and the TestStateMachine checking updates the ThinReplicaImpl writes
against this value.

Additionally, this commit reactivates the affected test cases, as they
were previously deactivated to avoid blocking other changes to improve
Concord-BFT's and its CI's stability.
  • Loading branch information
upshaw-alex committed Jun 18, 2022
1 parent 60e1b8a commit 7542620
Showing 1 changed file with 133 additions and 60 deletions.
Loading

0 comments on commit 7542620

Please sign in to comment.