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

DROP TABLE leads to corruption? #433

Open
louwers opened this issue May 26, 2024 · 3 comments
Open

DROP TABLE leads to corruption? #433

louwers opened this issue May 26, 2024 · 3 comments

Comments

@louwers
Copy link
Contributor

louwers commented May 26, 2024

Once a table has been turned into a CRR with crsql_as_crr, dropping it seems to result in irrecoverable corruption since the crsql_changes will be in an invalid state. Deleting changes is not possible (only inserts are allowed).

SELECTing from crsql_changes now leads to query aborted. If the table is dropped and re-created on two sites, trying to sync will fail whenINSERTing old changes that are lingering (could not find row to merge with for tbl ....

I think when dropping a table, all related entries in crsql_changes should be deleted.

@louwers
Copy link
Contributor Author

louwers commented May 26, 2024

SELECT crsql_begin_alter('mytable');
DROP TABLE mytable
SELECT crsql_commit_alter('mytable');

Results in:

Error: failed compacting tables post alteration

@louwers
Copy link
Contributor Author

louwers commented May 26, 2024

OK deleting mytable__crsql_pks and mytable__crsql_clock seems to resolve the issues.

But since these are not part of the API of cr-sqlite, I think these tables should be dropped along with the source table automatically. But I think this is a known limitation right now:

4. [ ] drop table

@tantaman
Copy link
Collaborator

Thanks. I'll update begin_alter to account for drop table

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

2 participants