Skip to content

Commit

Permalink
txn: fix the warnings in pipelined dml (#51867)
Browse files Browse the repository at this point in the history
ref #50215
  • Loading branch information
you06 committed Mar 19, 2024
1 parent 24e8333 commit 9b6db9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,13 @@ bazel_importintotest4: failpoint-enable bazel_ci_simple_prepare
-- //tests/realtikvtest/importintotest4/...
./build/jenkins_collect_coverage.sh

# on timeout, bazel won't print log sometimes, so we use --test_output=all to print log always
bazel_pipelineddmltest: failpoint-enable bazel_ci_simple_prepare
bazel $(BAZEL_GLOBAL_CONFIG) coverage $(BAZEL_CMD_CONFIG) $(BAZEL_INSTRUMENTATION_FILTER) --test_output=all --test_arg=-with-real-tikv --define gotags=deadlock,intest \
--@io_bazel_rules_go//go/config:cover_format=go_cover \
-- //tests/realtikvtest/pipelineddmltest/...
./build/jenkins_collect_coverage.sh

bazel_lint: bazel_prepare
bazel build //... --//build:with_nogo_flag=true

Expand Down
6 changes: 1 addition & 5 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4367,18 +4367,14 @@ func (s *session) usePipelinedDmlOrWarn() bool {
stmtCtx.AppendWarning(errors.New("Pipelined DML can not be used on sequence. Fallback to standard mode"))
return false
}
if len(tbl.Meta().ForeignKeys) > 0 && vars.ForeignKeyChecks {
if vars.ForeignKeyChecks && (len(tbl.Meta().ForeignKeys) > 0 || len(is.GetTableReferredForeignKeys(t.DB, t.Table)) > 0) {
stmtCtx.AppendWarning(
errors.New(
"Pipelined DML can not be used on table with foreign keys when foreign_key_checks = ON. Fallback to standard mode",
),
)
return false
}
referredFKs := is.GetTableReferredForeignKeys(t.DB, t.Table)
if len(referredFKs) > 0 {
return false
}
if tbl.Meta().TempTableType != model.TempTableNone {
stmtCtx.AppendWarning(
errors.New(
Expand Down
3 changes: 2 additions & 1 deletion tests/realtikvtest/pipelineddmltest/pipelineddml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ func TestPipelinedDMLNegative(t *testing.T) {
// 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")
// explain is read-only, so it doesn't warn.
tk.MustQuery("show warnings").Check(testkit.Rows())
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
Expand Down

0 comments on commit 9b6db9d

Please sign in to comment.