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/12/24 10:22:27 UTC
[GitHub] [shardingsphere] sandynz commented on a change in pull request #14297: For #14281: Fix the problem that the replication stream slot of incremental tasks in PostgreSQL is occupied in the case of multiple data sources.
sandynz commented on a change in pull request #14297:
URL: https://github.com/apache/shardingsphere/pull/14297#discussion_r774965150
##########
File path: shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/test/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializerTest.java
##########
@@ -128,4 +130,15 @@ public void assertDestroyWhenSlotExists() throws SQLException {
new PostgreSQLPositionInitializer().destroy(dataSource);
verify(preparedStatement).execute();
}
+
+ /**
+ * Get the unique slot name by connection.
+ *
+ * @param conn the connection
+ * @return the unique name by connection
+ * @throws SQLException failed when getCatalog
+ */
+ public static String getUniqueSlotName(final Connection conn) throws SQLException {
+ return String.format("%s_%s", "sharding_scaling", conn.getCatalog());
+ }
Review comment:
Looks it's the same code as `PostgreSQLPositionInitializer.getUniqueSlotName`
##########
File path: shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/PostgreSQLPositionInitializer.java
##########
@@ -113,8 +113,19 @@ private void dropSlotIfExists(final Connection connection) throws SQLException {
log.info("drop, slot exist, slot name: {}", SLOT_NAME);
String dropSlotSQL = "SELECT pg_drop_replication_slot(?)";
try (PreparedStatement preparedStatement = connection.prepareStatement(dropSlotSQL)) {
- preparedStatement.setString(1, SLOT_NAME);
+ preparedStatement.setString(1, getUniqueSlotName(connection));
preparedStatement.execute();
}
}
+
+ /**
+ * Get the unique slot name by connection.
+ *
+ * @param conn the connection
+ * @return the unique name by connection
+ * @throws SQLException failed when getCatalog
+ */
+ public static String getUniqueSlotName(final Connection conn) throws SQLException {
Review comment:
Use `connection` instead of `conn` could be better, keep consistent variable naming.
--
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