Skip to content

Commit

Permalink
*: refine transaction related log (#13380)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood authored and sre-bot committed Nov 12, 2019
1 parent 3663a39 commit 2b08825
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 0 additions & 3 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,6 @@ func (a *ExecStmt) handlePessimisticLockError(ctx context.Context, err error) (E
zap.Uint64("deadlockKeyHash", deadlock.DeadlockKeyHash))
} else if terror.ErrorEqual(kv.ErrWriteConflict, err) {
conflictCommitTS := extractConflictCommitTS(err.Error())
if conflictCommitTS == 0 {
logutil.Logger(ctx).Warn("failed to extract conflictCommitTS from a conflict error")
}
forUpdateTS := txnCtx.GetForUpdateTS()
logutil.Logger(ctx).Info("pessimistic write conflict, retry statement",
zap.Uint64("txn", txnCtx.StartTS),
Expand Down
11 changes: 10 additions & 1 deletion store/tikv/lock_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package tikv

import (
"bytes"
"container/list"
"context"
"fmt"
Expand Down Expand Up @@ -137,7 +138,12 @@ type Lock struct {
}

func (l *Lock) String() string {
return fmt.Sprintf("key: %s, primary: %s, txnStartTS: %d, ttl: %d", l.Key, l.Primary, l.TxnID, l.TTL)
buf := bytes.NewBuffer(make([]byte, 0, 128))
buf.WriteString("key: ")
prettyWriteKey(buf, l.Key)
buf.WriteString(", primary: ")
prettyWriteKey(buf, l.Primary)
return fmt.Sprintf("%s, txnStartTS: %d, ttl: %d, type: %s", buf.String(), l.TxnID, l.TTL, l.LockType)
}

// NewLock creates a new *Lock.
Expand Down Expand Up @@ -477,6 +483,9 @@ func (lr *LockResolver) resolveLock(bo *Backoffer, l *Lock, status TxnStatus, cl
// prevent from scanning the whole region in this case.
tikvLockResolverCountWithResolveLockLite.Inc()
req.ResolveLock.Keys = [][]byte{l.Key}
if !status.IsCommitted() {
logutil.Logger(context.Background()).Info("resolveLock rollback", zap.String("lock", l.String()))
}
}
resp, err := lr.store.SendReq(bo, req, loc.Region, readTimeoutShort)
if err != nil {
Expand Down

0 comments on commit 2b08825

Please sign in to comment.