-
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
Wait for MARK message to mark a SubscriptionSet as Complete #5795
Changes from 12 commits
f18c87a
9b8768d
7a537eb
39a5181
66f0e3e
244ec8b
9ce02a6
1f765a8
f1a3549
eea8257
d6238d3
704a102
d95f001
3cc9a78
1197d03
38dbf38
ea5a07c
e8ccb4c
9d91042
93e872c
30523f6
32ad0aa
95fa856
a0bcc33
550d81c
684e596
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 |
---|---|---|
|
@@ -11,7 +11,6 @@ | |
} | ||
}, | ||
"sync": { | ||
"brokerRegistryCacheTTL": "0s", | ||
"allowSyncSessionTestCommands": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,6 +252,7 @@ class SessionWrapper final : public util::AtomicRefCountBase, public SyncTransac | |
int64_t m_flx_active_version = 0; | ||
int64_t m_flx_last_seen_version = 0; | ||
int64_t m_flx_latest_version = 0; | ||
int64_t m_flx_pending_mark_version = 0; | ||
std::unique_ptr<PendingBootstrapStore> m_flx_pending_bootstrap_store; | ||
|
||
bool m_initiated = false; | ||
|
@@ -785,6 +786,7 @@ void SessionImpl::process_pending_flx_bootstrap() | |
VersionInfo new_version; | ||
SyncProgress progress; | ||
int64_t query_version = -1; | ||
size_t changesets_processed = 0; | ||
while (bootstrap_store->has_pending()) { | ||
auto pending_batch = bootstrap_store->peek_pending(batch_size_in_bytes); | ||
if (!pending_batch.progress) { | ||
|
@@ -803,7 +805,6 @@ void SessionImpl::process_pending_flx_bootstrap() | |
throw IntegrationException(ClientError::bad_changeset, "simulated failure"); | ||
} | ||
|
||
|
||
history.integrate_server_changesets( | ||
*pending_batch.progress, &downloadable_bytes, pending_batch.changesets, new_version, batch_state, logger, | ||
[&](const TransactionRef& tr, size_t count) { | ||
|
@@ -812,9 +813,7 @@ void SessionImpl::process_pending_flx_bootstrap() | |
}, | ||
get_transact_reporter()); | ||
progress = *pending_batch.progress; | ||
|
||
REALM_ASSERT(call_debug_hook(SyncClientHookEvent::DownloadMessageIntegrated, progress, query_version, | ||
batch_state, pending_batch.changesets.size()) == SyncClientHookAction::NoAction); | ||
changesets_processed += pending_batch.changesets.size(); | ||
|
||
logger.info("Integrated %1 changesets from pending bootstrap for query version %2, producing client version " | ||
"%3. %4 changesets remaining in bootstrap", | ||
|
@@ -826,6 +825,10 @@ void SessionImpl::process_pending_flx_bootstrap() | |
REALM_ASSERT_3(query_version, !=, -1); | ||
m_wrapper.on_sync_progress(); | ||
on_flx_sync_progress(query_version, DownloadBatchState::LastInBatch); | ||
|
||
auto action = call_debug_hook(SyncClientHookEvent::BootstrapProcessed, progress, query_version, | ||
DownloadBatchState::LastInBatch, changesets_processed); | ||
REALM_ASSERT(action == SyncClientHookAction::NoAction); | ||
} | ||
|
||
void SessionImpl::on_new_flx_subscription_set(int64_t new_version) | ||
|
@@ -950,8 +953,10 @@ SessionWrapper::SessionWrapper(ClientImpl& client, DBRef db, std::shared_ptr<Sub | |
REALM_ASSERT(dynamic_cast<ClientReplication*>(m_db->get_replication())); | ||
|
||
if (m_flx_subscription_store) { | ||
std::tie(m_flx_active_version, m_flx_latest_version) = | ||
m_flx_subscription_store->get_active_and_latest_versions(); | ||
auto versions_info = m_flx_subscription_store->get_active_and_latest_versions(); | ||
m_flx_active_version = versions_info.active; | ||
m_flx_latest_version = versions_info.latest; | ||
m_flx_pending_mark_version = versions_info.pending_mark; | ||
} | ||
} | ||
|
||
|
@@ -1032,7 +1037,13 @@ void SessionWrapper::on_flx_sync_progress(int64_t new_version, DownloadBatchStat | |
return; | ||
} | ||
on_flx_sync_version_complete(new_version); | ||
new_state = SubscriptionSet::State::Complete; | ||
if (new_version == 0) { | ||
new_state = SubscriptionSet::State::Complete; | ||
} | ||
else { | ||
new_state = SubscriptionSet::State::AwaitingMark; | ||
m_flx_pending_mark_version = new_version; | ||
} | ||
break; | ||
case DownloadBatchState::MoreToCome: | ||
if (m_flx_last_seen_version == new_version) { | ||
|
@@ -1438,6 +1449,16 @@ void SessionWrapper::on_download_completion() | |
m_upload_completion_handlers.push_back(std::move(handler)); // Throws | ||
m_sync_completion_handlers.pop_back(); | ||
} | ||
|
||
if (m_flx_subscription_store && m_flx_pending_mark_version != SubscriptionSet::EmptyVersion) { | ||
m_sess->logger.debug("Marking query version %1 as complete after receiving MARK message", | ||
m_flx_pending_mark_version); | ||
auto mutable_subs = m_flx_subscription_store->get_mutable_by_version(m_flx_pending_mark_version); | ||
mutable_subs.update_state(SubscriptionSet::State::Complete); | ||
std::move(mutable_subs).commit(); | ||
m_flx_pending_mark_version = SubscriptionSet::EmptyVersion; | ||
} | ||
|
||
util::LockGuard lock{m_client.m_mutex}; | ||
if (m_staged_download_mark > m_reached_download_mark) { | ||
m_reached_download_mark = m_staged_download_mark; | ||
|
@@ -1458,6 +1479,11 @@ void SessionWrapper::on_suspended(const SessionErrorInfo& error_info) | |
void SessionWrapper::on_resumed() | ||
{ | ||
m_suspended = false; | ||
if (m_flx_subscription_store && m_flx_pending_mark_version != SubscriptionSet::EmptyVersion) { | ||
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 have a test case for this scenario? 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. We didn't, so I went and wrote one, and then found out this block wasn't necessary and have removed it (but left the test case). |
||
m_sess->logger.debug("Requesting download notification for query version %1 after resume", | ||
m_flx_pending_mark_version); | ||
m_sess->request_download_completion_notification(); | ||
} | ||
if (m_connection_state_change_listener) { | ||
ClientImpl::Connection& conn = m_sess->get_connection(); | ||
if (conn.get_state() != ConnectionState::disconnected) { | ||
|
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.
Why is this removed? I am using it in RCORE-1225 to update an object brought into view during bootstrap.
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.
I think by accident. I've put it back.