4 ms·
It’s available as a file handle. If you have a database file named “db” then you can read “db-pos” to read the replication position. The position is a tuple of
by benbjohnson 4y ago
It’s available as a file handle. If you have a database file named “db” then you can read “db-pos” to read the replication position. The position is a tuple of the TXID and the database checksum.
- ngrilly 4y agoCan the app read it concurrently while it is updated by LiteFS?
- benbjohnson 4y agoYes, the app can read it whenever. There's a brief lock obtained on the current database position internally to read it out. The position only gets updated at the end of the transaction.
- yencabulator 4y agoLooks like LiteFS invalidates the cached file contents on every update of position. This means there is never stale data to be read. (The client needs to make sure to consume that in a single pread/read syscall, or it could observe a sheared state.) Disclaimer: I wrote the FUSE framework LiteFS uses, https://bazil.org/fuse https://bazil.org/fuse https://github.com/superfly/litefs/blob/52e269d4b04070690ce2757e568d320ae631d7fe/db.go#L121 https://github.com/superfly/litefs/blob/52e269d4b04070690ce2... https://github.com/superfly/litefs/blob/52e269d4b04070690ce2757e568d320ae631d7fe/fuse/file_system.go#L136 https://github.com/superfly/litefs/blob/52e269d4b04070690ce2... https://github.com/superfly/litefs/blob/a5cf33d1a3a91873d4ad291e6e63c94a8488084d/fuse/pos_node.go#L49 https://github.com/superfly/litefs/blob/a5cf33d1a3a91873d4ad...
- ngrilly 4y agoVery clear. Thanks for the great explanation.