DISABLE_AUDIT_NAMES hint is ignored when the auditor name contains upper-case letters
DISABLE_AUDIT_NAMES hint is ignored when the auditor name contains upper-case letters
Bug Report
Which version of ShardingSphere did you use?
master @ 101c3d56ccd
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
Both
Expected behavior
With allowHintDisable: true, /* SHARDINGSPHERE_HINT: DISABLE_AUDIT_NAMES=<name> */ skips the named auditor.
Actual behavior
When the auditor name contains an upper-case letter (e.g. shardingKeyAuditor), the hint is ignored even with identical spelling; the auditor still runs and throws DMLWithoutShardingKeyException.
Reason analyze (If you can)
ShardingSQLAuditor.audit() (features/sharding/core/.../auditor/ShardingSQLAuditor.java line 53) evaluates disableAuditNames.contains(each.toLowerCase()): the configured name is lower-cased while the hint value is kept as written (SQLHintUtils only trims).
The next line resolves rule.getAuditors().get(each) through a CaseInsensitiveMap (ShardingRule line 99), so one method applies two case rules.
DistSQL lower-cases auditor names; this reproduces with YAML or Java API configuration.
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
- Configure
auditors: { shardingKeyAuditor: { type: DML_SHARDING_CONDITIONS } }andauditStrategy: { auditorNames: [shardingKeyAuditor], allowHintDisable: true }. - Execute
/* SHARDINGSPHERE_HINT: DISABLE_AUDIT_NAMES=shardingKeyAuditor */ SELECT * FROM t_order;. DMLWithoutShardingKeyExceptionis thrown.
Example codes for reproduce this issue (such as a github link).
N/A
Source: apache/shardingsphere