funky-eyes commented on code in PR #7071:
URL: https://github.com/apache/incubator-seata/pull/7071#discussion_r1895273444


##########
rm-datasource/src/main/java/org/apache/seata/rm/datasource/DataSourceProxy.java:
##########
@@ -210,6 +210,11 @@ public String getDbType() {
     @Override
     public ConnectionProxy getConnection() throws SQLException {
         Connection targetConnection = targetDataSource.getConnection();
+        //如果是读写分离,在用aop设置主库的时候,会走这里,需要重新设置resourceId
+        if (targetConnection!=null) {
+            this.jdbcUrl = targetConnection.getMetaData().getURL();

Review Comment:
   1.为什么要代理只读的从库?
   2.这个方式能让兼容大部分的场景吗?只要是从库直接通过`targetConnection.getMetaData().getURL();` 
得到的一定是主库的url?
   
   Why proxy the read-only replica?
   Does this approach work for most scenarios? If it's a replica, will 
`targetConnection.getMetaData().getURL();` always return the URL of the primary 
database?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to