dbutil: keep column and index buckets apart when names collide - #905
dbutil: keep column and index buckets apart when names collide#905yzxcj797 wants to merge 1 commit into
Conversation
GetBucketsInfo keyed both column statistics (is_index=0, scalar bounds) and index statistics (is_index=1, tuple bounds) by bare name and appended into one map, so an index sharing its name with a column merged two bucket sequences under one key. Chunk splitting then fed scalar column bounds to AnalyzeValuesFromBuckets against the index's columns and failed with 'analyze value 1683857 failed' — as happens for a table whose first secondary index is named after its leading column (KEY contentid (contentid, flag, datetime)). Collect the two kinds into separate maps during the scan and merge at the end, with the index entry winning its name: lookups by index name must get the index statistics. The PRIMARY fallback now reads from the column map directly, so a PK column named like another index keeps its own entry. Fixes pingcap#904
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @yzxcj797. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @yzxcj797! |
|
|
Issue Number: close #904
What problem does this PR solve?
GetBucketsInfomerged column statistics and index statistics under bare names, so an index sharing its name with a column (e.g.KEY \contentid` (`contentid`,`flag`,`datetime`)) produced one bucket sequence mixing scalar column bounds with tuple index bounds — chunk splitting then failed withanalyze value 1683857 failed` (#904).What is changed and how it works?
Column (
is_index=0) and index (is_index=1) buckets are collected into separate maps during the scan and merged at the end, with the index entry winning its own name: lookups by index name must return the index statistics. ThePRIMARYfallback reads from the column map directly so a PK column named like another index keeps its own entry.Check List
TestGetBucketsInfoIndexNameCollidesWithColumn(sqlmock) reproduces the report's table shape and asserts only the tuple buckets are returned under the index name; differential on unpatched code fails with the merged-sequence behavior../pkg/dbutil/bucket tests pass.