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

How would read-only replicas actually work #366

Open
a-type opened this issue Mar 20, 2024 · 2 comments
Open

How would read-only replicas actually work #366

a-type opened this issue Mar 20, 2024 · 2 comments

Comments

@a-type
Copy link
Owner

a-type commented Mar 20, 2024

Ok, I admit, I sorta dabbled at support for this but didn't think it through.

The main blocker here is migrations. All meaningful migrations require writing operations to migrate the data.

A read-only replica isn't allowed to do those writes. So if it's the first replica to connect to a library after a schema change, it's unable to write the migration operations necessary to make data conform to the new schema.

This is going to require special behavior...

@a-type
Copy link
Owner Author

a-type commented Jun 20, 2024

The ability to store non-synced migration operations in-memory would probably make this possible.

A readonly replica can still generate operations, but it won't store or sync them anywhere. Migration can still work as normal, but it's lost on refresh and has to be re-applied each time.

I think this can be done with minimal added complexity.

@a-type
Copy link
Owner Author

a-type commented Oct 21, 2024

Actually, I may be overthinking this.

A read only replica could still theoretically be allowed to write to the local database. It's only forbidden from syncing back.

As an app maker, you probably want to prevent local writes to not confuse users. Either that, or limit only to one initial sync. These would both be possible to do fairly easily.

This requires no changes except to forbid sync messages from readonly replicas. Local migrations are allowed and happen according to existing rules.

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

No branches or pull requests

1 participant