You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/17 11:38:14 UTC

[GitHub] [shardingsphere] yx9o opened a new pull request #12529: Fix #12480

yx9o opened a new pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529


   Fixes #12480 .
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713577241



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -244,66 +294,16 @@ ShardingSphere中很多功能实现类的加载方式是通过[SPI](https://shar
 - 配置项`max.connections.size.per.query`(默认值为1)调高(版本 >= 3.0.0.M3且低于5.0.0)。
 - 配置项`max-connections-size-per-query`(默认值为1)调高(版本 >= 5.0.0)。
 
-## 19. 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
-
-回答:
-
-1. 需要使用4.1.0或更高版本。
-2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
- - 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
- - 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
-
-## 20. 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
-
-回答:
-
-1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
-2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
-
-## 21. 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
-
-回答:
-
-1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
-2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
-
-## 22. 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
-
-回答:
-
-1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
-2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
-3. 目前已测试的第三方数据库工具如下:
-   - Navicat:11.1.13、15.0.20。
-   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
-   - WorkBench:8.0.25。
-
-## 23. 引入`shardingsphere-transaction-xa-core`后,如何避免spring-boot自动加载默认的JtaTransactionManager?
+## 25. [其他] 引入`shardingsphere-transaction-xa-core`后,如何避免spring-boot自动加载默认的JtaTransactionManager?
 
 回答:
 
 1. 需要在spring-boot的引导类中添加 `@SpringBootApplication(exclude = JtaAutoConfiguration.class)`。
 

Review comment:
       Same as 17, We think this article is related to `JDBC`, because this problem will only occur when `JDBC` is integrated with `SpringBoot`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713574470



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+
+## 18. [其他] ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+
+回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+
+由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+
+而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+

Review comment:
       I think this way. 
   First of all, the content of the answer is related to sharding. 
   In addition, when this problem occurs, the user is probably already using the `KeyGenerateAlgorithm`. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-924598152


   > @lanchengx Hi, done, please review, thank you.
   
   Thanks a lot,I don’t think there are any other problems.
   @tristaZero 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang merged pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
RaigorJiang merged pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-922472286


   @lanchengx Hi could you have a review here?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713584135



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+

Review comment:
       > 我们认为这篇文章是相关的`JDBC`,因为这个问题只有在`JDBC`与`SPRING`.
   
   ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713561272



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+
+## 18. [其他] ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+
+回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+
+由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+
+而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+

Review comment:
       @lanchengx Hi, the use of self-incrementing primary key cannot be used as a sharding key, I think it should not be the `[sharding]` tag.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-922472350


   @yx9o Hey, thanks. ;-)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713583655



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+
+## 18. [其他] ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+
+回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+
+由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+
+而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+

Review comment:
       > I think this way.
   > First of all, the content of the answer is related to sharding.
   > In addition, when this problem occurs, the user is probably already using the `KeyGenerateAlgorithm`.
   
   ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713574868



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+

Review comment:
       This is related to the data source, I think the `[other]` tag is better,  What do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713561940



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -194,26 +269,13 @@ git config --global core.longpaths true
 https://docs.microsoft.com/zh-cn/windows/desktop/FileIO/naming-a-file
 https://ourcodeworld.com/articles/read/109/how-to-solve-filename-too-long-error-in-git-powershell-and-github-application-for-windows
 
-## 14. Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
-
-回答:
-
-某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
-
-解决方案:
-
-打开cmd.exe并执行下面的命令:
-```
-tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
-```
-
-## 15. Type is required 异常的解决方法?
+## 22. [其他] Type is required 异常的解决方法?
 
 回答:
 
 ShardingSphere中很多功能实现类的加载方式是通过[SPI](https://shardingsphere.apache.org/document/current/cn/features/pluggable-architecture/)注入的方式完成的,如分布式主键,注册中心等;这些功能通过配置中type类型来寻找对应的SPI实现,因此必须在配置文件中指定类型。
 
-## 16. 为什么我实现了`KeyGenerateAlgorithm`接口,也配置了Type,但是自定义的分布式主键依然不生效?
+## 23. [其他] 为什么我实现了`KeyGenerateAlgorithm`接口,也配置了Type,但是自定义的分布式主键依然不生效?
 

Review comment:
       > Hi @yx9o ,
   > Should the content related to `KeyGenerateAlgorithm` use the `[sharding]` tag?
   > I found that this interface is in the `shardingsphere-sharding` module.
   
   Ok, is there anything else incorrect? Let me modify it together.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713584907



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -244,66 +294,16 @@ ShardingSphere中很多功能实现类的加载方式是通过[SPI](https://shar
 - 配置项`max.connections.size.per.query`(默认值为1)调高(版本 >= 3.0.0.M3且低于5.0.0)。
 - 配置项`max-connections-size-per-query`(默认值为1)调高(版本 >= 5.0.0)。
 
-## 19. 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
-
-回答:
-
-1. 需要使用4.1.0或更高版本。
-2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
- - 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
- - 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
-
-## 20. 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
-
-回答:
-
-1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
-2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
-
-## 21. 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
-
-回答:
-
-1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
-2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
-
-## 22. 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
-
-回答:
-
-1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
-2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
-3. 目前已测试的第三方数据库工具如下:
-   - Navicat:11.1.13、15.0.20。
-   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
-   - WorkBench:8.0.25。
-
-## 23. 引入`shardingsphere-transaction-xa-core`后,如何避免spring-boot自动加载默认的JtaTransactionManager?
+## 25. [其他] 引入`shardingsphere-transaction-xa-core`后,如何避免spring-boot自动加载默认的JtaTransactionManager?
 
 回答:
 
 1. 需要在spring-boot的引导类中添加 `@SpringBootApplication(exclude = JtaAutoConfiguration.class)`。
 

Review comment:
       > Same as 17, We think this article is related to `JDBC`, because this problem will only occur when `JDBC` is integrated with `SpringBoot`.
   
   ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-924585779


   @lanchengx Hi, done, please review, thank you.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713554915



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -194,26 +269,13 @@ git config --global core.longpaths true
 https://docs.microsoft.com/zh-cn/windows/desktop/FileIO/naming-a-file
 https://ourcodeworld.com/articles/read/109/how-to-solve-filename-too-long-error-in-git-powershell-and-github-application-for-windows
 
-## 14. Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
-
-回答:
-
-某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
-
-解决方案:
-
-打开cmd.exe并执行下面的命令:
-```
-tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
-```
-
-## 15. Type is required 异常的解决方法?
+## 22. [其他] Type is required 异常的解决方法?
 
 回答:
 
 ShardingSphere中很多功能实现类的加载方式是通过[SPI](https://shardingsphere.apache.org/document/current/cn/features/pluggable-architecture/)注入的方式完成的,如分布式主键,注册中心等;这些功能通过配置中type类型来寻找对应的SPI实现,因此必须在配置文件中指定类型。
 
-## 16. 为什么我实现了`KeyGenerateAlgorithm`接口,也配置了Type,但是自定义的分布式主键依然不生效?
+## 23. [其他] 为什么我实现了`KeyGenerateAlgorithm`接口,也配置了Type,但是自定义的分布式主键依然不生效?
 

Review comment:
       Should the content related to `KeyGenerateAlgorithm` use the `[sharding]` tag?
   
   I found that this interface is in the `shardingsphere-sharding` module.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter commented on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-924615133


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#12529](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (77d3068) into [master](https://codecov.io/gh/apache/shardingsphere/commit/62828cdfee6a24ee0be57e16eb41848979dba079?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (62828cd) will **decrease** coverage by `0.10%`.
   > The diff coverage is `66.37%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12529/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #12529      +/-   ##
   ============================================
   - Coverage     63.48%   63.37%   -0.11%     
   - Complexity     1304     1327      +23     
   ============================================
     Files          2401     2440      +39     
     Lines         36572    37009     +437     
     Branches       6350     6405      +55     
   ============================================
   + Hits          23218    23456     +238     
   - Misses        11477    11648     +171     
   - Partials       1877     1905      +28     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...sql/parser/core/ShadowDistSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsL3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsLXBhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhZG93L2Rpc3RzcWwvcGFyc2VyL2NvcmUvU2hhZG93RGlzdFNRTFN0YXRlbWVudFZpc2l0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...ception/rule/RequiredAlgorithmMissedException.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9kaXN0c3FsL2V4Y2VwdGlvbi9ydWxlL1JlcXVpcmVkQWxnb3JpdGhtTWlzc2VkRXhjZXB0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../coordinator/lock/service/LockRegistryService.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtbW9kZS9zaGFyZGluZ3NwaGVyZS1tb2RlLXR5cGUvc2hhcmRpbmdzcGhlcmUtY2x1c3Rlci1tb2RlL3NoYXJkaW5nc3BoZXJlLWNsdXN0ZXItbW9kZS1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tb2RlL21hbmFnZXIvY2x1c3Rlci9jb29yZGluYXRvci9sb2NrL3NlcnZpY2UvTG9ja1JlZ2lzdHJ5U2VydmljZS5qYXZh) | `37.14% <0.00%> (ø)` | |
   | [...nt/distsql/rdl/alter/AlterRuleStatementAssert.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvYXNzZXJ0cy9zdGF0ZW1lbnQvZGlzdHNxbC9yZGwvYWx0ZXIvQWx0ZXJSdWxlU3RhdGVtZW50QXNzZXJ0LmphdmE=) | `22.22% <50.00%> (+9.72%)` | :arrow_up: |
   | [...r/update/AlterShadowAlgorithmStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsL3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYWRvdy9kaXN0c3FsL2hhbmRsZXIvdXBkYXRlL0FsdGVyU2hhZG93QWxnb3JpdGhtU3RhdGVtZW50VXBkYXRlci5qYXZh) | `58.82% <58.82%> (ø)` | |
   | [...l/rdl/drop/impl/DropShadowRuleStatementAssert.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvYXNzZXJ0cy9zdGF0ZW1lbnQvZGlzdHNxbC9yZGwvZHJvcC9pbXBsL0Ryb3BTaGFkb3dSdWxlU3RhdGVtZW50QXNzZXJ0LmphdmE=) | `60.00% <60.00%> (ø)` | |
   | [...handler/update/DropShadowRuleStatementUpdater.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsL3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1kaXN0c3FsLWhhbmRsZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NoYWRvdy9kaXN0c3FsL2hhbmRsZXIvdXBkYXRlL0Ryb3BTaGFkb3dSdWxlU3RhdGVtZW50VXBkYXRlci5qYXZh) | `62.50% <62.50%> (ø)` | |
   | [...lter/impl/AlterShadowAlgorithmStatementAssert.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtdGVzdC9zaGFyZGluZ3NwaGVyZS1wYXJzZXItdGVzdC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvdGVzdC9zcWwvcGFyc2VyL3BhcmFtZXRlcml6ZWQvYXNzZXJ0cy9zdGF0ZW1lbnQvZGlzdHNxbC9yZGwvYWx0ZXIvaW1wbC9BbHRlclNoYWRvd0FsZ29yaXRobVN0YXRlbWVudEFzc2VydC5qYXZh) | `77.77% <77.77%> (ø)` | |
   | [.../metadata/schema/builder/TableMetaDataBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9zY2hlbWEvYnVpbGRlci9UYWJsZU1ldGFEYXRhQnVpbGRlci5qYXZh) | `80.76% <83.33%> (-5.60%)` | :arrow_down: |
   | [...e/infra/metadata/schema/builder/SchemaBuilder.java](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9tZXRhZGF0YS9zY2hlbWEvYnVpbGRlci9TY2hlbWFCdWlsZGVyLmphdmE=) | `100.00% <100.00%> (+81.25%)` | :arrow_up: |
   | ... and [139 more](https://codecov.io/gh/apache/shardingsphere/pull/12529/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [b978498...77d3068](https://codecov.io/gh/apache/shardingsphere/pull/12529?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713559382



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+
+## 18. [其他] ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+
+回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+
+由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+
+而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+

Review comment:
       Should this related to `KeyGenerateAlgorithm` also use the `[sharding]` tag?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713576566



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+

Review comment:
       We think this article is related to `JDBC`, because this problem will only occur when `JDBC` is integrated with `SPRING`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713584135



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+

Review comment:
       > 我们认为这篇文章是相关的`JDBC`,因为这个问题只有在`JDBC`与`SPRING`.
   
   ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-924529963


   > @lanchengx Hi could you have a review here?
   
   ok.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713586516



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+
+## 11. [分片] ShardingSphere提供的默认分布式自增主键策略为什么是不连续的,且尾数大多为偶数?
 
 回答:
 
-必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
+ShardingSphere采用snowflake算法作为默认的分布式自增主键策略,用于保证分布式的情况下可以无中心化的生成不重复的自增序列。因此自增主键可以保证递增,但无法保证连续。
+
+而snowflake算法的最后4位是在同一毫秒内的访问递增值。因此,如果毫秒内并发度不高,最后4位为零的几率则很大。因此并发度不高的应用生成偶数主键的几率会更高。
+
+在3.1.0版本中,尾数大多为偶数的问题已彻底解决,参见:https://github.com/apache/shardingsphere/issues/1617
+
+## 12. [分片] 如何在inline分表策略时,允许执行范围查询操作(BETWEEN AND、\>、\<、\>=、\<=)?
+
+回答:
+
+1. 需要使用4.1.0或更高版本。
+2. 调整以下配置项(需要注意的是,此时所有的范围查询将会使用广播的方式查询每一个分表):
+- 4.x版本:`allow.range.query.with.inline.sharding`设置为true即可(默认为false)。
+- 5.x版本:在InlineShardingStrategy中将`allow-range-query-with-inline-sharding`设置为true即可(默认为false)。
+
+## 13. [数据加密] JPA 和 数据加密无法一起使用,如何解决?
+
+回答:
+
+由于数据加密的DDL尚未开发完成,因此对于自动生成DDL语句的JPA与数据加密一起使用时,会导致JPA的实体类(Entity)无法同时满足DDL和DML的情况。
+
+解决方案如下:
+
+1. 以需要加密的逻辑列名编写JPA的实体类(Entity)。
+2. 关闭JPA的auto-ddl,如 auto-ddl=none。
+3. 手动建表,建表时应使用数据加密配置的`cipherColumn`,`plainColumn`和`assistedQueryColumn`代替逻辑列。
+
+## 14. [DistSQL] 使用DistSQL添加数据源时,如何设置自定义的JDBC连接参数或连接池属性?
+
+回答:
+
+1. 如需自定义JDBC参数,请使用 `urlSource` 的方式定义 `dataSource`。
+2. ShardingSphere预置了必要的连接池参数,如 `maxPoolSize`、`idleTimeout`等。如需增加或覆盖参数配置,请在 `dataSource` 中通过 `PROPERTIES` 指定。
+3. 以上规则请参考 [相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
+
+## 15. [其他] 如果SQL在ShardingSphere中执行不正确,该如何调试?
+
+回答:
+
+在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
+`sql.show`配置默认关闭,如果需要请通过配置开启。
+
+> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+
+## 16. [其他] 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+
+回答:
+
+ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+
+`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+
+```bash
+./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+```
+
+生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
+可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
 
-## 9. 使用SQLSever和PostgreSQL时,聚合列不加别名会抛异常?
+## 17. [其他] 使用Spring命名空间时找不到xsd?
+
+回答:
+
+Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+
+实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
+META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+

Review comment:
       > We think this article is related to `JDBC`, because this problem will only occur when `JDBC` is integrated with `SPRING`.
   
   ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx edited a comment on pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx edited a comment on pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#issuecomment-924598152


   > @lanchengx Hi, done, please review, thank you.
   
   @yx9o Thanks a lot, I don’t think there are any other problems.
   @tristaZero 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] yx9o commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
yx9o commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713583899



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -5,73 +5,176 @@ weight = 1
 chapter = true
 +++
 
-## 1. 如果SQL在ShardingSphere中执行不正确,该如何调试?
+## 1. [JDBC] 为什么配置了某个数据连接池的spring-boot-starter(比如druid)和shardingsphere-jdbc-spring-boot-starter时,系统启动会报错?
 
 回答:
 
-在ShardingSphere-Proxy以及ShardingSphere-JDBC 1.5.0版本之后提供了`sql.show`的配置,可以将解析上下文和改写后的SQL以及最终路由至的数据源的细节信息全部打印至info日志。
-`sql.show`配置默认关闭,如果需要请通过配置开启。
-
-> 注意:5.x版本以后,`sql.show`参数调整为`sql-show`。
+1. 因为数据连接池的starter(比如druid)可能会先加载并且其创建一个默认数据源,这将会使得ShardingSphere-JDBC创建数据源时发生冲突。
+2. 解决办法为,去掉数据连接池的starter即可,sharing-jdbc自己会创建数据连接池。
 
-## 2. 阅读源码时为什么会出现编译错误?IDEA不索引生成的代码?
+## 2. [Proxy] Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
 
 回答:
 
-ShardingSphere使用lombok实现极简代码。关于更多使用和安装细节,请参考[lombok官网](https://projectlombok.org/download.html)。
+某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
 
-`org.apache.shardingsphere.sql.parser.autogen` 包下的代码由 ANTLR 生成,可以执行以下命令快速生成:
+解决方案:
 
-```bash
-./mvnw -Dcheckstyle.skip=true -Drat.skip=true -Dmaven.javadoc.skip=true -Djacoco.skip=true -DskipITs -DskipTests install -T1C 
+打开cmd.exe并执行下面的命令:
+```
+tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
 ```
 
-生成的代码例如 `org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser` 等 Java 文件由于较大,默认配置的 IDEA 可能不会索引该文件。
-可以调整 IDEA 的属性:`idea.max.intellisense.filesize=10000`
+## 3. [Proxy] 在使用sharing-proxy的时候,如何动态在ShardingSphere-UI上添加新的logic schema?
 
-## 3. 使用Spring命名空间时找不到xsd?
+回答:
+
+1. 4.1.0之前的版本不支持动态添加或删除logic schema的功能,例如一个proxy启动的时候有2个logic schema,就会一直持有这2个schema,只能感知这两个schema内部的表和rule的变更事件。
+2. 4.1.0版本支持在ShardingSphere-UI或直接在zookeeper上增加新的logic schema,删除logic schema的功能计划在5.0.0版本支持。
+
+## 4. [Proxy] 在使用ShardingSphere-Proxy时,怎么使用合适的工具连接到ShardingSphere-Proxy?
 
 回答:
 
-Spring命名空间使用规范并未强制要求将xsd文件部署至公网地址,但考虑到部分用户的需求,我们也将相关xsd文件部署至ShardingSphere官网。
+1. ShardingSphere-Proxy可以看做是一个mysql server,所以首选支持mysql命令连接和操作。
+2. 如果使用其他第三方数据库工具,可能由于不同工具的特定实现导致出现异常。
+3. 目前已测试的第三方数据库工具如下:
+   - Navicat:11.1.13、15.0.20。
+   - DataGrip:2020.1、2021.1(使用 IDEA/DataGrip 时打开 `introspect using JDBC metadata` 选项)。
+   - WorkBench:8.0.25。
 
-实际上 shardingsphere-jdbc-spring-namespace 的 jar 包中 META-INF\spring.schemas 配置了 xsd 文件的位置:
-META-INF\namespace\sharding.xsd 和 META-INF\namespace\replica-query.xsd,只需确保 jar 包中该文件存在即可。
+## 5. [Proxy] 使用Navicat等第三方数据库工具连接ShardingSphere-Proxy时,如果ShardingSphere-Proxy没有创建Schema或者没有添加Resource,连接失败?
+
+回答:
+
+1. 第三方数据库工具在连接 ShardingSphere-Proxy 时会发送一些SQL查询元数据,当 ShardingSphere-Proxy 没有创建 `schema` 或者没有添加 `resource` 时,ShardingSphere-Proxy 无法执行 SQL。
+2. 推荐先创建 `schema` 和 `resource` 之后再使用第三方数据库工具连接。
+3. 有关 `resource` 的详情请参考。[相关介绍](https://shardingsphere.apache.org/document/current/cn/features/dist-sql/syntax/rdl/rdl-resource/)
 
-## 4. Cloud not resolve placeholder ... in string value ...异常的解决方法?
+## 6. [分片] Cloud not resolve placeholder ... in string value ...异常的解决方法?
 
 回答:
 
 行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
 
-## 5. inline表达式返回结果为何出现浮点数?
+## 7. [分片] inline表达式返回结果为何出现浮点数?
 
 回答:
 
 Java的整数相除结果是整数,但是对于inline表达式中的Groovy语法则不同,整数相除结果是浮点数。
 想获得除法整数结果需要将A/B改为A.intdiv(B)。
 
-## 6. 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
+## 8. [分片] 如果只有部分数据库分库分表,是否需要将不分库分表的表也配置在分片规则中?
 
 回答:
 
 不需要,ShardingSphere会自动识别。
 
-## 7. ShardingSphere除了支持自带的分布式自增主键之外,还能否支持原生的自增主键?
+## 9. [分片] 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
 
-回答:是的,可以支持。但原生自增主键有使用限制,即不能将原生自增主键同时作为分片键使用。
+回答:
 
-由于ShardingSphere并不知晓数据库的表结构,而原生自增主键是不包含在原始SQL中内的,因此ShardingSphere无法将该字段解析为分片字段。如自增主键非分片键,则无需关注,可正常返回;若自增主键同时作为分片键使用,ShardingSphere无法解析其分片值,导致SQL路由至多张表,从而影响应用的正确性。
+必须确保数据库表中该字段和分片算法该字段类型一致,如:数据库中该字段类型为int(11),泛型所对应的分片类型应为Integer,如果需要配置为Long类型,请确保数据库中该字段类型为bigint。
 
-而原生自增主键返回的前提条件是INSERT SQL必须最终路由至一张表,因此,面对返回多表的INSERT SQL,自增主键则会返回零。
+## 10. [分片] 使用`Proxool`时分库结果不正确?
+
+回答:
+
+使用Proxool配置多个数据源时,应该为每个数据源设置alias,因为Proxool在获取连接时会判断连接池中是否包含已存在的alias,不配置alias会造成每次都只从一个数据源中获取连接。
+
+以下是Proxool源码中ProxoolDataSource类getConnection方法的关键代码:
+
+```java
+    if(!ConnectionPoolManager.getInstance().isPoolExists(this.alias)) {
+        this.registerPool();
+    }
+```
 
-## 8. 指定了泛型为Long的`SingleKeyTableShardingAlgorithm`,遇到`ClassCastException: Integer can not cast to Long`?
+更多关于alias使用方法请参考[Proxool官网](http://proxool.sourceforge.net/configure.html)。
+
+PS:sourceforge网站需要翻墙访问。
+

Review comment:
       > This is related to the data source, I think the `[other]` tag is better, What do you think?
   
   ok.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] lanchengx commented on a change in pull request #12529: Fix #12480

Posted by GitBox <gi...@apache.org>.
lanchengx commented on a change in pull request #12529:
URL: https://github.com/apache/shardingsphere/pull/12529#discussion_r713554915



##########
File path: docs/document/content/others/faq/_index.cn.md
##########
@@ -194,26 +269,13 @@ git config --global core.longpaths true
 https://docs.microsoft.com/zh-cn/windows/desktop/FileIO/naming-a-file
 https://ourcodeworld.com/articles/read/109/how-to-solve-filename-too-long-error-in-git-powershell-and-github-application-for-windows
 
-## 14. Windows环境下,运行ShardingSphere-Proxy,找不到或无法加载主类 org.apache.shardingsphere.proxy.Bootstrap,如何解决?
-
-回答:
-
-某些解压缩工具在解压ShardingSphere-Proxy二进制包时可能将文件名截断,导致找不到某些类。
-
-解决方案:
-
-打开cmd.exe并执行下面的命令:
-```
-tar zxvf apache-shardingsphere-${RELEASE.VERSION}-shardingsphere-proxy-bin.tar.gz
-```
-
-## 15. Type is required 异常的解决方法?
+## 22. [其他] Type is required 异常的解决方法?
 
 回答:
 
 ShardingSphere中很多功能实现类的加载方式是通过[SPI](https://shardingsphere.apache.org/document/current/cn/features/pluggable-architecture/)注入的方式完成的,如分布式主键,注册中心等;这些功能通过配置中type类型来寻找对应的SPI实现,因此必须在配置文件中指定类型。
 
-## 16. 为什么我实现了`KeyGenerateAlgorithm`接口,也配置了Type,但是自定义的分布式主键依然不生效?
+## 23. [其他] 为什么我实现了`KeyGenerateAlgorithm`接口,也配置了Type,但是自定义的分布式主键依然不生效?
 

Review comment:
       Hi @yx9o ,
   Should the content related to `KeyGenerateAlgorithm` use the `[sharding]` tag?
   I found that this interface is in the `shardingsphere-sharding` module.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org