Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions br/pkg/restore/log_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,11 @@
addArgs = append(addArgs, info.SchemaName.O, info.TableName.O, info.IndexInfo.Name.O)
addArgs = append(addArgs, info.ColumnArgs...)
}
// WHERE CONDITION
if len(info.IndexInfo.ConditionExprString) > 0 {

Check failure on line 1653 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)

Check failure on line 1653 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)

Check failure on line 1653 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)

Check failure on line 1653 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)
addSQL.WriteString(" WHERE ")
addSQL.WriteString(info.IndexInfo.ConditionExprString)

Check failure on line 1655 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)

Check failure on line 1655 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)

Check failure on line 1655 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)

Check failure on line 1655 in br/pkg/restore/log_client/client.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

info.IndexInfo.ConditionExprString undefined (type *"github.com/pingcap/tidb/pkg/meta/model".IndexInfo has no field or method ConditionExprString)
}
// USING BTREE/HASH/RTREE
indexTypeStr := info.IndexInfo.Tp.String()
if len(indexTypeStr) > 0 {
Expand Down
8 changes: 8 additions & 0 deletions br/tests/br_pitr/check/check_ingest_repair.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ check_contains "ON DELETE SET NULL ON UPDATE CASCADE"
run_sql "SELECT count(*) AS RESCNT FROM INFORMATION_SCHEMA.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'pairs19' AND INDEX_ID = 2 AND IS_GLOBAL = 1;"
check_contains "RESCNT: 1"

## check table test.pairs20
run_sql "SELECT COUNT(*) AS RESCNT FROM INFORMATION_SCHEMA.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'pairs20' AND INDEX_ID > 2 AND PREDICATE = '\`id\` > 5'"
check_contains "RESCNT: 2"
Comment on lines +143 to +145
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the partial-index metadata assertion deterministic.

Line 144’s INDEX_ID > 2 is allocation-dependent and can make this check flaky. Assert by key names instead.

Suggested fix
-run_sql "SELECT COUNT(*) AS RESCNT FROM INFORMATION_SCHEMA.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'pairs20' AND INDEX_ID > 2 AND PREDICATE = '\`id\` > 5'"
+run_sql "SELECT COUNT(*) AS RESCNT FROM INFORMATION_SCHEMA.TIDB_INDEXES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'pairs20' AND KEY_NAME IN ('i1','i2') AND PREDICATE = '\`id\` > 5'"
 check_contains "RESCNT: 2"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@br/tests/br_pitr/check/check_ingest_repair.sh` around lines 143 - 145, The
current assertion in check_ingest_repair.sh queries
INFORMATION_SCHEMA.TIDB_INDEXES using an allocation-dependent INDEX_ID > 2 which
is flaky; update the SQL used by run_sql to assert partial-index rows by stable
index identifiers (INDEX_NAME) and PREDICATE instead of INDEX_ID, e.g. filter
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='pairs20' AND INDEX_NAME IN
('<partial_idx_name1>','<partial_idx_name2>') AND PREDICATE = '`id` > 5' (or use
a single INDEX_NAME = '<name>' if only one), then adjust the expected RESCNT
accordingly so the check is deterministic.


# adjust some index to be visible
run_sql "ALTER TABLE test.pairs ALTER INDEX i1 VISIBLE;"

Expand Down Expand Up @@ -198,3 +202,7 @@ run_sql "select count(*) AS RESCNT from test.pairs19 use index(i1) where pid = 1
check_not_contains "RESCNT: 0"
run_sql "select count(*) AS RESCNT from test.pairs19 use index(i1) where pid = 10;"
check_not_contains "RESCNT: 0"
run_sql "select count(*) AS RESCNT from test.pairs20 use index(i1) where pid1 = 10";
check_not_contains "RESCNT: 0"
run_sql "select count(*) AS RESCNT from test.pairs20 use index(i2) where pid2 = 10";
check_not_contains "RESCNT: 0"
4 changes: 4 additions & 0 deletions br/tests/br_pitr/incremental_data/ingest_repair.sql
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ ALTER TABLE test2.pairs18_child ADD CONSTRAINT fk_0 FOREIGN KEY (pid) REFERENCES

-- test global index
alter table test.pairs19 add unique index i1(pid) global;

-- test patial index
ALTER TABLE test.pairs20 ADD INDEX i1(pid1) WHERE id > 5;
ALTER TABLE test.pairs20 ADD UNIQUE INDEX i2(pid2) WHERE id > 5;
4 changes: 4 additions & 0 deletions br/tests/br_pitr/prepare_data/ingest_repair.sql
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ INSERT INTO test2.pairs18_child VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
-- test global index
CREATE TABLE test.pairs19 (id int, pid int) partition by range(id) (partition p0 values less than (6), partition p1 values less than (11));
INSERT INTO test.pairs19 values (1, 1), (10, 10);

-- test partial index
CREATE TABLE test.pairs20 (id int PRIMARY KEY, pid1 int, pid2 int);
INSERT INTO test.pairs20 values (1, 1, 1), (10, 10, 10);
Loading