fix sqlite3 tx retry condition operator precedence (#32897)

This commit is contained in:
Alexander Emelin 2021-04-13 18:26:54 +03:00 committed by GitHub
parent 7b7ea5a1ce
commit e288cd0836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,7 @@ func inTransactionWithRetryCtx(ctx context.Context, engine *xorm.Engine, callbac
// special handling of database locked errors for sqlite, then we can retry 5 times
var sqlError sqlite3.Error
if errors.As(err, &sqlError) && retry < 5 && sqlError.Code == sqlite3.ErrLocked || sqlError.Code == sqlite3.ErrBusy {
if errors.As(err, &sqlError) && retry < 5 && (sqlError.Code == sqlite3.ErrLocked || sqlError.Code == sqlite3.ErrBusy) {
if rollErr := sess.Rollback(); rollErr != nil {
return errutil.Wrapf(err, "Rolling back transaction due to error failed: %s", rollErr)
}