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

Conflict detection in WAL API #1875

Open
penberg opened this issue Dec 10, 2024 · 2 comments
Open

Conflict detection in WAL API #1875

penberg opened this issue Dec 10, 2024 · 2 comments
Labels
enhancement New feature or request offline writes

Comments

@penberg
Copy link
Collaborator

penberg commented Dec 10, 2024

We currently allow arbitrary frames to be inserted to the WAL. Let's check the salt and the checksum to verify that a new frame matches the existing WAL. The tricky bit here is that the WAL we insert to needs to have the same salt as the origin WAL because salt is part of the cumulative checksum.

@penberg penberg added enhancement New feature or request offline writes labels Dec 10, 2024
@penberg
Copy link
Collaborator Author

penberg commented Dec 12, 2024

We could augment the libsql_wal_frame_insert() to force the WAL to have the same salt and checksum as the first frame. However, this seems a bit intrusive to SQLite itself, so perhaps a better approach is to use external checksumming.

@penberg
Copy link
Collaborator Author

penberg commented Jan 30, 2025

There is a simple solution here: make the libsql_wal_insert_frame simply check if a frame already exists in the WAL. If it does not, append it; otherwise compare the existing and the new frame and only accept it if the frames have the same contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request offline writes
Projects
None yet
Development

No branches or pull requests

1 participant