From 576e9a2bc682db8294125dccf953779a9c2f864a Mon Sep 17 00:00:00 2001 From: ekexium Date: Tue, 12 Mar 2024 15:25:18 +0800 Subject: [PATCH 1/6] feat: produce warnings when fallback from bulk mode Signed-off-by: ekexium --- pkg/session/session.go | 35 +++++++++++++++---- .../realtikvtest/pipelineddmltest/BUILD.bazel | 1 + .../pipelineddmltest/pipelineddml_test.go | 22 ++++++++++-- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/pkg/session/session.go b/pkg/session/session.go index 8298a93c05f33..eca25397e1619 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -3818,7 +3818,7 @@ func (s *session) PrepareTSFuture(ctx context.Context, future oracle.Future, sco future: future, store: s.store, txnScope: scope, - pipelined: s.isPipelinedDML(), + pipelined: s.usePipeilnedDMLorWarn(), }) return nil } @@ -4291,8 +4291,8 @@ func (s *session) NewStmtIndexUsageCollector() *indexusage.StmtIndexUsageCollect return indexusage.NewStmtIndexUsageCollector(s.idxUsageCollector) } -// isPipelinedDML returns the current statement can be executed as a pipelined DML. -func (s *session) isPipelinedDML() bool { +// usePipeilnedDMLorWarn returns the current statement can be executed as a pipelined DML. +func (s *session) usePipeilnedDMLorWarn() bool { if !s.sessionVars.BulkDMLEnabled { return false } @@ -4300,15 +4300,36 @@ func (s *session) isPipelinedDML() bool { if stmtCtx == nil { return false } - if !stmtCtx.InInsertStmt && !stmtCtx.InDeleteStmt && !stmtCtx.InUpdateStmt { - // not a DML + vars := s.GetSessionVars() + if (vars.BatchCommit || vars.BatchInsert || vars.BatchDelete) && vars.DMLBatchSize > 0 && variable.EnableBatchDML.Load() { + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used with the deprecated Batch DML. Fallback to standard mode.")) + return false + } + if vars.BinlogClient != nil { + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode.")) + return false + } + if !(stmtCtx.InInsertStmt || stmtCtx.InDeleteStmt || stmtCtx.InUpdateStmt) { + stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used for auto-commit INSERT, REPLACE, UPDATE or DELETE. Fallback to standard mode.")) return false } if s.isInternal() { + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used for internal SQL. Fallback to standard mode.")) + return false + } + if vars.InTxn() { + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in transaction. Fallback to standard mode.")) + return false + } + if !vars.IsAutocommit() { + stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used in autocommit mode. Fallback to standard mode.")) return false } - return s.sessionVars.IsAutocommit() && !s.sessionVars.InTxn() && - !config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() && s.sessionVars.BinlogClient == nil + if config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() { + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode.")) + return false + } + return true } // RemoveLockDDLJobs removes the DDL jobs which doesn't get the metadata lock from job2ver. diff --git a/tests/realtikvtest/pipelineddmltest/BUILD.bazel b/tests/realtikvtest/pipelineddmltest/BUILD.bazel index 6a51a7e57dcb4..18c9dd1b214a7 100644 --- a/tests/realtikvtest/pipelineddmltest/BUILD.bazel +++ b/tests/realtikvtest/pipelineddmltest/BUILD.bazel @@ -13,6 +13,7 @@ go_test( "//pkg/config", "//pkg/kv", "//pkg/sessionctx/binloginfo", + "//pkg/sessionctx/variable", "//pkg/testkit", "//tests/realtikvtest", "@com_github_pingcap_failpoint//:failpoint", diff --git a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go index 00241ce8dcc61..ce72858933b47 100644 --- a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go +++ b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go @@ -26,6 +26,7 @@ import ( "github.com/pingcap/tidb/pkg/config" "github.com/pingcap/tidb/pkg/kv" "github.com/pingcap/tidb/pkg/sessionctx/binloginfo" + "github.com/pingcap/tidb/pkg/sessionctx/variable" "github.com/pingcap/tidb/pkg/testkit" "github.com/pingcap/tidb/tests/realtikvtest" "github.com/stretchr/testify/require" @@ -55,7 +56,7 @@ func TestVariable(t *testing.T) { func TestPipelinedDMLPositive(t *testing.T) { // the test is a little tricky, only when pipelined dml is enabled, the failpoint panics and the panic message will be returned as error // TODO: maybe save the pipelined DML usage into TxnInfo, so we can check from it. - require.NoError(t, failpoint.Enable("tikvclient/pipelinedCommitFail", `panic("pipelined memdb is be enabled")`)) + require.NoError(t, failpoint.Enable("tikvclient/pipelinedCommitFail", `panic("pipelined memdb is enabled")`)) defer func() { require.NoError(t, failpoint.Disable("tikvclient/pipelinedCommitFail")) }() @@ -93,7 +94,7 @@ func TestPipelinedDMLPositive(t *testing.T) { return err }) require.Error(t, err, stmt) - require.True(t, strings.Contains(err.Error(), "pipelined memdb is be enabled"), err.Error(), stmt) + require.True(t, strings.Contains(err.Error(), "pipelined memdb is enabled"), err.Error(), stmt) // binary protocol ctx := context.Background() parsedStmts, err := tk.Session().Parse(ctx, stmt) @@ -103,7 +104,7 @@ func TestPipelinedDMLPositive(t *testing.T) { return err }) require.Error(t, err, stmt) - require.True(t, strings.Contains(err.Error(), "pipelined memdb is be enabled"), err.Error(), stmt) + require.True(t, strings.Contains(err.Error(), "pipelined memdb is enabled"), err.Error(), stmt) } } @@ -127,6 +128,7 @@ func TestPipelinedDMLNegative(t *testing.T) { // not in auto-commit txn tk.MustExec("set session tidb_dml_type = bulk") tk.MustExec("begin") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can only be used for auto-commit INSERT, REPLACE, UPDATE or DELETE. Fallback to standard mode.") tk.MustExec("insert into t values(2, 2)") tk.MustExec("commit") @@ -137,16 +139,19 @@ func TestPipelinedDMLNegative(t *testing.T) { config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(origPessimisticAutoCommit) }() tk.MustExec("insert into t values(3, 3)") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode.") config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(false) // binlog is enabled tk.Session().GetSessionVars().BinlogClient = binloginfo.MockPumpsClient(&testkit.MockPumpClient{}) tk.MustExec("insert into t values(4, 4)") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode.") tk.Session().GetSessionVars().BinlogClient = nil // in a running txn tk.MustExec("set session tidb_dml_type = standard") tk.MustExec("begin") + // the warning is produced for the begin stmt. tk.MustExec("set session tidb_dml_type = bulk") // turn on bulk dml in a txn doesn't effect the current txn. tk.MustExec("insert into t values(5, 5)") tk.MustExec("commit") @@ -155,9 +160,20 @@ func TestPipelinedDMLNegative(t *testing.T) { tk.Session().GetSessionVars().InRestrictedSQL = true tk.MustExec("insert into t values(6, 6)") tk.Session().GetSessionVars().InRestrictedSQL = false + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used for internal SQL. Fallback to standard mode.") // it's a read statement tk.MustQuery("select * from t").Sort().Check(testkit.Rows("1 1", "2 2", "3 3", "4 4", "5 5", "6 6")) + + // for deprecated batch-dml + tk.Session().GetSessionVars().BatchDelete = true + tk.Session().GetSessionVars().DMLBatchSize = 1 + variable.EnableBatchDML.Store(true) + tk.MustExec("insert into t values(7, 7)") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with the deprecated Batch DML. Fallback to standard mode.") + tk.Session().GetSessionVars().BatchDelete = false + tk.Session().GetSessionVars().DMLBatchSize = 0 + variable.EnableBatchDML.Store(false) } func compareTables(t *testing.T, tk *testkit.TestKit, t1, t2 string) { From 808fc29691ff2cdcf96b490f36bce52b7fd8e783 Mon Sep 17 00:00:00 2001 From: ekexium Date: Tue, 12 Mar 2024 18:49:04 +0800 Subject: [PATCH 2/6] style: fix lint and typo Signed-off-by: ekexium --- pkg/session/session.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/session/session.go b/pkg/session/session.go index eca25397e1619..29ebd64515a6d 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -3818,7 +3818,7 @@ func (s *session) PrepareTSFuture(ctx context.Context, future oracle.Future, sco future: future, store: s.store, txnScope: scope, - pipelined: s.usePipeilnedDMLorWarn(), + pipelined: s.usePipelinedDmlOrWarn(), }) return nil } @@ -4291,8 +4291,8 @@ func (s *session) NewStmtIndexUsageCollector() *indexusage.StmtIndexUsageCollect return indexusage.NewStmtIndexUsageCollector(s.idxUsageCollector) } -// usePipeilnedDMLorWarn returns the current statement can be executed as a pipelined DML. -func (s *session) usePipeilnedDMLorWarn() bool { +// usePipelinedDmlOrWarn returns the current statement can be executed as a pipelined DML. +func (s *session) usePipelinedDmlOrWarn() bool { if !s.sessionVars.BulkDMLEnabled { return false } @@ -4302,31 +4302,31 @@ func (s *session) usePipeilnedDMLorWarn() bool { } vars := s.GetSessionVars() if (vars.BatchCommit || vars.BatchInsert || vars.BatchDelete) && vars.DMLBatchSize > 0 && variable.EnableBatchDML.Load() { - stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used with the deprecated Batch DML. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used with the deprecated Batch DML. Fallback to standard mode")) return false } if vars.BinlogClient != nil { - stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode")) return false } if !(stmtCtx.InInsertStmt || stmtCtx.InDeleteStmt || stmtCtx.InUpdateStmt) { - stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used for auto-commit INSERT, REPLACE, UPDATE or DELETE. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used for auto-commit INSERT, REPLACE, UPDATE or DELETE. Fallback to standard mode")) return false } if s.isInternal() { - stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used for internal SQL. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used for internal SQL. Fallback to standard mode")) return false } if vars.InTxn() { - stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in transaction. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in transaction. Fallback to standard mode")) return false } if !vars.IsAutocommit() { - stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used in autocommit mode. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used in autocommit mode. Fallback to standard mode")) return false } if config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() { - stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode.")) + stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode")) return false } return true From ba891dc80d9c6cd5f293c8aaef79c0f587fa84c0 Mon Sep 17 00:00:00 2001 From: ekexium Date: Wed, 13 Mar 2024 13:35:56 +0800 Subject: [PATCH 3/6] test: fix lint Signed-off-by: ekexium --- .../realtikvtest/pipelineddmltest/pipelineddml_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go index ce72858933b47..2eafad42c2c77 100644 --- a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go +++ b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go @@ -128,7 +128,7 @@ func TestPipelinedDMLNegative(t *testing.T) { // not in auto-commit txn tk.MustExec("set session tidb_dml_type = bulk") tk.MustExec("begin") - tk.MustQuery("show warnings").CheckContain("Pipelined DML can only be used for auto-commit INSERT, REPLACE, UPDATE or DELETE. Fallback to standard mode.") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can only be used for auto-commit INSERT, REPLACE, UPDATE or DELETE. Fallback to standard mode") tk.MustExec("insert into t values(2, 2)") tk.MustExec("commit") @@ -139,13 +139,13 @@ func TestPipelinedDMLNegative(t *testing.T) { config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(origPessimisticAutoCommit) }() tk.MustExec("insert into t values(3, 3)") - tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode.") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode") config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(false) // binlog is enabled tk.Session().GetSessionVars().BinlogClient = binloginfo.MockPumpsClient(&testkit.MockPumpClient{}) tk.MustExec("insert into t values(4, 4)") - tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode.") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode") tk.Session().GetSessionVars().BinlogClient = nil // in a running txn @@ -160,7 +160,7 @@ func TestPipelinedDMLNegative(t *testing.T) { tk.Session().GetSessionVars().InRestrictedSQL = true tk.MustExec("insert into t values(6, 6)") tk.Session().GetSessionVars().InRestrictedSQL = false - tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used for internal SQL. Fallback to standard mode.") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used for internal SQL. Fallback to standard mode") // it's a read statement tk.MustQuery("select * from t").Sort().Check(testkit.Rows("1 1", "2 2", "3 3", "4 4", "5 5", "6 6")) @@ -170,7 +170,7 @@ func TestPipelinedDMLNegative(t *testing.T) { tk.Session().GetSessionVars().DMLBatchSize = 1 variable.EnableBatchDML.Store(true) tk.MustExec("insert into t values(7, 7)") - tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with the deprecated Batch DML. Fallback to standard mode.") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with the deprecated Batch DML. Fallback to standard mode") tk.Session().GetSessionVars().BatchDelete = false tk.Session().GetSessionVars().DMLBatchSize = 0 variable.EnableBatchDML.Store(false) From 47f2d3727c403d46d41b406ea1bb741ffec96bdb Mon Sep 17 00:00:00 2001 From: ekexium Date: Wed, 13 Mar 2024 13:59:32 +0800 Subject: [PATCH 4/6] test: explain and explain analyze Signed-off-by: ekexium --- .../pipelineddmltest/pipelineddml_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go index 2eafad42c2c77..0c7d7520c3605 100644 --- a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go +++ b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go @@ -151,8 +151,8 @@ func TestPipelinedDMLNegative(t *testing.T) { // in a running txn tk.MustExec("set session tidb_dml_type = standard") tk.MustExec("begin") - // the warning is produced for the begin stmt. - tk.MustExec("set session tidb_dml_type = bulk") // turn on bulk dml in a txn doesn't effect the current txn. + // turn on bulk dml in a txn doesn't affect the current txn. + tk.MustExec("set session tidb_dml_type = bulk") tk.MustExec("insert into t values(5, 5)") tk.MustExec("commit") @@ -174,6 +174,14 @@ func TestPipelinedDMLNegative(t *testing.T) { tk.Session().GetSessionVars().BatchDelete = false tk.Session().GetSessionVars().DMLBatchSize = 0 variable.EnableBatchDML.Store(false) + + // for explain and explain analyze + tk.Session().GetSessionVars().BinlogClient = binloginfo.MockPumpsClient(&testkit.MockPumpClient{}) + tk.MustExec("explain insert into t values(8, 8)") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode") + tk.MustExec("explain analyze insert into t values(9, 9)") + tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used with Binlog: BinlogClient != nil. Fallback to standard mode") + tk.Session().GetSessionVars().BinlogClient = nil } func compareTables(t *testing.T, tk *testkit.TestKit, t1, t2 string) { From 8c41cd451839efae6699a5249bedd2216cdff976 Mon Sep 17 00:00:00 2001 From: ekexium Date: Wed, 13 Mar 2024 16:19:33 +0800 Subject: [PATCH 5/6] feat: tidb_dml_type=bulk will override the pessimistic-auto-commit config Signed-off-by: ekexium --- pkg/planner/core/point_get_plan.go | 3 +- pkg/session/session.go | 13 +++++++-- .../pipelineddmltest/pipelineddml_test.go | 29 ++++++++++++------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/pkg/planner/core/point_get_plan.go b/pkg/planner/core/point_get_plan.go index d09672ae67c63..fc9766d8f92b0 100644 --- a/pkg/planner/core/point_get_plan.go +++ b/pkg/planner/core/point_get_plan.go @@ -635,7 +635,8 @@ func getLockWaitTime(ctx PlanContext, lockInfo *ast.SelectLockInfo) (lock bool, // autocommit to 0. If autocommit is enabled, the rows matching the specification are not locked. // See https://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html sessVars := ctx.GetSessionVars() - if !sessVars.IsAutocommit() || sessVars.InTxn() || config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() { + if !sessVars.IsAutocommit() || sessVars.InTxn() || (config.GetGlobalConfig(). + PessimisticTxn.PessimisticAutoCommit.Load() && !sessVars.BulkDMLEnabled) { lock = true waitTime = sessVars.LockWaitTimeout if lockInfo.LockType == ast.SelectLockForUpdateWaitN { diff --git a/pkg/session/session.go b/pkg/session/session.go index 29ebd64515a6d..71201b991f365 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -3782,7 +3782,8 @@ func (s *session) PrepareTxnCtx(ctx context.Context) error { } txnMode := ast.Optimistic - if !s.sessionVars.IsAutocommit() || config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() { + if !s.sessionVars.IsAutocommit() || (config.GetGlobalConfig().PessimisticTxn. + PessimisticAutoCommit.Load() && !s.GetSessionVars().BulkDMLEnabled) { if s.sessionVars.TxnMode == ast.Pessimistic { txnMode = ast.Pessimistic } @@ -4325,9 +4326,15 @@ func (s *session) usePipelinedDmlOrWarn() bool { stmtCtx.AppendWarning(errors.New("Pipelined DML can only be used in autocommit mode. Fallback to standard mode")) return false } + + // tidb_dml_type=bulk will invalidate the config pessimistic-auto-commit. + // The behavior is as if the config is set to false. But we generate a warning for it. if config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() { - stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode")) - return false + stmtCtx.AppendWarning( + errors.New( + "pessimistic-auto-commit config is ignored in favor of Pipelined DML", + ), + ) } return true } diff --git a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go index 0c7d7520c3605..02fb93ebb9346 100644 --- a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go +++ b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go @@ -106,6 +106,23 @@ func TestPipelinedDMLPositive(t *testing.T) { require.Error(t, err, stmt) require.True(t, strings.Contains(err.Error(), "pipelined memdb is enabled"), err.Error(), stmt) } + + // pessimistic-auto-commit is on + origPessimisticAutoCommit := config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() + config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(true) + defer func() { + config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(origPessimisticAutoCommit) + }() + err := panicToErr( + func() error { + _, err := tk.Exec("insert into t values(3, 3)") + return err + }, + ) + require.Error(t, err) + require.True(t, strings.Contains(err.Error(), "pipelined memdb is enabled"), err.Error()) + tk.MustQuery("show warnings").CheckContain("pessimistic-auto-commit config is ignored in favor of Pipelined DML") + config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(false) } func TestPipelinedDMLNegative(t *testing.T) { @@ -132,16 +149,6 @@ func TestPipelinedDMLNegative(t *testing.T) { tk.MustExec("insert into t values(2, 2)") tk.MustExec("commit") - // pessimistic-auto-commit is on - origPessimisticAutoCommit := config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Load() - config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(true) - defer func() { - config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(origPessimisticAutoCommit) - }() - tk.MustExec("insert into t values(3, 3)") - tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used in pessimistic autocommit mode. Fallback to standard mode") - config.GetGlobalConfig().PessimisticTxn.PessimisticAutoCommit.Store(false) - // binlog is enabled tk.Session().GetSessionVars().BinlogClient = binloginfo.MockPumpsClient(&testkit.MockPumpClient{}) tk.MustExec("insert into t values(4, 4)") @@ -163,7 +170,7 @@ func TestPipelinedDMLNegative(t *testing.T) { tk.MustQuery("show warnings").CheckContain("Pipelined DML can not be used for internal SQL. Fallback to standard mode") // it's a read statement - tk.MustQuery("select * from t").Sort().Check(testkit.Rows("1 1", "2 2", "3 3", "4 4", "5 5", "6 6")) + tk.MustQuery("select * from t").Sort().Check(testkit.Rows("1 1", "2 2", "4 4", "5 5", "6 6")) // for deprecated batch-dml tk.Session().GetSessionVars().BatchDelete = true From 8d8b333f3a44b404efbdf23e28d0254dc5939db9 Mon Sep 17 00:00:00 2001 From: ekexium Date: Wed, 13 Mar 2024 17:41:46 +0800 Subject: [PATCH 6/6] test: update comments Signed-off-by: ekexium --- tests/realtikvtest/pipelineddmltest/pipelineddml_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go index 02fb93ebb9346..847ef64f421a5 100644 --- a/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go +++ b/tests/realtikvtest/pipelineddmltest/pipelineddml_test.go @@ -48,7 +48,7 @@ func TestVariable(t *testing.T) { // We limit this feature only for cases meet all the following conditions: // 1. tidb_dml_type is set to bulk for the current session // 2. the session is running an auto-commit txn -// 3. pessimistic-auto-commit is turned off +// 3. (removed, it is now overridden by tidb_dml_type=bulk) pessimistic-auto-commit ~~if off~~ // 4. binlog is disabled // 5. the statement is not running inside a transaction // 6. the session is external used