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

Incorrect index after deleting from a table with index of multiple columns using a subquery, on latest master version (ADMIN CHECK TABLE failed) #8853

Closed
kennytm opened this issue Dec 27, 2018 · 4 comments
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@kennytm
Copy link
Contributor

kennytm commented Dec 27, 2018

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?

Execute the following SQL:

DROP DATABASE IF EXISTS tlc;

CREATE DATABASE tlc;

USE tlc;

CREATE TABLE table_v1 ( 
    table_name bigint NOT NULL PRIMARY KEY, 
    status tinyint unsigned
);

CREATE TABLE chunk_v3 ( 
    table_name bigint NOT NULL, 
    offset bigint NOT NULL, 
    INDEX(table_name, offset) 
);

INSERT INTO table_v1 (table_name, status) VALUES (1, 30);

INSERT INTO chunk_v3 (table_name, offset) VALUES (1, 0);

DELETE FROM chunk_v3 WHERE table_name IN (SELECT table_name FROM table_v1 WHERE status > 0);

ADMIN CHECK TABLE chunk_v3;
  1. What did you expect to see?

ADMIN CHECK TABLE passes.

  1. What did you see instead?

The row is deleted but the index remains. It failed with:

ERROR 8003 (HY000): chunk_v3 err:[admin:1]index:&admin.RecordData{Handle:1, Values:[]types.Datum{types.Datum{k:0x1, collation:0x0, decimal:0x0, length:0x0, i:1, b:[]uint8(nil), x:interface {}(nil)}, types.Datum{k:0x1, collation:0x0, decimal:0x0, length:0x0, i:0, b:[]uint8(nil), x:interface {}(nil)}}} != record:<nil>
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?

This is only reproducible on the master branch. The SQL works fine on 2.1.1 and 2.0.9. I suspect this is a recently introduced regression.

mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v3.0.0-aaaaaaa-29-g71088815e
Git Commit Hash: 71088815e7c5121e069d7ec10595d176a44b9bea
Git Branch: log-all-queries
UTC Build Time: 2018-12-27 05:00:31
GoVersion: go version go1.11.2 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
1 row in set (0.00 sec)
@kennytm kennytm added the type/bug The issue is confirmed as a bug. label Dec 27, 2018
@kennytm
Copy link
Contributor Author

kennytm commented Dec 27, 2018

The regression is introduced in 126e44b...096bb68. git bisecting...

Edit: Bisection shows 6bd8bdd (#8394) is the first bad commit, cc @winoros.

@kennytm kennytm added the sig/planner SIG: Planner label Dec 27, 2018
@kennytm kennytm changed the title Incorrect index after deleting with a subquery on latest master version (ADMIN CHECK TABLE failed) Incorrect index after deleting from a table with index of multiple columns using a subquery, on latest master version (ADMIN CHECK TABLE failed) Dec 27, 2018
@jackysp
Copy link
Member

jackysp commented Dec 28, 2018

PTAL @winoros @zz-jason

@winoros
Copy link
Member

winoros commented Dec 28, 2018

After some investigating, #8805 should fix it.

@kennytm
Copy link
Contributor Author

kennytm commented Jan 4, 2019

Verified fixed as of 6d098d4, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants