From 07b1ec1a54fbc406cc02d989e60abb9c3f947ecc Mon Sep 17 00:00:00 2001 From: Keith Turner Date: Tue, 17 Sep 2024 20:13:45 -0400 Subject: [PATCH] switches volumes prior to recovery check (#4889) In #4873 a check was added to inspect walogs during tablet load to see if they had any data for the tablet. This check happens prior to volume replacement that also runs during tablet load. Therefore if volume replacement is needed for the walogs then this check will fail because it can not find the files and the tablet will fail to load. To fix this problem modified the new check to switch volumes if needed prior to running the check. Co-authored-by: Christopher Tubbs --- .../apache/accumulo/tserver/TabletServer.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java index eae66377020..2cb9caf23ca 100644 --- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java +++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java @@ -116,6 +116,7 @@ import org.apache.accumulo.server.conf.TableConfiguration; import org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl; import org.apache.accumulo.server.fs.VolumeManager; +import org.apache.accumulo.server.fs.VolumeUtil; import org.apache.accumulo.server.log.WalStateManager; import org.apache.accumulo.server.log.WalStateManager.WalMarkerException; import org.apache.accumulo.server.rpc.ServerAddress; @@ -1087,8 +1088,23 @@ public boolean needsRecovery(TabletMetadata tabletMetadata) { return false; } + // This method is called prior to volumes being switched for a tablet during the load process, + // so switch volumes before calling needsRecovery() + var switchedLogEntries = new ArrayList(logEntries.size()); + for (LogEntry logEntry : logEntries) { + var switchedWalog = VolumeUtil.switchVolume(logEntry, context.getVolumeReplacements()); + LogEntry walog; + if (switchedWalog != null) { + log.debug("Volume switched for needsRecovery {} -> {}", logEntry, switchedWalog); + walog = switchedWalog; + } else { + walog = logEntry; + } + switchedLogEntries.add(walog); + } + try { - return logger.needsRecovery(getContext(), tabletMetadata.getExtent(), logEntries); + return logger.needsRecovery(getContext(), tabletMetadata.getExtent(), switchedLogEntries); } catch (IOException e) { throw new UncheckedIOException(e); }