Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/sqlcache/db/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func (c *client) WithTransaction(ctx context.Context, forWriting bool, f WithTra
}

func (c *client) withTransaction(ctx context.Context, forWriting bool, f WithTransactionFunction) error {
if forWriting {
c.writeMu.Lock()
defer c.writeMu.Unlock()
}

c.connLock.RLock()
// note: this assumes _txlock=immediate in the connection string, see NewConnection
tx, err := c.beginTX(ctx, forWriting)
Expand Down Expand Up @@ -162,6 +167,7 @@ type client struct {
Client
conn Connection
connLock sync.RWMutex
writeMu sync.Mutex
encryptor Encryptor
decryptor Decryptor
encoding encoding
Expand Down