Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl, meta: allow increasing auto_random bits #17423

Merged
merged 28 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2055362
ddl, meta: allow increasing auto_random bits
tangenta May 26, 2020
82997c2
fix linter
tangenta May 27, 2020
944b21e
Merge branch 'master' into autorand-increasing
AilinKid May 27, 2020
09f694d
Merge branch 'master' into autorand-increasing
AilinKid May 27, 2020
0bd0375
fix ci
tangenta May 27, 2020
efcc8b4
add comments about counting max shard bits
tangenta May 27, 2020
609660b
prevent update meta key concurrently
tangenta Jun 2, 2020
d74b7b4
Merge remote-tracking branch 'upstream/master' into autorand-increasing
tangenta Jun 2, 2020
a989adf
sort import order
tangenta Jun 2, 2020
69487c1
make fmt
tangenta Jun 2, 2020
eb37b3f
fix integration test
tangenta Jun 2, 2020
28b399f
fix table name conflict in test
tangenta Jun 2, 2020
7727609
Merge branch 'master' into autorand-increasing
bb7133 Jun 2, 2020
1df6f17
Merge branch 'master' into autorand-increasing
AilinKid Jun 3, 2020
69f7512
autoid: polish auto_random error messages
tangenta Jun 4, 2020
2b22027
Merge remote-tracking branch 'upstream/master' into autorand-increasing
tangenta Jun 4, 2020
28da208
unistore: move coprocessor logic from unistore repo to tidb repo (#17…
coocood Jun 4, 2020
8842281
unistore: move coprocessor analyze logic to tidb repo (#17661)
coocood Jun 4, 2020
e6d7b35
unistore: update unistore version to use tidb cophandler (#17666)
coocood Jun 4, 2020
f29026f
ddl: polish the comment in checkAutoRandom
tangenta Jun 5, 2020
3a96e84
Merge remote-tracking branch 'upstream/master' into autorand-increasing
tangenta Jun 5, 2020
41ba129
cancel job when it encounter error
tangenta Jun 8, 2020
574c5c1
Merge remote-tracking branch 'upstream/master' into autorand-increasing
tangenta Jun 8, 2020
69560cf
not to cancel the job when an error occurred
tangenta Jun 9, 2020
6905f63
address comments
tangenta Jun 9, 2020
1196ac4
address comments
tangenta Jun 9, 2020
05556e2
address comment
tangenta Jun 9, 2020
19ef062
Merge branch 'master' into autorand-increasing
tangenta Jun 9, 2020
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
45 changes: 42 additions & 3 deletions ddl/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ package ddl

import (
"fmt"
"math/bits"
"strings"
"sync/atomic"
"time"

"github.com/cznic/mathutil"
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/parser/ast"
Expand All @@ -27,6 +29,7 @@ import (
"github.com/pingcap/tidb/ddl/util"
"github.com/pingcap/tidb/infoschema"
"github.com/pingcap/tidb/meta"
"github.com/pingcap/tidb/meta/autoid"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/types"
Expand Down Expand Up @@ -585,17 +588,20 @@ func (w *worker) onModifyColumn(t *meta.Meta, job *model.Job) (ver int64, _ erro
oldColName := &model.CIStr{}
pos := &ast.ColumnPosition{}
var modifyColumnTp byte
err := job.DecodeArgs(newCol, oldColName, pos, &modifyColumnTp)
var updatedAutoRandomBits uint64
err := job.DecodeArgs(newCol, oldColName, pos, &modifyColumnTp, &updatedAutoRandomBits)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this DDL operation needs to be handled during the rolling upgrade, there may be compatibility issues.

Copy link
Contributor Author

@tangenta tangenta Jun 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If modifying auto_random bits is really necessary during updates, we need to consider two cases:

  • The DDL owner is an old-version TiDB: auto_random shard bits remain unchanged(but DDL successfully executed).
  • The DDL owner is a new-version TiDB: the job arguments mismatch, throwing an error.

I think none of them can lead to data inconsistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DDL owner is an old-version TiDB: auto_random shard bits remain unchanged(but DDL successfully executed).

It will not cause data inconsistency, but it will confuse the user, the execution is successful, but the function is not successful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I add job arguments to DDL jobs without affecting the rolling update?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, I don’t seem to have any good methods other than the newly added types. Or you ask if the DBA can accept this situation

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can write this in the documents.

if err != nil {
job.State = model.JobStateCancelled
return ver, errors.Trace(err)
}

return w.doModifyColumn(t, job, newCol, oldColName, pos, modifyColumnTp)
return w.doModifyColumn(t, job, newCol, oldColName, pos, modifyColumnTp, updatedAutoRandomBits)
}

// doModifyColumn updates the column information and reorders all columns.
func (w *worker) doModifyColumn(t *meta.Meta, job *model.Job, newCol *model.ColumnInfo, oldName *model.CIStr, pos *ast.ColumnPosition, modifyColumnTp byte) (ver int64, _ error) {
func (w *worker) doModifyColumn(
t *meta.Meta, job *model.Job, newCol *model.ColumnInfo, oldName *model.CIStr,
pos *ast.ColumnPosition, modifyColumnTp byte, newAutoRandBits uint64) (ver int64, _ error) {
dbInfo, err := checkSchemaExistAndCancelNotExistJob(t, job)
if err != nil {
return ver, errors.Trace(err)
Expand Down Expand Up @@ -637,6 +643,13 @@ func (w *worker) doModifyColumn(t *meta.Meta, job *model.Job, newCol *model.Colu
}
})

if newAutoRandBits > 0 {
tangenta marked this conversation as resolved.
Show resolved Hide resolved
if err := checkAndApplyNewAutoRandomBits(t, job.SchemaID, tblInfo, newCol, oldName, newAutoRandBits); err != nil {
job.State = model.JobStateRollingback
return ver, errors.Trace(err)
}
}

// Column from null to not null.
if !mysql.HasNotNullFlag(oldCol.Flag) && mysql.HasNotNullFlag(newCol.Flag) {
noPreventNullFlag := !mysql.HasPreventNullInsertFlag(oldCol.Flag)
Expand Down Expand Up @@ -727,6 +740,32 @@ func (w *worker) doModifyColumn(t *meta.Meta, job *model.Job, newCol *model.Colu
return ver, nil
}

func checkAndApplyNewAutoRandomBits(t *meta.Meta, schemaID int64, tblInfo *model.TableInfo,
newCol *model.ColumnInfo, oldName *model.CIStr, newAutoRandBits uint64) error {
newLayout := autoid.NewAutoRandomIDLayout(&newCol.FieldType, newAutoRandBits)

// GenAutoRandomID first to prevent concurrent update.
_, err := t.GenAutoRandomID(schemaID, tblInfo.ID, 1)
if err != nil {
return err
}
currentIncBitsVal, err := t.GetAutoRandomID(schemaID, tblInfo.ID)
AilinKid marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
tangenta marked this conversation as resolved.
Show resolved Hide resolved
return err
}
// Find the max number of available shard bits by
// counting leading zeros in current inc part of auto_random ID.
availableBits := bits.LeadingZeros64(uint64(currentIncBitsVal))
tangenta marked this conversation as resolved.
Show resolved Hide resolved
isOccupyingIncBits := newLayout.TypeBitsLength-newLayout.IncrementalBits > uint64(availableBits)
if isOccupyingIncBits {
availableBits := mathutil.Min(autoid.MaxAutoRandomBits, availableBits)
errMsg := fmt.Sprintf(autoid.AutoRandomOverflowErrMsg, availableBits, newAutoRandBits, oldName.O)
return ErrInvalidAutoRandom.GenWithStackByArgs(errMsg)
}
tblInfo.AutoRandomBits = newAutoRandBits
return nil
}

// checkForNullValue ensure there are no null values of the column of this table.
// `isDataTruncated` indicates whether the new field and the old field type are the same, in order to be compatible with mysql.
func checkForNullValue(ctx sessionctx.Context, isDataTruncated bool, schema, table, newCol model.CIStr, oldCols ...*model.ColumnInfo) error {
Expand Down
72 changes: 72 additions & 0 deletions ddl/column_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import (
"context"
"fmt"
"sync"
"sync/atomic"
"time"

. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/model"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/meta"
"github.com/pingcap/tidb/meta/autoid"
Expand Down Expand Up @@ -151,6 +153,76 @@ func (s *testColumnChangeSuite) TestColumnChange(c *C) {
s.testAddColumnNoDefault(c, ctx, d, tblInfo)
}

func (s *testColumnChangeSuite) TestModifyAutoRandColumnWithMetaKeyChanged(c *C) {
d := testNewDDLAndStart(
context.Background(),
c,
WithStore(s.store),
WithLease(testLease),
)
defer d.Stop()

ids, err := d.genGlobalIDs(1)
tableID := ids[0]
c.Assert(err, IsNil)
colInfo := &model.ColumnInfo{
Name: model.NewCIStr("a"),
Offset: 0,
State: model.StatePublic,
FieldType: *types.NewFieldType(mysql.TypeLonglong),
}
tblInfo := &model.TableInfo{
ID: tableID,
Name: model.NewCIStr("auto_random_table_name"),
Columns: []*model.ColumnInfo{colInfo},
AutoRandomBits: 5,
}
colInfo.ID = allocateColumnID(tblInfo)
ctx := testNewContext(d)
testCreateTable(c, ctx, d, s.dbInfo, tblInfo)

tc := &TestDDLCallback{}
var errCount int32 = 3
var genAutoRandErr error
tc.onJobRunBefore = func(job *model.Job) {
if atomic.LoadInt32(&errCount) > 0 && job.Type == model.ActionModifyColumn {
atomic.AddInt32(&errCount, -1)
genAutoRandErr = kv.RunInNewTxn(s.store, false, func(txn kv.Transaction) error {
t := meta.NewMeta(txn)
_, err1 := t.GenAutoRandomID(s.dbInfo.ID, tableID, 1)
tangenta marked this conversation as resolved.
Show resolved Hide resolved
return err1
})
}
}
d.SetHook(tc)
const newAutoRandomBits uint64 = 10
job := &model.Job{
SchemaID: s.dbInfo.ID,
TableID: tblInfo.ID,
SchemaName: s.dbInfo.Name.L,
Type: model.ActionModifyColumn,
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{colInfo, colInfo.Name, ast.ColumnPosition{}, 0, newAutoRandomBits},
}
err = d.doDDLJob(ctx, job)
c.Assert(err, IsNil)
c.Assert(errCount == 0, IsTrue)
c.Assert(genAutoRandErr, IsNil)
testCheckJobDone(c, d, job, true)
var newTbInfo *model.TableInfo
err = kv.RunInNewTxn(d.store, false, func(txn kv.Transaction) error {
t := meta.NewMeta(txn)
var err error
newTbInfo, err = t.GetTable(s.dbInfo.ID, tableID)
if err != nil {
return errors.Trace(err)
}
return nil
})
c.Assert(err, IsNil)
c.Assert(newTbInfo.AutoRandomBits, Equals, newAutoRandomBits)
}

func (s *testColumnChangeSuite) testAddColumnNoDefault(c *C, ctx sessionctx.Context, d *ddl, tblInfo *model.TableInfo) {
tc := &TestDDLCallback{}
// set up hook
Expand Down
45 changes: 29 additions & 16 deletions ddl/ddl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,8 @@ func (d *ddl) getModifiableColumnJob(ctx sessionctx.Context, ident ast.Ident, or
return nil, errors.Trace(err)
}

if err = checkAutoRandom(t.Meta(), col, specNewColumn); err != nil {
var newAutoRandBits uint64
if newAutoRandBits, err = checkAutoRandom(t.Meta(), col, specNewColumn); err != nil {
return nil, errors.Trace(err)
}

Expand All @@ -3294,7 +3295,7 @@ func (d *ddl) getModifiableColumnJob(ctx sessionctx.Context, ident ast.Ident, or
SchemaName: schema.Name.L,
Type: model.ActionModifyColumn,
BinlogInfo: &model.HistoryInfo{},
Args: []interface{}{&newCol, originalColName, spec.Position, modifyColumnTp},
Args: []interface{}{&newCol, originalColName, spec.Position, modifyColumnTp, newAutoRandBits},
}
return job, nil
}
Expand Down Expand Up @@ -3336,34 +3337,46 @@ func checkColumnWithIndexConstraint(tbInfo *model.TableInfo, originalCol, newCol
return nil
}

func checkAutoRandom(tableInfo *model.TableInfo, originCol *table.Column, specNewColumn *ast.ColumnDef) error {
func checkAutoRandom(tableInfo *model.TableInfo, originCol *table.Column, specNewColumn *ast.ColumnDef) (uint64, error) {
if !config.GetGlobalConfig().Experimental.AllowAutoRandom && containsColumnOption(specNewColumn, ast.ColumnOptionAutoRandom) {
return ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomExperimentalDisabledErrMsg)
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomExperimentalDisabledErrMsg)
}
// Disallow add/drop/modify actions on auto_random.
newAutoRandomBit, err := extractAutoRandomBitsFromColDef(specNewColumn)
// Disallow add/drop actions on auto_random.
oldRandBits := tableInfo.AutoRandomBits
newRandBits, err := extractAutoRandomBitsFromColDef(specNewColumn)
if err != nil {
return errors.Trace(err)
}
if tableInfo.AutoRandomBits != newAutoRandomBit {
return ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomAlterErrMsg)
return 0, errors.Trace(err)
}

if tableInfo.AutoRandomBits != 0 {
switch {
case oldRandBits == newRandBits:
break
case oldRandBits == 0 || newRandBits == 0:
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomAlterErrMsg)
case autoid.MaxAutoRandomBits < newRandBits:
errMsg := fmt.Sprintf(autoid.AutoRandomOverflowErrMsg,
autoid.MaxAutoRandomBits, newRandBits, specNewColumn.Name.Name.O)
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(errMsg)
case oldRandBits < newRandBits:
break // pass the check
tangenta marked this conversation as resolved.
Show resolved Hide resolved
case oldRandBits > newRandBits:
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomDecreaseBitErrMsg)
}

if oldRandBits != 0 {
// Disallow changing the column field type.
if originCol.Tp != specNewColumn.Tp.Tp {
return ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomModifyColTypeErrMsg)
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomModifyColTypeErrMsg)
}
// Disallow changing auto_increment on auto_random column.
if containsColumnOption(specNewColumn, ast.ColumnOptionAutoIncrement) != mysql.HasAutoIncrementFlag(originCol.Flag) {
return ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomIncompatibleWithAutoIncErrMsg)
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomIncompatibleWithAutoIncErrMsg)
}
// Disallow specifying a default value on auto_random column.
if containsColumnOption(specNewColumn, ast.ColumnOptionDefaultValue) {
return ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomIncompatibleWithDefaultValueErrMsg)
return 0, ErrInvalidAutoRandom.GenWithStackByArgs(autoid.AutoRandomIncompatibleWithDefaultValueErrMsg)
}
}
return nil
return newRandBits, nil
}

// ChangeColumn renames an existing column and modifies the column's definition,
Expand Down
47 changes: 43 additions & 4 deletions ddl/serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ func (s *testSerialSuite) TestAutoRandom(c *C) {
defer tk.MustExec("drop database if exists auto_random_db")
tk.MustExec("use auto_random_db")
tk.MustExec("drop table if exists t")
tk.MustExec("set @@allow_auto_random_explicit_insert = true")

assertInvalidAutoRandomErr := func(sql string, errMsg string, args ...interface{}) {
_, err := tk.Exec(sql)
Expand All @@ -847,10 +848,16 @@ func (s *testSerialSuite) TestAutoRandom(c *C) {
assertAlterValue := func(sql string) {
assertInvalidAutoRandomErr(sql, autoid.AutoRandomAlterErrMsg)
}
assertDecreaseBitErr := func(sql string) {
assertInvalidAutoRandomErr(sql, autoid.AutoRandomDecreaseBitErrMsg)
}
assertWithAutoInc := func(sql string) {
assertInvalidAutoRandomErr(sql, autoid.AutoRandomIncompatibleWithAutoIncErrMsg)
}
assertOverflow := func(sql, colName string, autoRandBits uint64) {
assertOverflow := func(sql, colName string, maxAutoRandBits, actualAutoRandBits uint64) {
assertInvalidAutoRandomErr(sql, autoid.AutoRandomOverflowErrMsg, maxAutoRandBits, actualAutoRandBits, colName)
}
assertMaxOverflow := func(sql, colName string, autoRandBits uint64) {
assertInvalidAutoRandomErr(sql, autoid.AutoRandomOverflowErrMsg, autoid.MaxAutoRandomBits, autoRandBits, colName)
}
assertModifyColType := func(sql string) {
Expand Down Expand Up @@ -906,8 +913,12 @@ func (s *testSerialSuite) TestAutoRandom(c *C) {
})

// Overflow data type max length.
assertOverflow("create table t (a bigint auto_random(64) primary key)", "a", 64)
assertOverflow("create table t (a bigint auto_random(16) primary key)", "a", 16)
assertMaxOverflow("create table t (a bigint auto_random(64) primary key)", "a", 64)
assertMaxOverflow("create table t (a bigint auto_random(16) primary key)", "a", 16)
mustExecAndDrop("create table t (a bigint auto_random(5) primary key)", func() {
assertMaxOverflow("alter table t modify a bigint auto_random(64)", "a", 64)
assertMaxOverflow("alter table t modify a bigint auto_random(16)", "a", 16)
})

assertNonPositive("create table t (a bigint auto_random(0) primary key)")
tk.MustGetErrMsg("create table t (a bigint auto_random(-1) primary key)",
Expand All @@ -920,6 +931,13 @@ func (s *testSerialSuite) TestAutoRandom(c *C) {
mustExecAndDrop("create table t (a bigint primary key auto_random(4))")
mustExecAndDrop("create table t (a bigint auto_random(4), primary key (a))")

// Increase auto_random bits.
mustExecAndDrop("create table t (a bigint auto_random(5) primary key)", func() {
tk.MustExec("alter table t modify a bigint auto_random(8)")
tk.MustExec("alter table t modify a bigint auto_random(10)")
tk.MustExec("alter table t modify a bigint auto_random(12)")
})

// Auto_random can occur multiple times like other column attributes.
mustExecAndDrop("create table t (a bigint auto_random(3) auto_random(2) primary key)")
mustExecAndDrop("create table t (a bigint, b bigint auto_random(3) primary key auto_random(2))")
Expand All @@ -936,9 +954,30 @@ func (s *testSerialSuite) TestAutoRandom(c *C) {
})
mustExecAndDrop("create table t (a bigint primary key)", func() {
assertAlterValue("alter table t modify column a bigint auto_random(3)")
assertAlterValue("alter table t change column a b bigint auto_random(3)")
})

// Decrease auto_random bits is not allowed.
mustExecAndDrop("create table t (a bigint auto_random(10) primary key)", func() {
assertDecreaseBitErr("alter table t modify column a bigint auto_random(6)")
})
mustExecAndDrop("create table t (a bigint auto_random(10) primary key)", func() {
assertDecreaseBitErr("alter table t modify column a bigint auto_random(1)")
})

originStep := autoid.GetStep()
autoid.SetStep(1)
// Increase auto_random bits but it will overlap with incremental bits.
mustExecAndDrop("create table t (a bigint unsigned auto_random(5) primary key)", func() {
const alterTryCnt, rebaseOffset = 3, 1
insertSQL := fmt.Sprintf("insert into t values (%d)", ((1<<(64-10))-1)-rebaseOffset-alterTryCnt)
tk.MustExec(insertSQL)
// Try to rebase to 0..0011..1111 (54 `1`s).
tk.MustExec("alter table t modify a bigint unsigned auto_random(6)")
tk.MustExec("alter table t modify a bigint unsigned auto_random(10)")
assertOverflow("alter table t modify a bigint unsigned auto_random(11)", "a", 10, 11)
})
autoid.SetStep(originStep)

// Modifying the field type of a auto_random column is not allowed.
// Here the throw error is `ERROR 8200 (HY000): Unsupported modify column: length 11 is less than origin 20`,
// instead of `ERROR 8216 (HY000): Invalid auto random: modifying the auto_random column type is not supported`
Expand Down
4 changes: 3 additions & 1 deletion meta/autoid/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ const (
// AutoRandomIncompatibleWithDefaultValueErrMsg is reported when auto_random and default are specified on the same column.
AutoRandomIncompatibleWithDefaultValueErrMsg = "auto_random is incompatible with default"
// AutoRandomOverflowErrMsg is reported when auto_random is greater than max length of a MySQL data type.
AutoRandomOverflowErrMsg = "max allowed auto_random bits is %d, but got %d on column `%s`"
AutoRandomOverflowErrMsg = "max allowed auto_random shard bits is %d, but got %d on column `%s`"
// AutoRandomModifyColTypeErrMsg is reported when a user is trying to modify the type of a column specified with auto_random.
AutoRandomModifyColTypeErrMsg = "modifying the auto_random column type is not supported"
// AutoRandomAlterErrMsg is reported when a user is trying to add/drop/modify the value of auto_random attribute.
AutoRandomAlterErrMsg = "adding/dropping/modifying auto_random is not supported"
// AutoRandomDecreaseBitErrMsg is reported when the auto_random shard bits is decreased.
AutoRandomDecreaseBitErrMsg = "decreasing auto_random shard bits is not supported"
// AutoRandomNonPositive is reported then a user specifies a non-positive value for auto_random.
AutoRandomNonPositive = "the value of auto_random should be positive"
// AutoRandomAvailableAllocTimesNote is reported when a table containing auto_random is created.
Expand Down
2 changes: 1 addition & 1 deletion meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (m *Meta) GetAutoTableID(dbID int64, tableID int64) (int64, error) {
return m.txn.HGetInt64(m.dbKey(dbID), m.autoTableIDKey(tableID))
}

// GetAutoRandomID gets current auto shard id with table id.
// GetAutoRandomID gets current auto random id with table id.
func (m *Meta) GetAutoRandomID(dbID int64, tableID int64) (int64, error) {
return m.txn.HGetInt64(m.dbKey(dbID), m.autoRandomTableIDKey(tableID))
}
Expand Down