-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: unify the management of transaction activation by TxnManager. #35679
Changes from 12 commits
233a8df
b51a332
3b91cbc
7106400
c4786a9
3bd122d
19b00f6
6241b73
3b8c815
6df2d89
f6d84cd
7edae7a
6f0d179
8e1bb57
107751f
288c66b
6e87d6d
e102e6c
769c4b4
3f84aee
3e595df
cfe4781
9ebe374
a71583f
43f7e7b
8789554
8ffb6eb
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 |
---|---|---|
|
@@ -17,15 +17,18 @@ package session | |
import ( | ||
"bytes" | ||
"context" | ||
"fmt" | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/pingcap/kvproto/pkg/kvrpcpb" | ||
"github.com/pingcap/tidb/domain" | ||
"github.com/pingcap/tidb/kv" | ||
"github.com/pingcap/tidb/parser/model" | ||
"github.com/pingcap/tidb/parser/mysql" | ||
"github.com/pingcap/tidb/planner/core" | ||
"github.com/pingcap/tidb/sessionctx/variable" | ||
"github.com/pingcap/tidb/sessiontxn" | ||
"github.com/pingcap/tidb/store/mockstore" | ||
"github.com/pingcap/tidb/table" | ||
"github.com/pingcap/tidb/tablecodec" | ||
|
@@ -254,6 +257,8 @@ func TestAmendCollectAndGenMutations(t *testing.T) { | |
store: store, | ||
sessionVars: variable.NewSessionVars(), | ||
} | ||
se.mu.values = make(map[fmt.Stringer]interface{}) | ||
domain.BindDomain(se, &domain.Domain{}) | ||
startStates := []model.SchemaState{model.StateNone, model.StateDeleteOnly, model.StateWriteOnly, model.StateWriteReorganization} | ||
for _, startState := range startStates { | ||
endStatMap := ConstOpAddIndex[startState] | ||
|
@@ -404,10 +409,9 @@ func TestAmendCollectAndGenMutations(t *testing.T) { | |
|
||
logutil.BgLogger().Info("[TEST]finish to write old txn data") | ||
// Write data for this new transaction, its memory buffer will be used by schema amender. | ||
txn, err := se.store.Begin() | ||
err = sessiontxn.NewTxn(ctx, se) | ||
require.NoError(t, err) | ||
se.txn.changeInvalidToValid(txn) | ||
txn, err = se.Txn(true) | ||
txn, err := se.Txn(false) | ||
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. Why Txn(true) => Txn(false) 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. The txn now is already actiavated in sessiontxn.NewTxn(ctx, se), so whether true or false here has no difference. |
||
require.NoError(t, err) | ||
var checkKeys []kv.Key | ||
for i, key := range mutations.GetKeys() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,8 +152,8 @@ type Context interface { | |
HasLockedTables() bool | ||
// PrepareTSFuture uses to prepare timestamp by future. | ||
PrepareTSFuture(ctx context.Context, future oracle.Future, scope string) error | ||
// GetPreparedTSFuture returns the prepared ts future | ||
GetPreparedTSFuture() oracle.Future | ||
// GetPreparedTxnFuture returns the prepared ts future | ||
GetPreparedTxnFuture() TxnFuture | ||
// StoreIndexUsage stores the index usage information. | ||
StoreIndexUsage(tblID int64, idxID int64, rowsSelected int64) | ||
// GetTxnWriteThroughputSLI returns the TxnWriteThroughputSLI. | ||
|
@@ -176,6 +176,12 @@ type Context interface { | |
ReleaseAllAdvisoryLocks() int | ||
} | ||
|
||
// TxnFuture todo: add comments | ||
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. You can add comments now... 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. ... Done. |
||
type TxnFuture interface { | ||
// Wait converts pending txn to valid | ||
Wait(ctx context.Context, sctx Context) (kv.Transaction, error) | ||
} | ||
|
||
type basicCtxType int | ||
|
||
func (t basicCtxType) String() string { | ||
|
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.
If mockContext can return a valid infoschema, can we revert this line?
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 is still needed as some tests does not init domain propoerly.