Skip to content
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

Reuse transaction when refreshing subscriptions after commit #8068

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jbreams
Copy link
Contributor

@jbreams jbreams commented Jan 24, 2025

What, How & Why?

Instead of throwing the read transaction away after committing subscription changes and then opening a new frozen transaction at the committed transaction's version - we should just re-use the read transaction.

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)
  • C-API, if public C++ API changed
  • bindgen/spec.yml, if public C++ API changed

Copy link

coveralls-official bot commented Jan 24, 2025

Pull Request Test Coverage Report for Build jonathan.reams_3585

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 60 unchanged lines in 13 files lost coverage.
  • Overall coverage decreased (-0.005%) to 91.127%

Files with Coverage Reduction New Missed Lines %
src/realm/array_string.cpp 1 88.03%
src/realm/mixed.cpp 1 86.75%
src/realm/sort_descriptor.cpp 1 94.06%
src/realm/uuid.cpp 1 98.48%
src/realm/array_blobs_big.cpp 2 98.58%
src/realm/cluster.cpp 2 75.85%
src/realm/sync/transform.cpp 2 61.08%
src/realm/sync/noinst/protocol_codec.hpp 3 75.74%
src/realm/link_translator.cpp 4 76.92%
src/realm/sync/noinst/client_impl_base.cpp 7 82.47%
Totals Coverage Status
Change from base Build 2648: -0.005%
Covered Lines: 217383
Relevant Lines: 238550

💛 - Coveralls

@kraenhansen
Copy link
Member

I've confirmed this fixed the issue we were seeing with Realm Core v14.13.4 via realm/realm-js#6961

@@ -970,9 +964,9 @@ SubscriptionSet SubscriptionStore::get_by_version(int64_t version_id)
throw KeyNotFound(util::format("Subscription set with version %1 not found", version_id));
}

SubscriptionSet SubscriptionStore::get_refreshed(ObjKey key, int64_t version, std::optional<DB::VersionID> db_version)
SubscriptionSet SubscriptionStore::get_refreshed(ObjKey key, int64_t version, std::optional<TransactionRef> maybe_tr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you don't need std::optional here. TransactionRef is already a pointer type that can be checked for null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its clearer with the optional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just that we have a tradition for checking the pointer directly.

@jbreams jbreams marked this pull request as ready for review January 27, 2025 15:12
Copy link
Collaborator

@danieltabacaru danieltabacaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢 🇮🇹

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants