-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
txn: fix the resolved txn status cache for pessimistic txn #21689
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1151,6 +1151,10 @@ func (mvcc *MVCCLevelDB) CheckTxnStatus(primaryKey []byte, lockTS, callerStartTS | |
|
||
// If the lock has already outdated, clean up it. | ||
if uint64(oracle.ExtractPhysical(lock.startTS))+lock.ttl < uint64(oracle.ExtractPhysical(currentTS)) { | ||
logutil.BgLogger().Info("rollback expired lock and write rollback record", | ||
zap.Stringer("primary key", kv.Key(primaryKey)), | ||
zap.Uint64("lock startTS", dec.lock.startTS), | ||
zap.Stringer("lock op", dec.lock.op)) | ||
if err = rollbackLock(batch, primaryKey, lockTS); err != nil { | ||
err = errors.Trace(err) | ||
return | ||
|
@@ -1333,6 +1337,12 @@ func (mvcc *MVCCLevelDB) ResolveLock(startKey, endKey []byte, startTS, commitTS | |
mvcc.mu.Lock() | ||
defer mvcc.mu.Unlock() | ||
|
||
if len(startKey) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temproraly solving some mvcc leveldb problem without which resolve lock will not work for splitted regions. |
||
startKey = []byte{} | ||
} | ||
if len(endKey) > 0 { | ||
endKey = []byte{} | ||
} | ||
iter, currKey, err := newScanIterator(mvcc.db, startKey, endKey) | ||
defer iter.Release() | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -652,6 +652,16 @@ func (c *twoPhaseCommitter) doActionOnGroupMutations(bo *Backoffer, action twoPh | |
// by test suites. | ||
secondaryBo := NewBackofferWithVars(context.Background(), CommitMaxBackoff, c.txn.vars) | ||
go func() { | ||
failpoint.Inject("beforeCommitSecondaries", func(v failpoint.Value) { | ||
if s, ok := v.(string); !ok { | ||
logutil.Logger(bo.ctx).Info("[failpoint] sleep 2s before commit secondary keys", | ||
zap.Uint64("connID", c.connID), zap.Uint64("startTS", c.startTS)) | ||
time.Sleep(2 * time.Second) | ||
} else if s == "skip" { | ||
failpoint.Return() | ||
} | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about to make this failpoint more general (eg. like the following) so that we can either disable it by failpoint.Inject("beforeCommitSecondaries", func(v failpoint.Value) {
if s, ok := v.(string); !ok {
} else if s == "skip" {
failpoint.Return()
}
}) |
||
|
||
e := c.doActionOnBatches(secondaryBo, action, batches) | ||
if e != nil { | ||
logutil.BgLogger().Debug("2PC async doActionOnBatches", | ||
|
@@ -1218,8 +1228,10 @@ func (actionCommit) handleSingleBatch(c *twoPhaseCommitter, bo *Backoffer, batch | |
} | ||
logutil.Logger(bo.ctx).Error("2PC failed commit key after primary key committed", | ||
zap.Error(err), | ||
zap.Stringer("primaryKey", kv.Key(c.primaryKey)), | ||
zap.Uint64("txnStartTS", c.startTS), | ||
zap.Uint64("commitTS", c.commitTS), | ||
zap.Uint64("forUpdateTS", c.forUpdateTS), | ||
zap.Strings("keys", hexBatchKeys(batch.mutations.keys))) | ||
return errors.Trace(err) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's complex. I want to confirm Does it fail with the always cached version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested without cache change, it will fail with error reported from
admin check
statement. Could be treated as a reproducing case in unit-test, we need also add cases in ticase I think.