You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/06/07 20:55:07 UTC

[GitHub] [druid] capistrant commented on a diff in pull request #12599: Add a configurable bufferPeriod between when a segment is marked unused and deleted by KillUnusedSegments duty

capistrant commented on code in PR #12599:
URL: https://github.com/apache/druid/pull/12599#discussion_r891701422


##########
server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java:
##########
@@ -408,6 +447,50 @@ tableName, getSerialType(), getPayloadType()
     );
   }
 
+  /**
+   * Adds the last_used column to the Druid segment table.
+   *
+   * This is public due to allow the UpdateTables cli tool to use for upgrade prep.
+   */
+  @Override
+  public void alterSegmentTableAddLastUsed()
+  {
+    String tableName = tablesConfigSupplier.get().getSegmentsTable();
+    if (!tableHasColumn(tableName, "last_used")) {
+      log.info("Adding last_used column to %s", tableName);
+      alterTable(
+          tableName,
+          ImmutableList.of(
+              StringUtils.format(
+                  "ALTER TABLE %1$s \n"
+                  + "ADD last_used varchar(255)",
+                  tableName
+              )
+          )
+      );
+    } else {
+      log.info("%s already has last_used column", tableName);
+    }
+  }
+
+  /**
+   * Populates the last_used column for all unused segments in the Druid segment table.
+   *
+   * The current UTC timestamp string is used for the content of each column.
+   * This is public due to allow the UpdateTables cli tool to use in a optional post-upgrade action.
+   */
+  @Override
+  public void updateSegmentTablePopulateLastUsed()

Review Comment:
   I suspect we want an existence check on table



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org