Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit f340c94

Browse files
committed
update comment
1 parent cde500c commit f340c94

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

internal/database/basestore/handle.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,21 @@ func makeSavepointID() (string, error) {
156156
return fmt.Sprintf("sp_%s", strings.ReplaceAll(id.String(), "-", "_")), nil
157157
}
158158

159-
var ErrConcurrentTransactions = errors.New("transaction used concurrently")
159+
var ErrConcurrentTransactionAccess = errors.New("transaction used concurrently")
160160

161-
// lockingTx wraps a *sql.Tx with a mutex, and reports when a caller tries
162-
// to use the transaction concurrently. Since using a transaction concurrently
163-
// is unsafe, we want to catch these issues. Currently, lockingTx will just
164-
// log an error and serialize accesses to the wrapped *sql.Tx, but in the future
165-
// concurrent calls may be upgraded to an error.
161+
// lockingTx wraps a *sql.Tx with a mutex, and reports when a caller tries to
162+
// use the transaction concurrently. Since using a transaction concurrently is
163+
// unsafe, we want to catch these issues. If lockingTx detects that a
164+
// transaction is being used concurrently, it will return
165+
// ErrConcurrentTransactionAccess and log an error.
166166
type lockingTx struct {
167167
tx *sql.Tx
168168
mu sync.Mutex
169169
}
170170

171171
func (t *lockingTx) lock() error {
172172
if !t.mu.TryLock() {
173-
err := errors.WithStack(ErrConcurrentTransactions)
173+
err := errors.WithStack(ErrConcurrentTransactionAccess)
174174
log.Scoped("internal", "database").Error("transaction used concurrently", log.Error(err))
175175
return err
176176
}

internal/database/basestore/store_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestConcurrentTransactions(t *testing.T) {
106106
})
107107
}
108108
err = g.Wait()
109-
require.ErrorIs(t, err, ErrConcurrentTransactions)
109+
require.ErrorIs(t, err, ErrConcurrentTransactionAccess)
110110
})
111111

112112
t.Run("parallel insertions on a single transaction fails", func(t *testing.T) {
@@ -123,7 +123,7 @@ func TestConcurrentTransactions(t *testing.T) {
123123
})
124124
}
125125
err = g.Wait()
126-
require.ErrorIs(t, err, ErrConcurrentTransactions)
126+
require.ErrorIs(t, err, ErrConcurrentTransactionAccess)
127127
})
128128
}
129129

0 commit comments

Comments
 (0)