Skip to content

Commit 86f3df1

Browse files
authored
HDDS-15103. OM termination due to race condition between om start and install snapshot (#10118)
1 parent 6d0be38 commit 86f3df1

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,8 +876,13 @@ public void testInstallSnapshotWithClientRead() throws Exception {
876876
long leaderOMSnapshotTermIndex = leaderOMTermIndex.getTerm();
877877

878878
// Start the inactive OM. Checkpoint installation will happen spontaneously.
879+
OzoneManager.setTestInstallSnapshot(true);
879880
cluster.startInactiveOM(followerNodeId);
880881
LogCapturer logCapture = LogCapturer.captureLogs(OzoneManager.class);
882+
assertLogCapture(logCapture, "OzoneManager is not in running state");
883+
assertLogCapture(logCapture, "Abort install snapshot from Leader");
884+
GenericTestUtils.waitFor(followerOM::isRunning, 100, 30_000);
885+
OzoneManager.setTestInstallSnapshot(false);
881886

882887
// Continuously read keys
883888
ExecutorService executor = Executors.newFixedThreadPool(1);

hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
488488
private static boolean testReloadConfigFlag = false;
489489
private static boolean testSecureOmFlag = false;
490490
private static UserGroupInformation testUgi;
491+
private static boolean testInstallSnapshot = false;
491492

492493
private final OzoneLockProvider ozoneLockProvider;
493494
private final OMPerformanceMetrics perfMetrics;
@@ -4063,6 +4064,12 @@ public List<OzoneAcl> getAcl(OzoneObj obj) throws IOException {
40634064
* @throws IOException if download or cleanup fails
40644065
*/
40654066
public synchronized TermIndex installSnapshotFromLeader(String leaderId) throws IOException {
4067+
if (!isRunning() || testInstallSnapshot) {
4068+
LOG.warn("OzoneManager is not in running state, state {}. Abort install snapshot from Leader.",
4069+
omState);
4070+
return null;
4071+
}
4072+
40664073
if (omRatisSnapshotProvider == null) {
40674074
LOG.error("OM Snapshot Provider is not configured as there are no peer " +
40684075
"nodes.");
@@ -4511,6 +4518,10 @@ public static void setTestReloadConfigFlag(boolean testReloadConfigFlag) {
45114518
OzoneManager.testReloadConfigFlag = testReloadConfigFlag;
45124519
}
45134520

4521+
public static void setTestInstallSnapshot(boolean testInstallSnapshot) {
4522+
OzoneManager.testInstallSnapshot = testInstallSnapshot;
4523+
}
4524+
45144525
public static void setTestSecureOmFlag(boolean testSecureOmFlag) {
45154526
OzoneManager.testSecureOmFlag = testSecureOmFlag;
45164527
}

0 commit comments

Comments
 (0)