-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lncfg: readd global lock for postgres and the channeldb_kv table #10394
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
lncfg: readd global lock for postgres and the channeldb_kv table #10394
Conversation
660f743 to
98ea583
Compare
98ea583 to
cecc728
Compare
starius
left a comment
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.
LGTM! 💾
Added few comments.
sqldb/config.go
Outdated
| MaxConnections int `long:"maxconnections" description:"The maximum number of open connections to the database. Set to zero for unlimited."` | ||
| SkipMigrations bool `long:"skipmigrations" description:"Skip applying migrations on startup."` | ||
| ChannelDBWithGlobalLock bool `long:"channeldb-with-global-lock" description:"Use a global lock for channeldb access. This ensures only a single writer at a time but reduces concurrency. This is a temporary workaround until the revocation log is migrated to native SQL."` | ||
| WalletDBWithGlobalLock bool `long:"walletdb-with-global-lock" description:"Use a global lock for wallet database access. This ensures only a single writer at a time but reduces concurrency. This is a temporary workaround until the wallet is fully concurrent-safe."` |
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.
Can we add default:"true" to the tags? I think lnd --help will show it then.
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.
no go-flags does not support defaults for booleans.
| concurrent access, while the wallet global lock defaults to `true` to maintain | ||
| safe single-writer behavior until the wallet subsystem is fully | ||
| concurrent-safe. | ||
|
|
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.
Should we also document the options in docs/postgres.md file?
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.
added.
506e232 to
5b7abfd
Compare
bhandras
left a comment
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.
LGTM, thank you! 🎉
Add two configuration options to control global lock usage for different postgres database backends: - ChannelDBWithGlobalLock: for channeldb access (default: false) - WalletDBWithGlobalLock: for wallet database access (default: true) These allow fine-grained control over which databases use global locks, rather than hardcoding the behavior. This is a temporary measure until the revocation log and wallet are migrated to native SQL and become fully concurrent-safe.
Replace hardcoded WithGlobalLock assignment with configurable options wallet postgres backends. Also add the WithGlobalLock option to the channeldb table for postgres backends. Defaults: - channeldb: false (allow concurrent access) - wallet: true (maintain safe single-writer behavior) Users can now override these defaults via: - db.postgres.channeldb-with-global-lock - db.postgres.walletdb-with-global-lock This gives operators flexibility while maintaining safe defaults until full native SQL migration is complete. Moreover exclude db.postgres.walletdb-with-global-lock check in the sample config file script. We cannot easily check the correct default because we set it later in the LND startup sequence so we exclude it.
5b7abfd to
5656335
Compare
Added new Postgres configuration options
db.postgres.channeldb-with-global-lockanddb.postgres.walletdb-with-global-lockto allow fine-grained control over database concurrency. The channeldb global lock defaults tofalseto enable concurrent access, while the wallet global lock defaults totrueto maintain safe single-writer behavior until the wallet subsystem is fully concurrent-safe.