-
Notifications
You must be signed in to change notification settings - Fork 172
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
RCORE-2129 Do not send empty upload messages if there are no downloads to ack #7859
Changes from 6 commits
b71ce67
f6a363d
3732aef
448bd53
d344642
d048425
5224176
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5023,6 +5023,53 @@ TEST_CASE("flx: nested collections in mixed", "[sync][flx][baas]") { | |
CHECK(nested_list.get_any(1) == "foo"); | ||
} | ||
|
||
TEST_CASE("flx: no upload during bootstraps", "[sync][flx][bootstrap][baas]") { | ||
FLXSyncTestHarness harness("flx_bootstrap_no_upload", {g_large_array_schema, {"queryable_int_field"}}); | ||
fill_large_array_schema(harness); | ||
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. do we need to use the large array schema here with tons of data to upload/download? 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. I think in a single download message bootstrap the data is applied immediately before the client gets the chance to send an upload (and after the bootstrap is done there is a server version to ack so the upload is legit). but I can check. |
||
auto config = harness.make_test_file(); | ||
enum class TestState { Start, BootstrapInProgress, BootstrapProcessed, BootstrapAck }; | ||
TestingStateMachine<TestState> state(TestState::Start); | ||
config.sync_config->on_sync_client_event_hook = [&](std::weak_ptr<SyncSession>, const SyncClientHookData& data) { | ||
if (data.query_version == 0) { | ||
return SyncClientHookAction::NoAction; | ||
} | ||
state.transition_with([&](TestState cur_state) -> std::optional<TestState> { | ||
// Check no upload messages are sent during bootstrap. | ||
if (data.event == SyncClientHookEvent::BootstrapMessageProcessed) { | ||
CHECK((cur_state == TestState::Start || cur_state == TestState::BootstrapInProgress)); | ||
return TestState::BootstrapInProgress; | ||
} | ||
else if (data.event == SyncClientHookEvent::DownloadMessageIntegrated && | ||
data.batch_state == sync::DownloadBatchState::LastInBatch) { | ||
CHECK(cur_state == TestState::BootstrapInProgress); | ||
return TestState::BootstrapProcessed; | ||
} | ||
else if (data.event == SyncClientHookEvent::UploadMessageSent) { | ||
// Uploads are allowed before a bootstrap starts. | ||
if (cur_state == TestState::Start) { | ||
return std::nullopt; // Don't transition | ||
} | ||
CHECK(cur_state == TestState::BootstrapProcessed); | ||
return TestState::BootstrapAck; | ||
} | ||
return std::nullopt; | ||
}); | ||
return SyncClientHookAction::NoAction; | ||
}; | ||
|
||
auto realm = Realm::get_shared_realm(config); | ||
auto table = realm->read_group().get_table("class_TopLevel"); | ||
auto new_subs = realm->get_latest_subscription_set().make_mutable_copy(); | ||
new_subs.insert_or_assign(Query(table)); | ||
new_subs.commit(); | ||
state.wait_for(TestState::BootstrapAck); | ||
|
||
// Commiting an empty changeset does not upload a message. | ||
realm->begin_transaction(); | ||
realm->commit_transaction(); | ||
wait_for_upload(*realm); | ||
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. How would this fail without your changes, would it hang? 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. it would send an upload message. But a recent change made wait_for_upload return immediately if all remaining changesets to upload are empty, so it may not give the client the chance to send the upload (and hence not fail without the change). |
||
} | ||
|
||
} // namespace realm::app | ||
|
||
#endif // REALM_ENABLE_AUTH_TESTS |
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.
Is this a correctness issue or a performance improvement? I don't think it is clear to someone just reading this line what the impact was.
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.
It's a performance improvement. It saves roundtrips to the server. But it's a bug fix since we introduced it in 14.8.0. I'll reword it.