Skip to content
New issue

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

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

Already on GitHub? # to your account

Row not found for Global Index during DeleteOnly state of Reorganize Partition #56819

Closed
mjonss opened this issue Oct 24, 2024 · 3 comments · Fixed by #56382
Closed

Row not found for Global Index during DeleteOnly state of Reorganize Partition #56819

mjonss opened this issue Oct 24, 2024 · 3 comments · Fixed by #56382
Labels
affects-8.4 component/tablepartition This issue is related to Table Partition of TiDB. severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Oct 24, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Apply this patch:

diff --git a/pkg/ddl/tests/partition/multi_domain_test.go b/pkg/ddl/tests/partition/multi_domain_test.go
index 1c567c9a4a..3a17df219d 100644
--- a/pkg/ddl/tests/partition/multi_domain_test.go
+++ b/pkg/ddl/tests/partition/multi_domain_test.go
@@ -27,6 +27,28 @@ import (
        "go.uber.org/zap"
 )
 
+func TestMultiSchemaReorganizePartition(t *testing.T) {
+       createSQL := `create table t (a int primary key, b varchar(255), unique index idx_b_global (b) global) partition by range (a) (partition p1 values less than (200), partition pMax values less than (maxvalue))`
+       initFn := func(tkO *testkit.TestKit) {
+               tkO.MustExec(`insert into t values (1,1),(2,2)`)
+       }
+       alterSQL := `alter table t reorganize partition p1 into (partition p0 values less than (100), partition p1 values less than (200))`
+       loopFn := func(tkO, tkNO *testkit.TestKit) {
+               res := tkO.MustQuery(`select schema_state from information_schema.DDL_JOBS where table_name = 't' order by job_id desc limit 1`)
+               schemaState := res.Rows()[0][0].(string)
+               switch schemaState {
+               case model.StateDeleteOnly.String():
+                       tkNO.MustExec(`insert into t values (4,4)`)
+                       tkNO.MustQuery(`select * from t where b = "4"`).Sort().Check(testkit.Rows("4 4"))
+                       tkO.MustQuery(`select * from t where b = "4"`).Sort().Check(testkit.Rows("4 4"))
+               }
+       }
+       postFn := func(tkO *testkit.TestKit) {
+               // nothing
+       }
+       runMultiSchemaTest(t, createSQL, alterSQL, initFn, postFn, loopFn)
+}
+
 func TestMultiSchemaDropRangePartition(t *testing.T) {
        createSQL := `create table t (a int primary key, b varchar(255)) partition by range (a) (partition p0 values less than (100), partition p1 values less than (200))`
        initFn := func(tkO *testkit.TestKit) {

use make failpoint-enable and run the test.

2. What did you expect to see? (Required)

test passing

3. What did you see instead (Required)

Read from the second SELECT did not return anything! I.e. the row "4 4" could not be found!

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v8.4.0-alpha-463-ged9a909395
Edition: Community
Git Commit Hash: ed9a9093954f6636f8d3c9d09686069626e5b5ce
Git Branch: master
UTC Build Time: 2024-10-24 13:20:54
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: unistore
@mjonss mjonss added the type/bug The issue is confirmed as a bug. label Oct 24, 2024
@mjonss
Copy link
Contributor Author

mjonss commented Oct 24, 2024

Would be fixed by #56382.

@mjonss
Copy link
Contributor Author

mjonss commented Oct 25, 2024

Since Global Index has not been GA in the previous versions, I have removed the 'may-affects-X.Y' labels for those.

@mjonss
Copy link
Contributor Author

mjonss commented Oct 25, 2024

Issue is that DroppingDefinitions are excluded from the Global Index search, which is fixed in #56382.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
affects-8.4 component/tablepartition This issue is related to Table Partition of TiDB. severity/critical sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants