From 2e1dbee249bbfe53e4b219ba59f597a90c00f041 Mon Sep 17 00:00:00 2001 From: jianbin Date: Mon, 15 Jan 2024 16:44:06 +0800 Subject: [PATCH 1/3] bugfix: pgsql cluster mode is supported --- .../main/java/io/seata/rm/datasource/DataSourceProxy.java | 3 +++ .../java/io/seata/rm/datasource/DataSourceProxyTest.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java b/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java index 292859058db..7555a62e026 100644 --- a/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java +++ b/rm-datasource/src/main/java/io/seata/rm/datasource/DataSourceProxy.java @@ -352,6 +352,9 @@ private void initPGResourceId() { } else { resourceId = jdbcUrl; } + if (resourceId.contains(",")) { + resourceId = resourceId.replace(",", "|"); + } } /** diff --git a/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java b/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java index aafae33d0d0..29a3b5ccf91 100644 --- a/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java +++ b/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java @@ -142,6 +142,11 @@ public void getResourceIdTest() throws SQLException, NoSuchFieldException, Illeg resourceIdField.set(proxy, null); jdbcUrlField.set(proxy, "jdbc:postgresql://mock/postgresql?xxx=1111¤tSchema=schema1,schema2&yyy=1"); Assertions.assertEquals("jdbc:postgresql://mock/postgresql?currentSchema=schema1!schema2", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + + resourceIdField.set(proxy, null); + jdbcUrlField.set(proxy, "jdbc:postgresql://192.168.1.123:30100,192.168.1.124:30100?xxx=1111¤tSchema=schema1,schema2&yyy=1"); + Assertions.assertEquals("jdbc:postgresql://192.168.1.123:30100|192.168.1.124:30100?currentSchema=schema1!schema2", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + jdbcUrlField.set(proxy, jdbcUrl); } From 6896159fad98846e2e58e963e325c23cc3f19161 Mon Sep 17 00:00:00 2001 From: jianbin Date: Mon, 15 Jan 2024 16:47:53 +0800 Subject: [PATCH 2/3] bugfix: pgsql cluster mode is supported --- changes/en-us/2.x.md | 1 + changes/zh-cn/2.x.md | 1 + 2 files changed, 2 insertions(+) diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 86e99fb6b2c..8d60573d1bf 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -19,6 +19,7 @@ Add changes here for all PR submitted to the 2.x branch. - [[#6204](https://github.com/apache/incubator-seata/pull/6204)] fix the problem that The incorrect configuration needs to be fixed - [[#6248](https://github.com/apache/incubator-seata/pull/6248)] fix JDBC resultSet, statement, connection closing order - [[#6248](https://github.com/apache/incubator-seata/pull/6256)] fix raft-discovery cannot read registry configuration for seata-all sdk +- [[#6261](https://github.com/apache/incubator-seata/pull/6261)] AT mode support the URL of a PGSQL cluster ### optimize: diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 2f6fbc1f5a9..3a2c006d698 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -19,6 +19,7 @@ - [[#6204](https://github.com/apache/incubator-seata/pull/6204)] 修复错误配置问题 - [[#6248](https://github.com/apache/incubator-seata/pull/6248)] 修复JDBC resultSet, statement, connection关闭顺序 - [[#6248](https://github.com/apache/incubator-seata/pull/6256)] 修复在seata-all sdk下,raft-discovery模块不能读取registry.conf的配置的问题 +- [[#6261](https://github.com/apache/incubator-seata/pull/6261)] at模式支持pgsql集群模式url ### optimize: - [[#6031](https://github.com/apache/incubator-seata/pull/6031)] 添加undo_log表的存在性校验 From 43810dea7458d478c1f35058c9dd80e40d71db34 Mon Sep 17 00:00:00 2001 From: jianbin Date: Mon, 15 Jan 2024 17:13:40 +0800 Subject: [PATCH 3/3] bugfix: pgsql cluster mode is supported --- .../io/seata/rm/datasource/DataSourceProxyTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java b/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java index 29a3b5ccf91..ce791027faa 100644 --- a/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java +++ b/rm-datasource/src/test/java/io/seata/rm/datasource/DataSourceProxyTest.java @@ -133,6 +133,7 @@ public void getResourceIdTest() throws SQLException, NoSuchFieldException, Illeg Assertions.assertEquals("jdbc:mock:xxx/username", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); } + // case: dbType = postgresql { resourceIdField.set(proxy, null); @@ -150,6 +151,18 @@ public void getResourceIdTest() throws SQLException, NoSuchFieldException, Illeg jdbcUrlField.set(proxy, jdbcUrl); } + // case: dbType = dm + { + resourceIdField.set(proxy, null); + dbTypeField.set(proxy, io.seata.sqlparser.util.JdbcConstants.DM); + Assertions.assertEquals(jdbcUrl, proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + + resourceIdField.set(proxy, null); + jdbcUrlField.set(proxy, "jdbc:dm://mock/dm?xxx=1111&schema=schema1"); + Assertions.assertEquals("jdbc:dm://mock/dm?schema=schema1", proxy.getResourceId(), "dbType=" + dbTypeField.get(proxy)); + jdbcUrlField.set(proxy, jdbcUrl); + } + // case: dbType = mysql { resourceIdField.set(proxy, null);