diff --git a/shared_realm.cpp b/shared_realm.cpp index 28bb81b6..432f06d9 100644 --- a/shared_realm.cpp +++ b/shared_realm.cpp @@ -171,6 +171,13 @@ SharedRealm Realm::get_shared_realm(Config config) else { realm->update_schema(std::move(target_schema), target_schema_version); } + + if (!m_config.read_only) { + // End the read transaction created to validation/update the + // schema to avoid pinning the version even if the user never + // actually reads data + invalidate(); + } } } diff --git a/shared_realm.hpp b/shared_realm.hpp index 0503282a..02367b9e 100644 --- a/shared_realm.hpp +++ b/shared_realm.hpp @@ -88,6 +88,7 @@ namespace realm { void commit_transaction(); void cancel_transaction(); bool is_in_transaction() const { return m_in_transaction; } + bool is_in_read_transaction() const { return !!m_group; } bool refresh(); void set_auto_refresh(bool auto_refresh) { m_auto_refresh = auto_refresh; }