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
*: support check an index #5932
Conversation
parser/parser_test.go
Outdated
@@ -403,6 +403,7 @@ func (s *testParserSuite) TestDMLStmt(c *C) { | |||
{"admin show ddl;", true}, | |||
{"admin show ddl jobs;", true}, | |||
{"admin check table t1, t2;", true}, | |||
{"admin check index idx;", true}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the idx
is the table name, and index name is empty?
break | ||
} | ||
} | ||
if idx == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check if the index state is public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
executor/executor.go
Outdated
} | ||
err := e.run(ctx) | ||
e.done = true | ||
return errors.Trace(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just call e.Next
or extract a function?
executor/executor.go
Outdated
} | ||
|
||
for { | ||
row, err := e.src.Next(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use NextChunk
?
executor/executor.go
Outdated
dbName string | ||
tableName string | ||
idxName string | ||
src Executor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Executor/*IndexLookUpExecutor/ is more readable ?
executor/distsql.go
Outdated
@@ -878,6 +886,10 @@ func (w *tableWorker) executeTask(ctx context.Context, task *lookupTableTask) { | |||
} | |||
sort.Sort(task) | |||
} | |||
|
|||
if w.isCheckOp && handleCnt != len(task.rows) { | |||
err = errors.Errorf("handle count %d isn't equal to value count %d", handleCnt, len(task.rows)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the missing handle and corresponding index value in the error message.
executor/executor.go
Outdated
@@ -409,6 +409,70 @@ func (e *CheckTableExec) run(ctx context.Context) error { | |||
return nil | |||
} | |||
|
|||
// CheckIndexExec represents the executor of check an index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check -> checking
executor/executor.go
Outdated
@@ -409,6 +409,70 @@ func (e *CheckTableExec) run(ctx context.Context) error { | |||
return nil | |||
} | |||
|
|||
// CheckIndexExec represents the executor of check an index. | |||
// It is built from the "admin check index" statement, and it checks if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it checks the consistency of the index data with the records of the table.
executor/executor.go
Outdated
if err != nil { | ||
return errors.Trace(err) | ||
} | ||
cnt := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cnt
is unused ?
PTAL @zz-jason |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
/run-all-tests |
Using
IndexLoopUpReader
to supportadmin check index
option.In next PR I will handle the case below: