-
Notifications
You must be signed in to change notification settings - Fork 324
feat(vfs): add observability PRAGMAs and relative time parsing #856
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
base: main
Are you sure you want to change the base?
Conversation
Add VFS observability features for monitoring replica health: - PRAGMA litestream_txid: Return current transaction ID - PRAGMA litestream_lag: Return seconds since last successful poll - Extend PRAGMA litestream_time to return actual LTX timestamp instead of "latest" when viewing current data - Add relative time parsing for litestream_time (e.g., "5 minutes ago", "yesterday") using go-dateparser library Fixes #851, #852, #853, #854 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Add SQL functions (litestream_time(), litestream_txid(), litestream_lag(),
litestream_set_time()) as an alternative interface to the existing PRAGMAs.
This provides more flexibility for queries and monitoring.
SQL Functions (via extension auto-extension):
- SELECT litestream_time() - returns current timestamp
- SELECT litestream_txid() - returns current transaction ID
- SELECT litestream_lag() - returns seconds since last poll
- SELECT litestream_set_time('timestamp') - set time travel target
- SELECT litestream_set_time('LATEST') - reset to latest
PRAGMAs (unchanged):
- PRAGMA litestream_time
- PRAGMA litestream_time = 'timestamp'
- PRAGMA litestream_txid
- PRAGMA litestream_lag
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Keep latestLTXTime in sync when pollReplicaClient processes new LTX files. Previously it was only set during rebuildIndex(), causing PRAGMA litestream_time to return stale timestamps after the first poll. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Move connection mapping code into vfs.go since there's no need for a separate file - both have the same build tag and are part of the same logical unit. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
@corylanou Can you have the |
Change litestream_txid PRAGMA and SQL function to return the TXID as a 16-character lowercase hex string using ltx.TXID.String() instead of returning it as a decimal integer. This matches how TXIDs are formatted throughout the rest of the codebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Done! |
Summary
This PR adds VFS observability features for monitoring replica health and enhances time travel functionality. It provides both SQL functions and PRAGMAs for maximum flexibility:
SQL Functions (via extension auto-extension)
PRAGMAs
Changes
vfs.go: Add new PRAGMA handlers, fields for tracking state, and time parsing helpervfs_connections.go: Connection-to-VFSFile mapping for SQL function supportsrc/litestream-vfs.c: SQL function implementations and auto-extension registrationcmd/litestream-vfs/main.go: CGO exports for SQL functionsgo.mod: Addgithub.com/markusmobius/go-dateparserdependencycmd/litestream-vfs/time_travel_test.go: Add/update testsTest Plan
Documentation
Created issue benbjohnson/litestream.io#146 to document these features.
Closes #851, #852, #853, #854