Commit Graph

105 Commits

Author SHA1 Message Date
Elle Mouton
67419a7c0c
Revert "kvdb/postgres: remove global application level lock"
This reverts commit 43a1ca4f3d.
2024-10-28 09:35:18 +02:00
Elle Mouton
a6e68cb6b8
kvdb: update btclog dep 2024-10-26 14:16:31 +02:00
Olaoluwa Osuntokun
43a1ca4f3d
kvdb/postgres: remove global application level lock
In this commit, we remove the global application level lock from the
postgres backend. This lock prevents multiple write transactions from
happening at the same time, and will also block a writer if a read is on
going. Since this lock was added, we know always open DB connections
with the strongest level of concurrency control available:
`LevelSerializable`. In concert with the new auto retry logic, we ensure
that if db transactions conflict (writing the same key/row in this
case), then the tx is retried automatically.

Removing this lock should increase perf for the postgres backend, as now
concurrent write transactions can proceed, being serialized as needed.
Rather then trying to handle concurrency at the application level, we'll
set postgres do its job, with the application only needing to retry as
necessary.
2024-09-30 16:58:46 -07:00
Olaoluwa Osuntokun
06b3588512
kvdb: update to latest walletdb version 2024-09-12 16:41:43 -07:00
Olaoluwa Osuntokun
f8962af444
kvdb: update bbolt to v1.3.11 2024-09-11 10:45:12 -07:00
Andras Banki-Horvath
2c8d1c878e
kvdb: make etcd calls timeout to ensure liveness
Previously our RPC calls to etcd would hang even in the case of properly
set dial timeouts and even if there was a network partition. To ensure
liveness we need to make sure that calls fail correctly in case of
system failure. To fix this we add a default timeout of 30 seconds to
each etcd RPC call.
2024-08-01 19:04:10 +02:00
elbandi
6043ced572
Add configuration description 2024-07-31 15:31:56 +02:00
elbandi
3d48dbdd55
Allow multiple etcd hosts to be specified in db.etcd.host. 2024-07-31 15:31:17 +02:00
Olaoluwa Osuntokun
7302051f44
build: update to sqldb v1.0.2
In this commit, we update the project and relevant sub-modules to sqldb
v1.0.2. The next step is to tag a new version of kvdb, then update the
main module to use that.
2024-04-26 15:31:14 -07:00
Olaoluwa Osuntokun
eb605a02fd
sqldb+kvdb: update to sqlite v1.29.8
Updates to SQLite 3.45.3: https://www.sqlite.org/releaselog/3_45_3.html.

May also address https://github.com/lightningnetwork/lnd/issues/8666.
2024-04-26 12:26:59 -07:00
erik
789c6bac8c multi: replace ioutil.WriteFile 2024-04-25 11:23:31 +02:00
erik
ab83343c87 multi: repleace ioutil.ReadFile 2024-04-25 11:22:43 +02:00
Olaoluwa Osuntokun
06e4ffb3f3
kvdb: bump to sqldb/v1.0.1
Post merge module clean up after
https://github.com/lightningnetwork/lnd/pull/8611.
2024-04-12 15:16:26 -07:00
Oliver Gugger
648fb22f63
multi: wrap all errors 2024-04-11 15:04:03 +02:00
Andras Banki-Horvath
9a28a4c105
kvdb: remove the unused SQL error mappers 2024-04-11 15:04:03 +02:00
Olaoluwa Osuntokun
cd0ca43a00
kvdb: don't do a critical log for db serialization errors
In this commit, we fix a bug that would cause the entire db to shutdown
if hit a panic (since db operations in the main buckets exit with a
panic) while executing a txn call back. This might be a postgres error
we need to check, so we don't want to bail out, and instead want to pass
up the error to the caller so we can retry if needed.
2024-04-11 15:04:03 +02:00
Olaoluwa Osuntokun
329fcc6498
kvdb+sqldb: update SQL error parsing to account for non wrapped errs
Some sub-systems like btcwallet will return an error from the database,
but they won't properly wrap it. As a result, we were unable to actually
catch the serialization errors in the first place. To work around this,
we'll now attempt to parse the error string directly.
2024-04-11 15:04:03 +02:00
Andras Banki-Horvath
43f4b14c28
kvdb+sqldb: use the same tx retry helper 2024-04-11 15:04:02 +02:00
undefinedor
028959f5a0
kvdb+watchtower: fix unreachable code 2024-03-25 21:04:48 +08:00
cuinix
60bc30dd08 remove repetitive words
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 14:05:47 +08:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Andras Banki-Horvath
25af657ad5
kvdb: set postgres max_connections on the started instance 2024-01-24 21:38:54 +01:00
Andras Banki-Horvath
524fa66abf
kvdb: bump embedded postgres to v1.25.0 2024-01-24 21:38:53 +01:00
Thabokani
b8d2fc3816
kvdb+cmd: fix typos 2024-01-03 12:06:32 +08:00
dependabot[bot]
effa5cf066
build(deps): bump google.golang.org/grpc from 1.53.0 to 1.56.3 in /kvdb
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.53.0 to 1.56.3.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.53.0...v1.56.3)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-25 22:28:42 +00:00
dependabot[bot]
be9fb28ac1
build(deps): bump golang.org/x/net from 0.10.0 to 0.17.0 in /kvdb
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.10.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 10:45:31 +00:00
Olaoluwa Osuntokun
bb67131ce5
kvdb/sqlbase: use positive+negative build tags for new sql error parsing
In this commit, we use exhaustive build tags to ensure that we can
always build the `sqlbase` package, independent of the set build tags.
To do this, we move the type declarations _into_ the parsing functions.
This then allows us to create two versions for each db: with the db, and
without it.

To avoid a module tag round trip to get this working, we use a local
replace for now. Once this is merged in, we can do the tag (along side
rc3), then remove the replace.
2023-09-11 20:35:01 -07:00
yyforyongyu
8813bc7ba8
kvdb/sqlbase: fix build errors
We copy the `sqldb/sqlerrors.go` into `kvdb/sqlbase` to avoid import
cycles.
2023-09-06 02:48:12 +08:00
yyforyongyu
08f4940e88
kvdb/sqlbase: fix params used in randRetryDelay 2023-09-06 02:47:55 +08:00
positiveblue
09d21345e1
multi: bump Go version
Bump all build go versions to v1.21.0
Bump the minimum build package version to v1.19.0

Debian "buster" is not longer supported. Security updates have been
discontinued since June 30th 2022. We will build using the latest
version, "bookworm".
2023-09-05 10:11:42 -07:00
yyforyongyu
68e6cd5c2e
gomod: run go work sync to sync modules
This commit is the result of running `go work sync` and `go mod tidy`
that syncs module versions for all submodules.
2023-09-05 07:27:20 +08:00
yyforyongyu
036f2a0f03
kvdb: fix version conflict in github.com/ulikunitz/xz
Fix the following conflict,
```
go: conflicting replacements for github.com/ulikunitz/xz:
	github.com/ulikunitz/xz@v0.5.11
	github.com/ulikunitz/xz@v0.5.8
```
2023-09-05 05:48:36 +08:00
Olaoluwa Osuntokun
01c64712a3
multi: ensure link is always torn down due to db failures, add exponential back off for sql-kvdb failures (#7927)
* lnwallet: fix log output msg

The log message is off by one.

* htlcswitch: fail channel when revoking it fails.

When the revocation of a channel state fails after receiving a new
CommitmentSigned msg we have to fail the channel otherwise we
continue with an unclean state.

* docs: update release-docs

* htlcswitch: tear down connection if revocation processing fails

If we couldn't revoke due to a DB error, then we want to also tear down
the connection, as we don't want the other party to continue to send
updates. That may lead to de-sync'd state an eventual force close.
Otherwise, the database might be able to recover come the next
reconnection attempt.

* kvdb: use sql.LevelSerializable for all backends

In this commit, we modify the default isolation level to be
`sql.LevelSerializable. This is the strictness isolation type for
postgres. For sqlite, there's only ever a single writer, so this doesn't
apply directly.

* kvdb/sqlbase: add randomized exponential backoff for serialization failures

In this commit, we add randomized exponential backoff for serialization
failures. For postgres, we''ll his this any time a transaction set fails
to be linearized. For sqlite, we'll his this if we have many writers
trying to grab the write lock at time same time, manifesting as a
`SQLITE_BUSY` error code.

As is, we'll retry up to 10 times, waiting a minimum of 50 miliseconds
between each attempt, up to 5 seconds without any delay at all. For
sqlite, this is also bounded by the busy timeout set, which applies on
top of this retry logic (block for busy timeout seconds, then apply this
back off logic).

* docs/release-notes: add entry for sqlite/postgres tx retry

---------

Co-authored-by: ziggie <ziggie1984@protonmail.com>
2023-08-30 16:48:00 -07:00
dependabot[bot]
b9b34a086f
build(deps): bump google.golang.org/grpc from 1.41.0 to 1.53.0 in /kvdb
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.41.0 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.41.0...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 21:12:10 +00:00
Hampus Sjöberg
3d69ed3d4c kvdb: Update bbolt to 1.3.7 in order to address mmap issues 2023-06-29 17:54:43 +02:00
dependabot[bot]
ded9fb87d2
build(deps): bump golang.org/x/net from 0.4.0 to 0.7.0 in /kvdb
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.4.0 to 0.7.0.
- [Release notes](https://github.com/golang/net/releases)
- [Commits](https://github.com/golang/net/compare/v0.4.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-17 16:03:17 +00:00
Oliver Gugger
97f139b617
Merge pull request #7353 from bottlepay/bump-kvdb-etcd
kvdb: bump etcd to v3.5.7
2023-01-24 15:58:15 +01:00
Joost Jager
1725e5bcbe
kvdb: bump etcd to v3.5.7 2023-01-24 13:52:20 +01:00
Elle Mouton
2b4de46c72
kvdb+docs: remove etcd test fixture cleanup calls
Remove the cleanup calls which no longer exist since `t.Cleanup` is now
called from within `NewEtcdTestFixture`
2023-01-24 09:23:50 +02:00
Elle Mouton
74b9c9ce9a
kvdb: add sqlite 2023-01-23 09:14:08 +02:00
Chris Geihsler
3d91bb65f7
kvdb: unify how the db backend for tests is set 2023-01-23 09:05:11 +02:00
Elle Mouton
170160f28a
kvdb+refactor: move all general sqlite code to seprate dir
In this commit, all the sql, non-postgres-specific, code is moved out of
the postgres package and into a new sqlbase package. This will make it
more easily reusable for future sql integrations.
2023-01-23 09:05:11 +02:00
Elle Mouton
30ba8cbae9
kvdb/postgres: separate general sql code from postgres
In this commit, changes are made to the `kvdb/postgres` package so that
all all the non-postgres-specific code is generalised to be applicable
for all sql code. A follow up commit will move all the general sql code
into its own package.
2023-01-23 09:05:11 +02:00
Elle Mouton
3dfaa88bb4
kvdb/postgres: remove old +build directive and cleanup
Due to the update of the kvdb package to go1.18, the `// +build`
directives are no longer required. They are removed in this commit in
order to simplify upcoming commits. Along the way, a few typos are fixed
and an unused struct is removed.
2023-01-23 09:05:11 +02:00
Elle Mouton
c6abf585ee
kvdb/postgres: make global dbConns thread safe
In this commit, a mutex is added to guard access to the global dbConns
variable in the kvdb/postgres package.
2023-01-23 09:05:11 +02:00
Elle Mouton
72dbc3dbb4
kvdb: bump go version to 1.18
Bump the go version to go1.18 so that we can get rid of the '// +build'
comments in the upcoming commits where some of the '//go:build'
comments will become too complex to write as '// +build' comments.
2023-01-23 09:05:10 +02:00
yyforyongyu
84fd911b47
multi: fix make lint
Fixes new lint errors caught by the latest version.
2022-11-18 20:48:23 +08:00
yyforyongyu
4db6617d45
multi: skip checking long lines for config files 2022-10-20 23:59:09 +08:00
Eng Zer Jun
889cb0af47
kvdb/etcd: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-13 17:47:03 +08:00
Oliver Gugger
ee9d6f21bd
etcd: add SequenceKey function 2022-10-13 09:37:52 +02:00