Skip to content

Commit

Permalink
ddl: apply common handle to index reorganization (pingcap#17906)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta authored Jun 16, 2020
1 parent b8fb4b0 commit 6c305e2
Show file tree
Hide file tree
Showing 14 changed files with 560 additions and 231 deletions.
20 changes: 10 additions & 10 deletions ddl/db_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1232,14 +1232,14 @@ func (s *testIntegrationSuite3) TestMultiRegionGetTableEndHandle(c *C) {
// Split the table.
s.cluster.SplitTable(tblID, 100)

maxID, emptyTable := getMaxTableRowID(testCtx, s.store)
maxHandle, emptyTable := getMaxTableHandle(testCtx, s.store)
c.Assert(emptyTable, IsFalse)
c.Assert(maxID, Equals, int64(1000))
c.Assert(maxHandle, Equals, kv.IntHandle(1000))

tk.MustExec("insert into t values(10000, 1000)")
maxID, emptyTable = getMaxTableRowID(testCtx, s.store)
maxHandle, emptyTable = getMaxTableHandle(testCtx, s.store)
c.Assert(emptyTable, IsFalse)
c.Assert(maxID, Equals, int64(1001))
c.Assert(maxHandle, Equals, kv.IntHandle(1001))
}

type testMaxTableRowIDContext struct {
Expand All @@ -1256,22 +1256,22 @@ func newTestMaxTableRowIDContext(c *C, d ddl.DDL, tbl table.Table) *testMaxTable
}
}

func getMaxTableRowID(ctx *testMaxTableRowIDContext, store kv.Storage) (int64, bool) {
func getMaxTableHandle(ctx *testMaxTableRowIDContext, store kv.Storage) (kv.Handle, bool) {
c := ctx.c
d := ctx.d
tbl := ctx.tbl
curVer, err := store.CurrentVersion()
c.Assert(err, IsNil)
maxID, emptyTable, err := d.GetTableMaxRowID(curVer.Ver, tbl.(table.PhysicalTable))
maxHandle, emptyTable, err := d.GetTableMaxHandle(curVer.Ver, tbl.(table.PhysicalTable))
c.Assert(err, IsNil)
return maxID, emptyTable
return maxHandle, emptyTable
}

func checkGetMaxTableRowID(ctx *testMaxTableRowIDContext, store kv.Storage, expectEmpty bool, expectMaxID int64) {
func checkGetMaxTableRowID(ctx *testMaxTableRowIDContext, store kv.Storage, expectEmpty bool, expectMaxHandle kv.Handle) {
c := ctx.c
maxID, emptyTable := getMaxTableRowID(ctx, store)
maxHandle, emptyTable := getMaxTableHandle(ctx, store)
c.Assert(emptyTable, Equals, expectEmpty)
c.Assert(maxID, Equals, expectMaxID)
c.Assert(maxHandle, testutil.HandleEquals, expectMaxHandle)
}

func getHistoryDDLJob(store kv.Storage, id int64) (*model.Job, error) {
Expand Down
2 changes: 1 addition & 1 deletion ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type DDL interface {
// GetID gets the ddl ID.
GetID() string
// GetTableMaxRowID gets the max row ID of a normal table or a partition.
GetTableMaxRowID(startTS uint64, tbl table.PhysicalTable) (int64, bool, error)
GetTableMaxHandle(startTS uint64, tbl table.PhysicalTable) (kv.Handle, bool, error)
// SetBinlogClient sets the binlog client for DDL worker. It's exported for testing.
SetBinlogClient(*pumpcli.PumpsClient)
// GetHook gets the hook. It's exported for testing.
Expand Down
8 changes: 4 additions & 4 deletions ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ import (
"github.com/pingcap/tidb/util/admin"
"github.com/pingcap/tidb/util/mock"
"github.com/pingcap/tidb/util/sqlexec"
"github.com/pingcap/tidb/util/testutil"
)

var _ = Suite(&testDDLSuite{})
var _ = Suite(&testDDLSerialSuite{})

type testDDLSuite struct{}
type testDDLSuite struct {
testutil.CommonHandleSuite
}
type testDDLSerialSuite struct{}

const testLease = 5 * time.Millisecond
Expand All @@ -50,9 +53,6 @@ func (s *testDDLSerialSuite) SetUpSuite(c *C) {
s.testRunWorker(c)
}

func (s *testDDLSuite) TearDownSuite(c *C) {
}

func (s *testDDLSuite) TestCheckOwner(c *C) {
store := testCreateStore(c, "test_owner")
defer store.Close()
Expand Down
154 changes: 88 additions & 66 deletions ddl/index.go

Large diffs are not rendered by default.

Loading

0 comments on commit 6c305e2

Please sign in to comment.