ArafatKhan2198 commented on code in PR #7554:
URL: https://github.com/apache/ozone/pull/7554#discussion_r1879489996


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconSchemaManager.java:
##########
@@ -45,13 +49,46 @@ public ReconSchemaManager(Set<ReconSchemaDefinition> 
reconSchemaDefinitions) {
 
   @VisibleForTesting
   public void createReconSchema() {
-    reconSchemaDefinitions.forEach(reconSchemaDefinition -> {
-      try {
-        reconSchemaDefinition.initializeSchema();
-      } catch (SQLException e) {
-        LOG.error("Error creating Recon schema {}.",
-            reconSchemaDefinition.getClass().getSimpleName(), e);
-      }
-    });
+    // Calculate the latest SLV from ReconLayoutFeature
+    int latestSLV = calculateLatestSLV();
+
+    try {
+      // Initialize the schema version table first
+      reconSchemaDefinitions.stream()

Review Comment:
   We need to address this scenario that a customer will encounter:
   Case of Fresh Install :-
   
   - In a complete fresh install, all tables are created for the first time.
     - Since the code is at its latest version, the freshly created tables will 
also have the most up-to-date metadata.
     - However, when the schema version table is created during the fresh 
install, it will initially be empty. When the Recon Finalize Layout Feature 
runs, it attempts to fetch the latest MLV from the schema version table. As 
there are no records in the table, the current implementation returns `-1`.
     - This causes the Recon Layout Version Manager to assume that the schema 
is old due to latest MLV being -1 and triggers all upgrade actions for versions 
`0, 1, 2, 3,` etc. This is unnecessary and incorrect, as all other tables are 
already created with the latest metadata.
     - The current behaviour leads to redundant upgrade actions being executed 
on a fresh install, which needs to be corrected.
     
   <img width="1625" alt="image" 
src="https://github.com/user-attachments/assets/d9152612-f3f3-4835-b7da-7142e78b2f7a";>
   



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