ddl: enhance placement rule mismatch error#69722
Conversation
|
Hi @Meowooh. 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. |
|
[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 |
📝 WalkthroughWalkthroughAdds a new ChangesPlacement error context enhancement
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant onAlterTablePlacement
participant PDClient
participant placementRuleErrorWithContext
participant findPlacementRule
onAlterTablePlacement->>PDClient: PutRuleBundlesWithDefaultRetry(bundles)
PDClient-->>onAlterTablePlacement: ErrHTTPServiceError
onAlterTablePlacement->>placementRuleErrorWithContext: wrap error with schema/table/policy/bundles
placementRuleErrorWithContext->>placementRuleErrorWithContext: extractPlacementRuleError(message)
placementRuleErrorWithContext->>findPlacementRule: locate rule by id in bundles
findPlacementRule-->>placementRuleErrorWithContext: rule or not found
placementRuleErrorWithContext-->>onAlterTablePlacement: enhanced error message
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What problem does this PR solve?
Issue Number: close #47253
Problem Summary:
When
ALTER TABLE ... PLACEMENT POLICY ...fails because PD rejects a generated placement rule, TiDB only returns PD's raw error, for examplecan not match any store. The message does not tell users which table, placement policy, rule group, rule, or constraints caused the mismatch, making label/topology issues hard to diagnose.What changed and how does it work?
infosync.ErrHTTPServiceErrorand MySQL error code 8243.onAlterTablePlacement, wheninfosync.PutRuleBundlesWithDefaultRetryfails, parse the PD error's rule group/rule ID and look up the matching rule in the current TiDB placement bundle.No store matches... SHOW PLACEMENT LABELShint only for thecan not match any storecase.Example enhanced message:
before
now
Check List
Tests
Unit test:
go test ./pkg/ddl -run TestEnhancePlacementRuleError -count=1Manual test:
region=us-east-1region=us-east-2region=us-west-1all_in_eastandmydeployplacement policies, wheremydeployrequests missing+region=us-west.ALTER TABLE t PLACEMENT POLICY mydeploystill returns code 8243.label_constraints=[region in (us-west)].SHOW WARNINGScontains the same enhanced message.Side effects
Documentation
Release note
Summary by CodeRabbit
New Features
Bug Fixes