kezhenxu94 commented on code in PR #10592:
URL: https://github.com/apache/skywalking/pull/10592#discussion_r1148377762


##########
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCHistoryDeleteDAO.java:
##########
@@ -75,16 +75,17 @@ public void deleteHistory(Model model, String 
timeBucketColumnName, int ttl) {
 
         final var ttlTables = tableHelper.getTablesForRead(model.getName(), 
startTimeBucket, endTimeBucket);
         final var tablesToDrop = new HashSet<String>();
+        final var tableName = TableHelper.getTableName(model);
 
         try (final var conn = jdbcClient.getConnection();
-             final var result = conn.getMetaData().getTables(null, null, 
TableHelper.getTableName(model) + "%", new String[]{"TABLE"})) {
+             final var result = conn.getMetaData().getTables(null, null, 
tableName + "%", new String[]{"TABLE"})) {
             while (result.next()) {
                 tablesToDrop.add(result.getString("TABLE_NAME"));
             }
         }
 
         ttlTables.forEach(tablesToDrop::remove);
-        tablesToDrop.removeIf(it -> !it.matches(".*_\\d{8}$"));
+        tablesToDrop.removeIf(it -> !it.matches(tableName + "_\\d{8}$"));

Review Comment:
   This fixes the issue when one model name is the prefix of another, the 
longer one will be deleted by mistake.
   
   Example: when model `meter_sumpermin` is deleting its outdated tables, the 
`meter_sumperminlabeled` will be deleted by mistake. Similar examples like 
`log` and `log_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-unsubscr...@skywalking.apache.org

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

Reply via email to