Skip to content

Fix broadcast data node lookup ignoring table name case#39153

Open
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:39149
Open

Fix broadcast data node lookup ignoring table name case#39153
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:39149

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #39149.

Changes proposed in this pull request:

  • Normalize the table name with .toLowerCase() in BroadcastDataNodeRuleAttribute.getDataNodesByTableName() before looking up tableDataNodes, which is keyed by lower-cased table names in the constructor.
  • Aligns the method with its three sibling lookups (findFirstActualTable, findLogicTableByActualTable, findActualTableByCatalog) that already lower-case the argument, and with the case-insensitive lookups in the Sharding and Single data node rule attributes.
  • Add a unit test asserting an upper-cased table name resolves to the same data nodes as the lower-cased name.

Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version. For more details, see Update Release Note

@terrymanu terrymanu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broadcast data node lookup by table name is case-sensitive

2 participants