Skip to content

Commit

Permalink
flashback: fix realtikvtest/flashbacktest test cases (#52899) (#55288)
Browse files Browse the repository at this point in the history
close #52898
  • Loading branch information
ti-chi-bot authored Aug 8, 2024
1 parent 370bd5a commit f29a4ea
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,14 @@ bazel_pipelineddmltest: failpoint-enable bazel_ci_simple_prepare
-- //tests/realtikvtest/pipelineddmltest/...
./build/jenkins_collect_coverage.sh

# on timeout, bazel won't print log sometimes, so we use --test_output=all to print log always
.PHONY: bazel_flashbacktest
bazel_flashbacktest: 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/flashbacktest/...
./build/jenkins_collect_coverage.sh

.PHONY: bazel_lint
bazel_lint: bazel_prepare
bazel build //... --//build:with_nogo_flag=true
Expand Down
33 changes: 19 additions & 14 deletions pkg/statistics/handle/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,25 @@ func (h *ddlHandlerImpl) HandleDDLEvent(t *util.DDLEvent) error {
return err
}
defer h.statsHandler.SPool().Put(sctx)
if isSysDB, err := t.IsMemOrSysDB(sctx.(sessionctx.Context)); err != nil {
return err
} else if isSysDB {
// EXCHANGE PARTITION EVENT NOTES:
// 1. When a partition is exchanged with a system table, we need to adjust the global statistics
// based on the count delta and modify count delta. However, due to the involvement of the system table,
// a complete update of the global statistics is not feasible. Therefore, we bypass the statistics update
// for the table in this scenario. Despite this, the table id still changes, so the statistics for the
// system table will still be visible.
// 2. If the system table is a partitioned table, we will update the global statistics for the partitioned table.
// It is rare to exchange a partition from a system table, so we can ignore this case. In this case,
// the system table will have statistics, but this is not a significant issue.
logutil.StatsLogger().Info("Skip handle system database ddl event", zap.Stringer("event", t))
return nil

// ActionFlashbackCluster will not create any new stats info
// and it's SchemaID alwayws equals to 0, so skip check it.
if t.GetType() != model.ActionFlashbackCluster {
if isSysDB, err := t.IsMemOrSysDB(sctx.(sessionctx.Context)); err != nil {
return err
} else if isSysDB {
// EXCHANGE PARTITION EVENT NOTES:
// 1. When a partition is exchanged with a system table, we need to adjust the global statistics
// based on the count delta and modify count delta. However, due to the involvement of the system table,
// a complete update of the global statistics is not feasible. Therefore, we bypass the statistics update
// for the table in this scenario. Despite this, the table id still changes, so the statistics for the
// system table will still be visible.
// 2. If the system table is a partitioned table, we will update the global statistics for the partitioned table.
// It is rare to exchange a partition from a system table, so we can ignore this case. In this case,
// the system table will have statistics, but this is not a significant issue.
logutil.StatsLogger().Info("Skip handle system database ddl event", zap.Stringer("event", t))
return nil
}
}
logutil.StatsLogger().Info("Handle ddl event", zap.Stringer("event", t))

Expand Down
1 change: 1 addition & 0 deletions tests/realtikvtest/flashbacktest/flashback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ func TestFlashbackSequence(t *testing.T) {
require.Equal(t, res[0][0], "101")

require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/ddl/injectSafeTS"))
tk.MustExec("drop sequence seq")
}
}

Expand Down

0 comments on commit f29a4ea

Please sign in to comment.