diff --git a/CHANGELOG.md b/CHANGELOG.md index dbaeb336e83..8fb30f1dcf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?) * Deleting an object in an asymmetric table would cause a crash. Likely to solve [#1537](https://github.com/realm/realm-kotlin/issues/1537), since v12.1.0. * Fixed FLX subscriptions not being fullfilled if the session was interrupted during bootstrapping. ([PR 7042](https://github.com/realm/realm-core/pull/7042)) +* Fixed FLX subscriptions not being picked up if an upload message was sent immediately after a subscription was committed but before the sync client checks for new subscriptions via `SubscriptionStore::get_next_pending_version()`. ([PR 7042](https://github.com/realm/realm-core/pull/7042)) ### Breaking changes * None. diff --git a/src/realm/sync/subscriptions.cpp b/src/realm/sync/subscriptions.cpp index f2e2dd10b5c..c44031fbc03 100644 --- a/src/realm/sync/subscriptions.cpp +++ b/src/realm/sync/subscriptions.cpp @@ -592,7 +592,11 @@ SubscriptionSet MutableSubscriptionSet::commit() if (m_state == State::Uncommitted) { m_state = State::Pending; } - m_obj.set(mgr->m_sub_set_snapshot_version, static_cast(m_tr->get_version())); + + // m_tr->get_version() gives the read transaction number that this write is based on. + // What we want to commit as the snapshot_version is actually the version of this commit, + // so assuming sequential commits and we have the write lock, we use m_tr->get_version() + 1. + m_obj.set(mgr->m_sub_set_snapshot_version, static_cast(m_tr->get_version() + 1)); auto obj_sub_list = m_obj.get_linklist(mgr->m_sub_set_subscriptions); obj_sub_list.clear();