-
Notifications
You must be signed in to change notification settings - Fork 171
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 3 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,44 @@ 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. |
||
bool should_send_upload = true; | ||
|
||
SyncTestFile config(harness.app()->current_user(), harness.schema(), SyncConfig::FLXSyncEnabled{}); | ||
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. you can do |
||
config.sync_config->on_sync_client_event_hook = [&](std::weak_ptr<SyncSession> weak_session, | ||
const SyncClientHookData& data) { | ||
if (data.query_version == 0) { | ||
return SyncClientHookAction::NoAction; | ||
} | ||
auto session = weak_session.lock(); | ||
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 actually use the session here anywhere? 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. no. i'll remove it. |
||
if (!session) { | ||
return SyncClientHookAction::NoAction; | ||
} | ||
// Check no upload messages are sent during bootstrap. | ||
if (data.event == SyncClientHookEvent::BootstrapMessageProcessed) { | ||
should_send_upload = false; | ||
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 want to check that we actually hit these cases in the test somehow? 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 could add a state machine (considered that actually) |
||
} | ||
else if (data.event == SyncClientHookEvent::DownloadMessageIntegrated && | ||
data.batch_state == sync::DownloadBatchState::LastInBatch) { | ||
should_send_upload = true; | ||
} | ||
else if (data.event == SyncClientHookEvent::UploadMessageSent) { | ||
CHECK(should_send_upload); | ||
} | ||
|
||
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)); | ||
auto subs = new_subs.commit(); | ||
subs.get_state_change_notification(sync::SubscriptionSet::State::Complete).get(); | ||
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. should we add something here where we do a write in the DB that can't result in an upload - like say writing to a table not prefixed by 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. great suggestion. |
||
} | ||
|
||
} // 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.