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

Sync schema migrations #7239

Merged
merged 14 commits into from
Jan 22, 2024
Merged

Sync schema migrations #7239

merged 14 commits into from
Jan 22, 2024

Conversation

danieltabacaru
Copy link
Collaborator

@danieltabacaru danieltabacaru commented Jan 8, 2024

What, How & Why?

Add support for Sync Schema Migrations for flexible sync Realms. Schema versioning is introduced for synchronized realms, so a client app can open a realm at any existing version. If required, the schema is upgraded or downgraded seamlessly.

☑️ 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 10, 2024

Pull Request Test Coverage Report for Build daniel.tabacaru_753

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 91.834%

Totals Coverage Status
Change from base Build 1971: 0.04%
Covered Lines: 234175
Relevant Lines: 254999

💛 - Coveralls

@danieltabacaru danieltabacaru marked this pull request as ready for review January 10, 2024 21:09
Copy link
Contributor

@jbreams jbreams left a comment

Choose a reason for hiding this comment

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

Since this was reviewed when it was merged into feature/sync_schema_migrations, you can merge when any merge conflicts are resolved and the tests are green.

danieltabacaru and others added 10 commits January 15, 2024 19:24
* Send schema version as part of BIND messages

* Update comment

* Changelog
* Add async shutdown of SyncSession

* SyncSession::shutdown returns a Future instead of passing callbacks around

* bug fix

* Fix the test

* A bit of redesign

* Improve test

* Relax check in test

* Rename shutdown() to pause_async(). Hide it from the public API.

* Remove unneeded header import
* Main work of sync schema migrations

* misc

* Code review changes
)

* Add option to use draft deployments when creating a schema for baas tests

* Track sync schema migration between sessions + minor refactoring

* Integration tests

* Use Transaction refs instead of shared pointers
@danieltabacaru danieltabacaru force-pushed the feature/sync_schema_migrations branch from 66127a6 to 44cbd35 Compare January 15, 2024 19:28
@danieltabacaru danieltabacaru force-pushed the feature/sync_schema_migrations branch from 44cbd35 to 18940aa Compare January 15, 2024 19:41
@danieltabacaru danieltabacaru merged commit 080108a into master Jan 22, 2024
34 of 35 checks passed
@danieltabacaru danieltabacaru deleted the feature/sync_schema_migrations branch January 22, 2024 09:50
util::CheckedLockGuard lock(m_mutex);
auto config = coordinator->get_config();
m_session = nullptr;
coordinator->close();
Copy link
Member

Choose a reason for hiding this comment

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

This is very unsafe. RealmCoordinator::close() is only safe to call if you can guarantee that no one else has a reference to the coordinator, which is not the case here. A simple example of something that'll break is if there are two async opens in progress at once.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the assumption was always that for this to work only one realm coordinator/task is allowed to have the realm file opened (otherwise we cannot delete it)

Copy link
Member

Choose a reason for hiding this comment

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

Well that isn't a very valid assumption.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see. I'll think of a different solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

it does already fail also on our ci #7325

Comment on lines +859 to +860
bool set_schema = (schema_version < target_schema_version || schema_version == ObjectStore::NotVersioned ||
set_schema_version_on_version_decrease);
Copy link
Member

Choose a reason for hiding this comment

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

This check should just be deleted entirely as it's long obsolete. It was originally there because we used to the schema version to decide if we should create and remove indexes.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants