diff --git a/src/object-store/src/shared_realm.cpp b/src/object-store/src/shared_realm.cpp index 516d2360..3d603225 100644 --- a/src/object-store/src/shared_realm.cpp +++ b/src/object-store/src/shared_realm.cpp @@ -179,13 +179,13 @@ void Realm::init(std::shared_ptr coordinator) else { 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(); - } + // End the read transaction created to validation/update the + // schema to avoid pinning the version even if the user never + // actually reads data + if (!m_config.read_only) { + invalidate(); } } catch (...) {