Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[infoschema] tikv_region_peers drops negative region_id/store_id predicates and returns all peers #70047

Copy link
Copy link

Description

@wjhuang2016
Issue body actions

Bug Report

Evidence status: confirmed.

1. Minimal reproduce step (Required)

SELECT COUNT(*) FROM information_schema.tikv_region_peers; -- 269
EXPLAIN FORMAT='brief' SELECT * FROM information_schema.tikv_region_peers WHERE region_id = -1; -- MemTableScan without Selection and without region_ids filter
SELECT COUNT(*) FROM information_schema.tikv_region_peers WHERE region_id = -1; -- 269
SELECT COUNT(*) FROM information_schema.tikv_region_peers WHERE CASE WHEN region_id = -1 THEN TRUE ELSE FALSE END; -- 0
SELECT region_id, store_id, peer_id, region_id = -1 AS predicate_value FROM information_schema.tikv_region_peers WHERE region_id = -1 LIMIT 5; -- predicate_value=0 on returned rows
SELECT COUNT(*) FROM information_schema.tikv_region_peers WHERE store_id = -1; -- 269
SELECT COUNT(*) FROM information_schema.tikv_region_peers WHERE CASE WHEN store_id = -1 THEN TRUE ELSE FALSE END; -- 0

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

A negative region_id/store_id predicate is unsatisfiable for TiKV peer metadata and should return an empty rowset. Invalid or out-of-domain extracted IDs must not bypass the SQL predicate; backend lookup errors for impossible filters should not replace SQL empty-row semantics.

3. What did you see instead? (Required)

The extractor removes the SQL predicate, fails to build a valid uint64 ID filter, and scans all peers. region_id=-1 and store_id=-1 return every row in information_schema.tikv_region_peers; rows visibly fail their own predicate. Non-numeric strings can additionally be coerced to region_ids:[0] and reported as a PD 400 error.

4. What is your TiDB version? (Required)

Confirmed on QA testbed 8192975. SELECT VERSION() returned 8.0.11-TiDB-v8.4.0-this-is-a-placeholder.

Likely root cause and fix direction

extractCol removes EQ/IN predicates once it recognizes region_id/store_id. TikvRegionPeersExtractor then calls parseUint64 on the extracted string set. parseUint64 silently ignores ParseUint failures such as "-1" and returns an empty slice, but the original predicate has already been dropped and SkipRequest is not set. The resulting MemTableScan has neither a Selection nor a region/store ID filter, so it returns all peers.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.