@@ -156,21 +156,21 @@ func makeSavepointID() (string, error) {
156
156
return fmt .Sprintf ("sp_%s" , strings .ReplaceAll (id .String (), "-" , "_" )), nil
157
157
}
158
158
159
- var ErrConcurrentTransactions = errors .New ("transaction used concurrently" )
159
+ var ErrConcurrentTransactionAccess = errors .New ("transaction used concurrently" )
160
160
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.
166
166
type lockingTx struct {
167
167
tx * sql.Tx
168
168
mu sync.Mutex
169
169
}
170
170
171
171
func (t * lockingTx ) lock () error {
172
172
if ! t .mu .TryLock () {
173
- err := errors .WithStack (ErrConcurrentTransactions )
173
+ err := errors .WithStack (ErrConcurrentTransactionAccess )
174
174
log .Scoped ("internal" , "database" ).Error ("transaction used concurrently" , log .Error (err ))
175
175
return err
176
176
}
0 commit comments