Skip to content

Commit 352b981

Browse files
Fix race in schema migration tests (#7766)
Some of the schema migration tests test the recovery of subscriptions and objects after a schema migration. This requires that the subscriptions and objects are committed when the synchronization session is paused so nothing is uploaded. `SyncSession::pause()` is used for this, but pause is an async operation so there is a race between pausing the session and uploading the data and subscriptions. `SyncSession::shutdown_and_wait()` is used instead.
1 parent 2e966fb commit 352b981

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/object-store/sync/flx_schema_migration.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ TEST_CASE("Upgrade schema version (with recovery) then downgrade", "[sync][flx][
498498
wait_for_upload(*realm);
499499
check_realm_schema(config.path, schema_v0, 0);
500500

501-
realm->sync_session()->pause();
501+
realm->sync_session()->shutdown_and_wait();
502502

503503
// Subscription to recover when upgrading the schema.
504504
auto subs = realm->get_latest_subscription_set().make_mutable_copy();
@@ -771,7 +771,7 @@ TEST_CASE("Client reset during schema migration", "[sync][flx][flx schema migrat
771771
wait_for_upload(*realm);
772772
check_realm_schema(config.path, schema_v0, 0);
773773

774-
realm->sync_session()->pause();
774+
realm->sync_session()->shutdown_and_wait();
775775

776776
realm->begin_transaction();
777777
CppContext c(realm);
@@ -862,7 +862,7 @@ TEST_CASE("Migrate to new schema version after migration to intermediate version
862862
wait_for_upload(*realm);
863863
check_realm_schema(config.path, schema_v0, 0);
864864

865-
realm->sync_session()->pause();
865+
realm->sync_session()->shutdown_and_wait();
866866

867867
realm->begin_transaction();
868868
CppContext c(realm);
@@ -1011,7 +1011,7 @@ TEST_CASE("Client reset and schema migration", "[sync][flx][flx schema migration
10111011
wait_for_upload(*realm);
10121012
check_realm_schema(config.path, schema_v0, 0);
10131013

1014-
realm->sync_session()->pause();
1014+
realm->sync_session()->shutdown_and_wait();
10151015

10161016
realm->begin_transaction();
10171017
CppContext c(realm);
@@ -1088,7 +1088,7 @@ TEST_CASE("Multiple async open tasks trigger a schema migration", "[sync][flx][f
10881088
wait_for_upload(*realm);
10891089
check_realm_schema(config.path, schema_v0, 0);
10901090

1091-
realm->sync_session()->pause();
1091+
realm->sync_session()->shutdown_and_wait();
10921092

10931093
// Subscription to recover when upgrading the schema.
10941094
auto subs = realm->get_latest_subscription_set().make_mutable_copy();
@@ -1181,7 +1181,7 @@ TEST_CASE("Upgrade schema version with no subscription initializer", "[sync][flx
11811181
wait_for_upload(*realm);
11821182
check_realm_schema(config.path, schema_v0, 0);
11831183

1184-
realm->sync_session()->pause();
1184+
realm->sync_session()->shutdown_and_wait();
11851185

11861186
// Object to recover when upgrading the schema.
11871187
realm->begin_transaction();

0 commit comments

Comments
 (0)