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 2022/04/13 16:31:07 UTC

[GitHub] [shardingsphere] terrymanu commented on a diff in pull request #16796: Shardingsphere-proxy fails to establish a connection when it proxies multiple versions of mysql databases

terrymanu commented on code in PR #16796:
URL: https://github.com/apache/shardingsphere/pull/16796#discussion_r849672802


##########
shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/java/org/apache/shardingsphere/proxy/version/ShardingSphereProxyVersion.java:
##########
@@ -62,8 +57,13 @@ private static String getProxyVersion() {
         return result;
     }
     
-    private static Optional<DataSource> findSampleBackendDataSource(final ContextManager contextManager) {
-        Optional<ShardingSphereMetaData> metaData = contextManager.getMetaDataContexts().getMetaDataMap().values().stream().filter(ShardingSphereMetaData::isComplete).findFirst();
-        return metaData.flatMap(optional -> optional.getResource().getDataSources().values().stream().findFirst());
+    private static void setDatabaseVersion(final String schemaName, final Map<String, DataSource> dataSources) {
+        Optional<DataSource> dataSource = dataSources.values().stream().findFirst();
+        if (!dataSource.isPresent()) {
+            return;
+        }
+        DatabaseServerInfo databaseServerInfo = new DatabaseServerInfo(dataSource.get());
+        log.info("{}, schema name is `{}`", databaseServerInfo.toString(), schemaName);
+        DatabaseProtocolFrontendEngineFactory.newInstance(DatabaseTypeRegistry.getTrunkDatabaseType(databaseServerInfo.getDatabaseName())).setDatabaseVersion(schemaName, databaseServerInfo.getDatabaseVersion());

Review Comment:
   Error:  src/main/java/org/apache/shardingsphere/proxy/version/ShardingSphereProxyVersion.java:[67] (sizes) LineLength: Line is longer than 200 characters (found 211).
   
   Please fix checkstyle error



##########
shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLServerInfo.java:
##########
@@ -34,27 +38,38 @@ public final class MySQLServerInfo {
     
     public static final MySQLCharacterSet DEFAULT_CHARSET = MySQLCharacterSet.UTF8MB4_GENERAL_CI;
     
-    private static final String DEFAULT_MYSQL_VERSION = "5.7.22";
+    private static final String DEFAULT_MYSQL_VERSION = "5.6.23";

Review Comment:
   Change version is dangers, please keep the version as `5.7.22`, we need to do enough test if we design to change the default version.



-- 
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