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

libsql: restart sync on lower frame_no from remote #1847

Merged
merged 1 commit into from
Nov 30, 2024
Merged

Conversation

LucioFranco
Copy link
Contributor

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

libsql/src/sync.rs Outdated Show resolved Hide resolved
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
@LucioFranco LucioFranco requested a review from penberg November 28, 2024 16:14
@penberg penberg added this pull request to the merge queue Nov 30, 2024
Merged via the queue into main with commit 9241b00 Nov 30, 2024
18 checks passed
@penberg penberg deleted the lucio/1838 branch November 30, 2024 10:15
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

Successfully merging this pull request may close these issues.

Restart sync if remote server returns frame number lower than cached
2 participants