-
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
kvdb: add postgres #5366
Merged
Merged
kvdb: add postgres #5366
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Postgres support in LND | ||
|
||
With the introduction of the `kvdb` interface, LND can support multiple database | ||
backends. One of the supported backends is Postgres. This document | ||
describes how it can be configured. | ||
|
||
## Building LND with postgres support | ||
|
||
To build LND with postgres support, include the following build tag: | ||
|
||
```shell | ||
⛰ make tags="kvdb_postgres" | ||
``` | ||
|
||
## Configuring Postgres for LND | ||
|
||
In order for LND to run on Postgres, an empty database should already exist. A | ||
database can be created via the usual ways (psql, pgadmin, etc). A user with | ||
access to this database is also required. | ||
|
||
Creation of a schema and the tables is handled by LND automatically. | ||
|
||
## Configuring LND for Postgres | ||
|
||
LND is configured for Postgres through the following configuration options: | ||
|
||
* `db.backend=postgres` to select the Postgres backend. | ||
* `db.postgres.dsn=...` to set the database connection string that includes | ||
database, user and password. | ||
* `db.postgres.timeout=...` to set the connection timeout. If not set, no | ||
timeout applies. |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want separate lines for these tags to test them individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more context: when we add the tag
kvdb_etcd
we also run channeldb unit tests on etcd.The trick is that there's a
GetTestBackend()
function inkvdb/backend.go
and there's a constant behind the tag inkvdb/kvdb_etcd.go
andkvdb/kvdb_no_etcd.go
that defines which backend to start withGetTestBacked()
.Looking at it again I now think having the tags passed together works but it'll still run the channeldb tests on etcd. You may want to fix this such that those tests also run on Postgres.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the channeldb tests on postgres and they all pass except for three specialty tests. Two fail because of assumptions about the db path (does not apply to postgres) and one because of panic bubbling that is different in Postgres. Needs a closer look.
My proposal is to do that work in a separate PR where we can also evaluate the additional run time for a test suite that is already long-running. For now, I at least have manual confirmation that the channeldb tests do pass on Postgres. Let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the postgres tests as a separate suite sounds good to me. If that needs some more work because of special cases I agree it should be done in a separate PR. Knowing they pass (with just three explainable exceptions) is important though.
@joostjager can you create an issue please so we don't forget?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed the code that I used here: #5550. I think this can double as an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the case that tacking on this extra tag doesn't actually do anything in practice? I'm guessing Go has some ordering tie-breaker here that causes it to only use the first tag?
In any case I think we want these to run separately so we can catch distinct regressions for both backends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these tests still failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are running separately. There is
kvdb/etcd_test.go
andkvdb/postgres_test.go
. Both build tags are set to have all code available in the test binary.Still failing, I haven't continued the work on that PR #5550 above.