Skip to content

Commit

Permalink
Merge branch 'master' into ddl-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored Jan 24, 2022
2 parents 7a24e76 + 416acd0 commit 6f673cf
Show file tree
Hide file tree
Showing 80 changed files with 1,745 additions and 638 deletions.
11 changes: 7 additions & 4 deletions bindinfo/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ func (h *BindHandle) Update(fullLoad bool) (err error) {
continue
}
hash, meta, err := h.newBindRecord(row)
if err != nil {
logutil.BgLogger().Debug("[sql-bind] failed to generate bind record from data row", zap.Error(err))
continue
}

// Update lastUpdateTime to the newest one.
// Even if this one is an invalid bind.
if meta.Bindings[0].UpdateTime.Compare(lastUpdateTime) > 0 {
lastUpdateTime = meta.Bindings[0].UpdateTime
}

if err != nil {
logutil.BgLogger().Debug("[sql-bind] failed to generate bind record from data row", zap.Error(err))
continue
}

oldRecord := newCache.getBindRecord(hash, meta.OriginalSQL, meta.Db)
newRecord := merge(oldRecord, meta).removeDeletedBindings()
if len(newRecord.Bindings) > 0 {
Expand Down
25 changes: 25 additions & 0 deletions bindinfo/handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,31 @@ func TestBindingLastUpdateTime(t *testing.T) {
tk.MustQuery(`show global status like 'last_plan_binding_update_time';`).Check(testkit.Rows())
}

func TestBindingLastUpdateTimeWithInvalidBind(t *testing.T) {
store, _, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()

tk := testkit.NewTestKit(t, store)

rows0 := tk.MustQuery("show status like 'last_plan_binding_update_time';").Rows()
updateTime0 := rows0[0][1]
require.Equal(t, updateTime0, "0000-00-00 00:00:00")

tk.MustExec("insert into mysql.bind_info values('select * from `test` . `t`', 'select * from `test` . `t` use index(`idx`)', 'test', 'using', '2000-01-01 09:00:00', '2000-01-01 09:00:00', '', '','" +
bindinfo.Manual + "')")
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
tk.MustExec("admin reload bindings;")

rows1 := tk.MustQuery("show status like 'last_plan_binding_update_time';").Rows()
updateTime1 := rows1[0][1]
require.Equal(t, updateTime1, "2000-01-01 09:00:00.000")

rows2 := tk.MustQuery("show global bindings").Rows()
require.Equal(t, len(rows2), 0)
}

func TestBindParse(t *testing.T) {
store, _, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
Expand Down
2 changes: 1 addition & 1 deletion br/cmd/tidb-lightning-ctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func checkpointDump(ctx context.Context, cfg *config.Config, dumpFolder string)
}
defer cpdb.Close()

if err := os.MkdirAll(dumpFolder, 0o755); err != nil {
if err := os.MkdirAll(dumpFolder, 0o750); err != nil {
return errors.Trace(err)
}

Expand Down
Loading

0 comments on commit 6f673cf

Please sign in to comment.