Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DistSQL lacks inline actual data nodes validation #33723

Closed
RaigorJiang opened this issue Nov 19, 2024 · 1 comment · Fixed by #33735
Closed

DistSQL lacks inline actual data nodes validation #33723

RaigorJiang opened this issue Nov 19, 2024 · 1 comment · Fixed by #33735

Comments

@RaigorJiang
Copy link
Contributor

Bug Report

Which version of ShardingSphere did you use?

5.5.2-SNAPSHOT master 89f21d4

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-Proxy

Expected behavior

DistSQL execution fails when inline expressions do not match actual nodes

Actual behavior

DistSQL execution succeeded, metadata update failed

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

  1. Create sharding table rule with wrong nodes in inline expression
CREATE SHARDING TABLE RULE t_order (
DATANODES("ds_${0..3}.t_order_${0..2}"),
DATABASE_STRATEGY(
  TYPE="standard",
  SHARDING_COLUMN=user_id,
  SHARDING_ALGORITHM(
    TYPE(NAME="inline",PROPERTIES("algorithm-expression"="dss_${user_id % 4}")))),
TABLE_STRATEGY(
  TYPE="standard",
  SHARDING_COLUMN=order_id,
  SHARDING_ALGORITHM(
    TYPE(NAME="inline",PROPERTIES("algorithm-expression"="t_order_${order_id % 3}"))))
);
  1. Refresh metadata failed
[Curator-SafeNotifyService-0] c.g.common.eventbus.EventBus.default - Exception thrown by subscriber method renew(org.apache.shardingsphere.mode.event.dispatch.rule.alter.AlterRuleItemEvent) on subscriber org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.RuleItemChangedSubscriber@27854b33 when dispatching event: org.apache.shardingsphere.mode.event.dispatch.rule.alter.AlterNamedRuleItemEvent@5c60de44
org.apache.shardingsphere.infra.algorithm.core.exception.AlgorithmInitializationException: Algorithm 'Object.'INLINE' initialization failed, reason is: `t_order_database_inline` sharding algorithm configuration of `t_order` does not match the actual data nodes.
	at org.apache.shardingsphere.sharding.rule.checker.ShardingRuleChecker.lambda$validateInlineShardingAlgorithm$6(ShardingRuleChecker.java:178)
	at org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
	at org.apache.shardingsphere.sharding.rule.checker.ShardingRuleChecker.validateInlineShardingAlgorithm(ShardingRuleChecker.java:176)
	at org.apache.shardingsphere.sharding.rule.checker.ShardingRuleChecker.lambda$checkInlineShardingAlgorithmsInTableRules$5(ShardingRuleChecker.java:157)
	at java.base/java.util.Map.forEach(Map.java:713)
	at org.apache.shardingsphere.sharding.rule.checker.ShardingRuleChecker.checkInlineShardingAlgorithmsInTableRules(ShardingRuleChecker.java:155)
	at org.apache.shardingsphere.sharding.rule.checker.ShardingRuleChecker.check(ShardingRuleChecker.java:62)
	at org.apache.shardingsphere.sharding.rule.ShardingRule.<init>(ShardingRule.java:141)
	at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:42)
	at org.apache.shardingsphere.sharding.rule.builder.ShardingRuleBuilder.build(ShardingRuleBuilder.java:36)
	at org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder.build(DatabaseRulesBuilder.java:96)
	at org.apache.shardingsphere.mode.metadata.manager.DatabaseRuleConfigurationManager.alterRuleConfiguration(DatabaseRuleConfigurationManager.java:78)
	at org.apache.shardingsphere.mode.metadata.manager.RuleItemManager.alterRuleItem(RuleItemManager.java:67)
	at org.apache.shardingsphere.mode.manager.cluster.event.subscriber.dispatch.RuleItemChangedSubscriber.renew(RuleItemChangedSubscriber.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant