Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/statistics/handle/ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ go_test(
timeout = "short",
srcs = ["ddl_test.go"],
flaky = True,
shard_count = 20,
shard_count = 21,
deps = [
":ddl",
"//pkg/ddl/notifier",
Expand Down
13 changes: 12 additions & 1 deletion pkg/statistics/handle/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import (
"github.com/pingcap/tidb/pkg/ddl/notifier"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/statistics/handle/lockstats"
statslogutil "github.com/pingcap/tidb/pkg/statistics/handle/logutil"
"github.com/pingcap/tidb/pkg/statistics/handle/storage"
"github.com/pingcap/tidb/pkg/statistics/handle/types"
"github.com/pingcap/tidb/pkg/statistics/handle/util"
"go.uber.org/zap"
)

type ddlHandlerImpl struct {
Expand All @@ -48,7 +50,16 @@ func NewDDLHandler(

// HandleDDLEvent begins to process a ddl task.
func (h *ddlHandlerImpl) HandleDDLEvent(ctx context.Context, sctx sessionctx.Context, s *notifier.SchemaChangeEvent) error {
return h.sub.handle(ctx, sctx, s)
// Ideally, we shouldn't allow any errors to be ignored, but for now, some queries can fail.
// Temporarily ignore the error and we need to check all queries to ensure they are correct.
if err := h.sub.handle(ctx, sctx, s); err != nil {
statslogutil.StatsLogger().Warn(
"failed to handle DDL event",
zap.String("event", s.String()),
zap.Error(err),
)
}
return nil
}

// DDLEventCh returns ddl events channel in handle.
Expand Down
15 changes: 15 additions & 0 deletions pkg/statistics/handle/ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,3 +1380,18 @@ func TestExchangePartition(t *testing.T) {
require.Equal(t, int64(200), count)
require.Equal(t, int64(200), modifyCount)
}

func TestDumpStatsDeltaBeforeHandleDDLEvent(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t (c1 int)")
// Insert some data.
tk.MustExec("insert into t values (1), (2), (3)")
h := dom.StatsHandle()
require.NoError(t, h.DumpStatsDeltaToKV(true))
// Find the DDL event.
event := findEvent(h.DDLEventCh(), model.ActionCreateTable)
err := statstestutil.HandleDDLEventWithTxn(h, event)
require.NoError(t, err)
}