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

Restart sync if remote server returns frame number lower than cached #1838

Open
penberg opened this issue Nov 22, 2024 · 0 comments · May be fixed by #1847
Open

Restart sync if remote server returns frame number lower than cached #1838

penberg opened this issue Nov 22, 2024 · 0 comments · May be fixed by #1847
Assignees
Labels
enhancement New feature or request WAL sync

Comments

@penberg
Copy link
Collaborator

penberg commented Nov 22, 2024

We need to restart sync from whatever frame number the server returns to us, even if we have a higher cached frame number. This can happen, for example, if someone deletes and re-creates a remote database, resetting it to generation 1 and frame 0.

@penberg penberg added enhancement New feature or request WAL sync labels Nov 22, 2024
@LucioFranco LucioFranco self-assigned this Nov 26, 2024
LucioFranco added a commit that referenced this issue Nov 27, 2024
This commit adds a new error returned from `SyncContext` that indicates
that the server returned a lower frame_no than what the local cached
max server frame no expected (durable_frame_num). When the high level
`Database::push` fn gets this error it will restart the sync which will
pick up the new server side frame hint that we got and start sync from
that frame_no.

Test output:
```
2024-11-27T15:45:27.284544Z DEBUG libsql::sync: no metadata info file found
2024-11-27T15:45:27.284603Z DEBUG push_one_frame{generation=1 frame_no=0}: libsql::sync: pushing frame
2024-11-27T15:45:27.285044Z DEBUG push_one_frame{generation=1 frame_no=0}: libsql::sync: frame successfully pushed durable_frame_num=0
2024-11-27T15:45:27.315258Z DEBUG libsql::sync: read sync metadata for db_path="/var/folders/xf/644ms45s1dj06pdbkn9ybs_80000gn/T/.tmpwvzlR0/test.db", metadata=MetadataJson { hash: 1306961641, version: 0, durable_frame_num: 3, generation: 1 }
2024-11-27T15:45:27.315287Z DEBUG push_one_frame{generation=1 frame_no=4}: libsql::sync: pushing frame
2024-11-27T15:45:27.315517Z DEBUG push_one_frame{generation=1 frame_no=4}: libsql::sync: server returned durable_frame_num lower than what we sent: sent=4, got=1
2024-11-27T15:45:27.315543Z DEBUG push_one_frame{generation=1 frame_no=2}: libsql::sync: pushing frame
2024-11-27T15:45:27.315649Z DEBUG push_one_frame{generation=1 frame_no=2}: libsql::sync: frame successfully pushed durable_frame_num=2
```

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

Successfully merging a pull request may close this issue.

2 participants