Revert "kvdb/postgres: remove global application level lock"

This reverts commit 43a1ca4f3d.
This commit is contained in:
Elle Mouton
2024-10-28 09:35:18 +02:00
parent a03d5fcb9e
commit 67419a7c0c
3 changed files with 53 additions and 0 deletions

View File

@@ -55,6 +55,10 @@ type Config struct {
// commands. Note that the sqlite keywords to be replaced are
// case-sensitive.
SQLiteCmdReplacements SQLiteCmdReplacements
// WithTxLevelLock when set will ensure that there is a transaction
// level lock.
WithTxLevelLock bool
}
// db holds a reference to the sql db connection.
@@ -75,6 +79,10 @@ type db struct {
// db is the underlying database connection instance.
db *sql.DB
// lock is the global write lock that ensures single writer. This is
// only used if cfg.WithTxLevelLock is set.
lock sync.RWMutex
// table is the name of the table that contains the data for all
// top-level buckets that have keys that cannot be mapped to a distinct
// sql table.