-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add package to support LiteFS in the WebSocket server #11
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tantaman
changed the title
Add classes to support LiteFS in the WebSocket server
Add package to support LiteFS in the WebSocket server
Aug 24, 2023
These are not litefs specific
instead we'll re-route write at the top of the stack at the websocket handler.
We have more information at this level and cleanup is easier to manage as the connection over which to forward writes is per-db.
- introduce DBFactory so different backends can provide different DBs. E.g., LiteFS provides one that forwards writes - make certain db methods async given we now have async operations when forwarding writes
… initialization of cached items
- make litefs db - deal with missing reqid - report errors
…hokidar on ubunutu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LiteFS is a bit more complicated when running WebSocket servers.
The reason is that all writes must go to the primary for LiteFS. In our websocket server, we determine if the received message is a write. If so, we send it on to the primary.
This isn't quite enough though. WebSocket servers are stateful by nature and we need to keep this state maintained on the edge node responsible for the websocket connection and not build up state on the primary that the writes are forwarded to.
In other words:
So after forwarding a write the follower will (for certain writes) await completion of that write (by following the -pos txid) and update its internal state.
LiteFS technically supports write forwarding (superfly/litefs#56) but the way it works is by passing the write lock around and is not recommended for cases with high write volume.