ArafatKhan2198 commented on code in PR #9127:
URL: https://github.com/apache/ozone/pull/9127#discussion_r2431603804
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/NSSummaryCodec.java:
##########
@@ -95,6 +96,7 @@ public NSSummary fromPersistedFormatImpl(byte[] rawData)
throws IOException {
NSSummary res = new NSSummary();
res.setNumOfFiles(in.readInt());
res.setSizeOfFiles(in.readLong());
+ res.setReplicatedSizeOfFiles(in.readLong());
Review Comment:
The `fromPersistedFormatImpl()` method reads the new `replicatedSizeOfFiles`
field unconditionally:
```
res.setSizeOfFiles(in.readLong());
res.setReplicatedSizeOfFiles(in.readLong()); // ❌ No version check!
```
But it has version checking for parentId:
```
if (in.available() >= Long.BYTES) {
long parentId = in.readLong();
res.setParentId(parentId);
} else {
res.setParentId(-1); // Default for old format
}
```
Issue: When reading old NSSummary entries (before the upgrade), this will
try to read `replicatedSizeOfFiles` from data that doesn't contain it, leading
to `IndexOutOfBoundsException`
Will have to do an upgrade testing to verify this could be a problem.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReplicatedSizeOfFilesUpgradeAction.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.recon.upgrade;
+
+import com.google.inject.Injector;
+import javax.sql.DataSource;
+import org.apache.hadoop.ozone.recon.ReconGuiceServletContextListener;
+import org.apache.hadoop.ozone.recon.tasks.ReconTaskController;
+import org.apache.hadoop.ozone.recon.tasks.ReconTaskReInitializationEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Upgrade action for the REPLICATED_SIZE_OF_FILES layout feature.
+ * The action triggers a full rebuild of the NSSummary ensuring that the new
field: replicatedSizeOfFiles is correctly
+ * populated for all objects.
+ */
+@UpgradeActionRecon(feature = ReconLayoutFeature.REPLICATED_SIZE_OF_FILES,
+ type = ReconUpgradeAction.UpgradeActionType.FINALIZE)
+public class ReplicatedSizeOfFilesUpgradeAction implements ReconUpgradeAction {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ReplicatedSizeOfFilesUpgradeAction.class);
+
+ @Override
+ public void execute(DataSource dataSource) {
+ try {
+ Injector injector = ReconGuiceServletContextListener.getStaticInjector();
+ if (injector == null) {
+ throw new IllegalStateException("Guice injector is not initialized.
Cannot perform NSSummary rebuild.");
+ }
+ ReconTaskController reconTaskController =
injector.getInstance(ReconTaskController.class);
+ LOG.info("Starting full rebuild of NSSummary for
REPLICATED_SIZE_OF_FILES upgrade...");
+ ReconTaskController.ReInitializationResult result =
reconTaskController.queueReInitializationEvent(
+
ReconTaskReInitializationEvent.ReInitializationReason.MANUAL_TRIGGER);
+ if (result != ReconTaskController.ReInitializationResult.SUCCESS) {
+ LOG.error(
+ "Failed to queue reinitialization event for manual trigger
(result: {}), failing the reinitialization " +
+ "during NSSummaryAggregatedTotalsUpgrade action, will be
retried as part of syncDataFromOM " +
+ "scheduler task.", result);
+ }
+ LOG.info("Completed full rebuild of NSSummary for
REPLICATED_SIZE_OF_FILES upgrade.");
Review Comment:
Logs success even when it failed
--
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]