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: Fix WAL pull logic on last frame #1877

Merged
merged 1 commit into from
Dec 12, 2024
Merged

libsql: Fix WAL pull logic on last frame #1877

merged 1 commit into from
Dec 12, 2024

Conversation

penberg
Copy link
Collaborator

@penberg penberg commented Dec 11, 2024

The WAL sync protocol only allows you to fetch frames for a range. While the protocol does not have mechanism to determine what is the latest frame on the server for pull, it does signal with HTTP status code 400 when you attempt to read a frame that does not exists.

Let's use this signal to fix WAL pull logic not to fail always. In the future, we might want to consider extending the protocol to allow clients to proble for latest frame. That, however, will make the protocol a bit more chatty, so I am trying to avoid that as long as I can.

The WAL sync protocol only allows you to fetch frames for a range.
While the protocol does not have mechanism to determine what is the
latest frame on the server for pull, it does signal with HTTP status
code 400 when you attempt to read a frame that does not exists.

Let's use this signal to fix WAL pull logic not to fail always. In the
future, we might want to consider extending the protocol to allow
clients to proble for latest frame. That, however, will make the
protocol a bit more chatty, so I am trying to avoid that as long as I
can.
Comment on lines +265 to 267
if res.status() == StatusCode::BAD_REQUEST {
return Ok(None);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of catch all BAD_REQUEST here since there are other areas that can produce this code and we end up eating the response. Should the server return 404 if the frame doesn't exist? Or maybe it should return 200 + an error code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair. I am merging this now because this is how the protocol works. Let's discuss changing the protocol separtely.

@penberg penberg added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit 6ed1690 Dec 12, 2024
19 checks passed
@penberg penberg deleted the fix-wal-pull branch December 12, 2024 08:53
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.

2 participants