Skip to content

Commit

Permalink
switches volumes prior to recovery check (#4889)
Browse files Browse the repository at this point in the history
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 <ctubbsii@apache.org>
  • Loading branch information
keith-turner and ctubbsii committed Sep 18, 2024
1 parent 9f8c069 commit 07b1ec1
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<LogEntry>(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);
}
Expand Down

0 comments on commit 07b1ec1

Please sign in to comment.