Fix broadcast data node lookup ignoring table name case#39153
Conversation
terrymanu
left a comment
There was a problem hiding this comment.
Summary
Review Result: Not Mergeable
Feedback Mode: Change Request
Reason: The broadcast-only scope is correct because the sharding and single-table implementations already support case-insensitive lookup. However, the proposed broadcast implementation should follow the established CaseInsensitiveMap approach instead of adding manual toLowerCase() normalization.
Issues
[P2] Use the established case-insensitive map implementation
Problem: BroadcastDataNodeRuleAttribute and ShardingDataNodeRuleAttribute both maintain the same mapping from logical table names to data nodes. The sharding implementation already uses CaseInsensitiveMap, while this PR manually lowercases the lookup key. The single-table implementation also provides case-insensitive lookup through equalsIgnoreCase.
There is no broadcast-specific requirement that justifies a separate normalization strategy. Manual String.toLowerCase() calls also depend on the JVM default locale and require every lookup method to repeat the same normalization rule.
Impact: The three DataNodeRuleAttribute implementations expose the same lookup contract but use inconsistent semantics. The broadcast implementation can still fail under locale-sensitive inputs, and future methods may omit normalization again.
Required Change: Please initialize tableDataNodes as a CaseInsensitiveMap, store the original logical table names, and remove the manual toLowerCase() calls from the constructor and all lookup methods. Add a regression test covering case-insensitive lookup, including a locale-sensitive table name.
The sharding and single-table implementations do not require changes because they already provide case-insensitive lookup.
Review Details
- Review Focus: Code Correctness Review — CI not reviewed by request.
- Reviewed Scope:
BroadcastDataNodeRuleAttribute, its unit test, and the corresponding sharding and single-table implementations. Latest PR head:34b5a8ca02952d06c3ca5f7b5cc50d26016072d8. - Not Reviewed Scope: GitHub Actions, other CI checks, and E2E scenarios.
- Verification: The focused broadcast unit test passed with 14 tests. A locale-sensitive lookup on the latest head still returned no data nodes.
- Release Note / User Docs: The release note is present. No user documentation change is required because this should preserve the existing configuration contract.
Fixes #39149.
Changes proposed in this pull request:
.toLowerCase()inBroadcastDataNodeRuleAttribute.getDataNodesByTableName()before looking uptableDataNodes, which is keyed by lower-cased table names in the constructor.findFirstActualTable,findLogicTableByActualTable,findActualTableByCatalog) that already lower-case the argument, and with the case-insensitive lookups in the Sharding and Single data node rule attributes.Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.