devmadhuu commented on code in PR #11060:
URL: https://github.com/apache/ozone/pull/11060#discussion_r3853081125


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLayoutVersionManager.java:
##########
@@ -80,38 +92,47 @@ private int determineSLV() {
    * feature that is registered for finalization.
    */
   public void finalizeLayoutFeatures() {
-    // Get features that need finalization, sorted by version
-    List<ReconLayoutFeature> featuresToFinalize = getRegisteredFeatures();
-    LOG.debug("Starting finalization of {} features.", 
featuresToFinalize.size());
-
-    try (Connection connection = dataSource.getConnection()) {
-      connection.setAutoCommit(false); // Turn off auto-commit for 
transactional control
-
-      for (ReconLayoutFeature feature : featuresToFinalize) {
-        LOG.debug("Processing feature version: {}", feature.getVersion());
-        try {
-          // Fetch the action for the feature
-          Optional<ReconUpgradeAction> action = feature.getAction();
-          if (action.isPresent()) {
-            LOG.debug("Finalize action found for feature version: {}", 
feature.getVersion());
-            // Update the schema version in the database
-            updateSchemaVersion(feature.getVersion(), connection);
-
-            // Execute the upgrade action
-            action.get().execute(dataSource);
-
-            // Commit the transaction only if both operations succeed
-            connection.commit();
-            LOG.info("Feature versioned {} finalized successfully.", 
feature.getVersion());
-          } else {
-            LOG.info("No finalize action found for feature version: {}", 
feature.getVersion());
+    try {
+      repairTaskStatusSchemaIfRequired();

Review Comment:
   So actually this call eventually being called at every recon startup and not 
just behind MLV gate. So if in case execute throws any error, startup will also 
fail which seems ok, can you mention this behavior in PR description.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconTaskStatusTableUpgradeAction.java:
##########
@@ -63,33 +72,82 @@ private void setColumnAsNonNullable(DSLContext dslContext, 
String columnName) {
         .execute();
   }
 
+  /**
+   * Returns the JDBC nullability value for a column, or
+   * {@link #COLUMN_MISSING} if it does not exist.
+   */
+  private int getColumnNullability(Connection connection, String columnName)
+      throws SQLException {
+    DatabaseMetaData metaData = connection.getMetaData();
+    try (ResultSet columns = metaData.getColumns(null, null, null, null)) {
+      while (columns.next()) {
+        String table = columns.getString("TABLE_NAME");
+        String column = columns.getString("COLUMN_NAME");
+        if (RECON_TASK_STATUS_TABLE_NAME.equalsIgnoreCase(table)
+            && columnName.equalsIgnoreCase(column)) {
+          return columns.getInt("NULLABLE");
+        }
+      }
+    }
+    return COLUMN_MISSING;
+  }
+
+  private boolean tableExists(Connection connection) throws SQLException {

Review Comment:
   We can reuse the 
[TABLE_EXISTS_CHECK](https://github.com/apache/ozone/blob/a73e0529ba3067b083c1fead435a824ebfdfb2ad/hadoop-ozone/recon-codegen/src/main/java/org/apache/ozone/recon/schema/SqlDbUtils.java#L53).
 No need to create new method.



-- 
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