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

Invalid sharding algorithms [INTERVAL] #22816

Closed
alei78910 opened this issue Dec 12, 2022 · 3 comments · Fixed by #22900
Closed

Invalid sharding algorithms [INTERVAL] #22816

alei78910 opened this issue Dec 12, 2022 · 3 comments · Fixed by #22900

Comments

@alei78910
Copy link

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

5.3.0

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

apache/shardingsphere-proxy:5.3.0,mysql-connector-java-5.1.47.jar

Expected behavior

CREATE DATABASE db_test_common CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';
USE db_test_common;
REGISTER STORAGE UNIT ds_write_test_common( URL="jdbc:mysql://10.98.59.35:3306/db_common_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2b8", USER="root", PASSWORD="123456");
CREATE SHARDING TABLE RULE apploginlog(
STORAGE_UNITS(ds_write_test_common),
SHARDING_COLUMN=CreationTime,
TYPE(NAME="INTERVAL", PROPERTIES("datetime-pattern"="yyyy-MM-dd HH:mm:ss","datetime-interval-unit"="MONTHS","datetime-interval-amount"="1","sharding-suffix-pattern"="yyyyMM","datetime-lower"="2016-01-01 00:00:00","datetime-upper"="2099-12-31 00:00:00"))
);

Actual behavior

CREATE DATABASE is OK;
REGISTER STORAGE UNIT is OK;
CREATE SHARDING TABLE RULE is error, ERROR 19150 (44000): Invalid sharding algorithms [INTERVAL].

Reason analyze (If you can)

使用apache/shardingsphere-proxy:5.2.1版本,执行CREATE SHARDING TABLE RULE apploginlogs(
RESOURCES(ds_write_test_common),
SHARDING_COLUMN=CreationTime,
TYPE(NAME=“INTERVAL”, PROPERTIES(“datetime-pattern”=“yyyy-MM-dd HH:mm:ss”,“datetime-interval-unit”=“MONTHS”,“datetime-interval-amount”=“1”,“sharding-suffix-pattern”=“yyyyMM”,“datetime-lower”=“2016-01-01 00:00:00”,“datetime-upper”=“2099-12-31 00:00:00”))
);也是报错ERROR 19150 (44000): Invalid sharding algorithms [INTERVAL]

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

Example codes for reproduce this issue (such as a github link).

@RaigorJiang RaigorJiang changed the title 时间范围数据分片不可用 Invalid sharding algorithms [INTERVAL] Dec 12, 2022
@RaigorJiang
Copy link
Contributor

Hi @alei78910
I reproduced the problem and the reason for the exception is as follows:

  1. INTERVAL is one of the standard sharding algorithms, it does not belong to the auto sharding algorithm;
  2. Please pay attention to the difference defined in sharding table rule. The auto sharding algorithm uses STORAGE_UNITS to specify the data source, and the standard sharding algorithm uses DATANODES to specify data nodes;
  3. Because you defined with STORAGE_UNITS, when checking the rules according to the auto sharding algorithm, it is found that INTERVAL does not meet the requirements

The above is the reason for this problem, but this prompt message is really not easy to understand, thank you for your feedback.

@RaigorJiang
Copy link
Contributor

@RaigorJiang
Copy link
Contributor

Hi @alei78910
I optimized the error message in #22900, if you want to use auto sharding algorithm, you can refer to:

CREATE SHARDING TABLE RULE apploginlog(
STORAGE_UNITS(ds_0),
SHARDING_COLUMN=CreationTime,
TYPE(NAME=AUTO_INTERVAL, PROPERTIES("sharding-seconds"="2592000","datetime-lower"="2016-01-01 00:00:00","datetime-upper"="2099-12-31 00:00:00"))
);

The above configuration means each sharding node for every 30 days.

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

Successfully merging a pull request may close this issue.

2 participants