-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
sqlite db backend #6570
sqlite db backend #6570
Conversation
f4e431d
to
6c865b3
Compare
👍 |
2ceb92c
to
abf7615
Compare
@blckbx good question! For the first iteration, I was hoping to keep things simple and not bring that sort of complexity into lnd. There is a new project (which I've only read about, but haven't used yet) called litestream.io that looks promising as a way to replicate sqlite database to another file locally or to cloud storage. That might be a nice solution because litestream runs as a sidecar process and so none of the replication complexity would have to come into Curious to hear your thoughts! |
225ea05
to
5a846b9
Compare
Absolutely true. Best to move this to another PR/discussion. But to get back to litestream ...
Unfortunately I'm not knowledgable enough to recommend a definite solution. So I just point to the issue CLN devs experienced using litestream, namely crashes. In the end they went away from litestream and implemented direct sqlite3 replication instead. |
Previously, we had a mix of ways to specify the DB backend: and . With the introduction of the sqlite backend, we didn't want to add yet another boolean, so we unified them into a single value.
Hey @seejee are you still interested in continuing this PR? (if not we can pick it up) |
Replaced by #7251 Thanks for getting this started! |
Change Description
Closes #6176
This PR brings SQLite support to LND. As mentioned in #6176, this PR is a first pass implements sqlite support in a somewhat naive way.
It builds on the postgres support work that was added recently, however to avoid any premature abstraction, I've intentionally duplicated some things between the
postgres
andsqlite
kvdb modules. Specifically, thekvdb/sqlite/readwrite_*.go
files are nearly completely identical to the ones in thepostgres
package, and (thanks for golang'sdatabase/sql
library) could likely be used as-is for future SQL-based kvdb backends.The table schema used by sqlite is almost identical to the postgres table schema. It is still very much a key-value approach as opposed to a properly normalized SQL table structure. The intention is that moving to a more normalized table structure could come in the future, along with tooling to migrate from the existing tables or from boltdb, but that would likely come in a future PR.
We're also making use of the https://github.com/mattn/go-sqlite3 package (which relies on C bindings) because of its maturity, as opposed to the less mature, but pure golang sqlite driver: https://pkg.go.dev/modernc.org/sqlite. If requiring CGO is a problem, then we could attempt to use the modernc sqlite package instead.
Tasks:
Steps to Test
TODO
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]
in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.