Skip to content

Create index on a small table is slow #49477

@tangenta

Description

@tangenta

Enhancement

use test;
drop table if exists t;
create table t (a int);
insert into t values (1);
alter table t add index i(a);

Output:

mysql> alter table t add index i(a);
Query OK, 0 rows affected (2.75 sec)

Log:

[WARN] [region_job.go:531] ["meet error and handle the job later"] ["job stage"=needRescan] [error="[Lightning:KV:EpochNotMatch]EpochNotMatch current epoch of region 22 is conf_ver: 1 version: 66"] [] [start=74800000000000006A5F698000000000000001038000000000000001038000000000000001] [end=74800000000000006A5F69800000000000000103800000000000000103800000000000000100]

You will almost certainly encounter an "EpochNotMatch" error when adding an index, and wait at least two seconds.

// max retry backoff time: 2+4+8+16+30*26=810s
sleepSecond := math.Pow(2, float64(job.retryCount))
if sleepSecond > float64(maxRetryBackoffSecond) {
sleepSecond = float64(maxRetryBackoffSecond)
}

Maybe we can improve this by synchronizing region splitting.

Metadata

Metadata

Assignees

Labels

type/enhancementThe issue or PR belongs to an enhancement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions