Copilot commented on code in PR #10917:
URL: https://github.com/apache/ozone/pull/10917#discussion_r3698165240
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOMRatisSnapshots.java:
##########
@@ -597,6 +607,125 @@ public void
testInstallSnapshotFromLeaderFailedDownloadCleanupSucceeds()
followerOM.getOmSnapshotProvider().setInjector(null);
}
+ /**
+ * Regression test for bootstrap when leader logs are purged: checkpoint
install
+ * must proceed during {@code BOOTSTRAPPING} with the default v2 checkpoint
API,
+ * and bootstrap must complete so the new OM joins the Ratis group.
+ */
+ @Test
+ public void testBootstrapInstallSnapshotDuringBootstrapping() throws
Exception {
+ IOUtils.closeQuietly(client);
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+
+ OzoneConfiguration bootstrapConf = new OzoneConfiguration();
+
bootstrapConf.setInt(OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_KEY, 5);
+ bootstrapConf.setInt(OMConfigKeys.OZONE_OM_RATIS_LOG_PURGE_GAP,
BOOTSTRAP_LOG_PURGE_GAP);
+
bootstrapConf.setLong(OMConfigKeys.OZONE_OM_RATIS_SNAPSHOT_AUTO_TRIGGER_THRESHOLD_KEY,
+ SNAPSHOT_THRESHOLD);
+ bootstrapConf.setStorageSize(OMConfigKeys.OZONE_OM_RATIS_SEGMENT_SIZE_KEY,
16,
+ StorageUnit.KB);
+
bootstrapConf.setStorageSize(OMConfigKeys.OZONE_OM_RATIS_SEGMENT_PREALLOCATED_SIZE_KEY,
+ 16, StorageUnit.KB);
+
+ OzoneManagerRatisServerConfig omRatisConf =
+ bootstrapConf.getObject(OzoneManagerRatisServerConfig.class);
+ omRatisConf.setLogAppenderWaitTimeMin(10);
+ bootstrapConf.setFromObject(omRatisConf);
+
+ cluster = (MiniOzoneHAClusterImpl)
MiniOzoneCluster.newHABuilder(bootstrapConf)
+ .setOMServiceId(BOOTSTRAP_OM_SERVICE_ID)
+ .setNumOfOzoneManagers(2)
+ .setNumDatanodes(1)
+ .build();
+ cluster.waitForClusterToBeReady();
+
+ client = OzoneClientFactory.getRpcClient(BOOTSTRAP_OM_SERVICE_ID,
bootstrapConf);
+ objectStore = client.getObjectStore();
+ String bootstrapVolume = uniqueObjectName("volume");
+ String bootstrapBucket = uniqueObjectName("bucket");
+ objectStore.createVolume(bootstrapVolume);
+ OzoneVolume volume = objectStore.getVolume(bootstrapVolume);
+ volume.createBucket(bootstrapBucket,
+ BucketArgs.newBuilder().setBucketLayout(TEST_BUCKET_LAYOUT).build());
+ ozoneBucket = volume.getBucket(bootstrapBucket);
+
+ OzoneManager leader = cluster.getOMLeader();
+ writeKeysToIncreaseLogIndex(leader.getOmRatisServer(),
BOOTSTRAP_TARGET_LOG_INDEX);
+ assertThat(leader.getRatisSnapshotIndex())
+ .as("leader should have purged early logs")
+ .isGreaterThan((long) BOOTSTRAP_LOG_PURGE_GAP);
+
+ LogCapturer omLog = LogCapturer.captureLogs(OzoneManager.class);
+ LogCapturer stateMachineLog =
+ LogCapturer.captureLogs(OzoneManagerStateMachine.class);
+ LogCapturer snapshotProviderLog =
+ LogCapturer.captureLogs(RDBSnapshotProvider.class);
+ String newNodeId = "omNode-bootstrap-ratis-snapshots";
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ Future<?> bootstrapFuture = executor.submit(() -> {
+ try {
+ cluster.bootstrapOzoneManager(newNodeId);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ try {
+ waitForBootstrapCheckpointInstallToStart(omLog, snapshotProviderLog);
+ bootstrapFuture.get(BOOTSTRAP_COMPLETION_DEADLINE_MS,
TimeUnit.MILLISECONDS);
+ assertBootstrapOmJoinedRatisGroup(newNodeId);
+ } finally {
+ bootstrapFuture.cancel(true);
+ executor.shutdownNow();
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ }
Review Comment:
These LogCapturer instances add appenders to the underlying logger; without
calling stopCapturing(), the appenders can leak into subsequent tests and cause
flakiness/noisy logs. Please stop capturing in the finally block (even on
failure).
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -4201,9 +4201,9 @@ public List<OzoneAcl> getAcl(OzoneObj obj) throws
IOException {
* @throws IOException if download or cleanup fails
*/
public synchronized TermIndex installSnapshotFromLeader(String leaderId)
throws IOException {
- if (!isRunning() || testInstallSnapshot) {
- LOG.warn("OzoneManager is not in running state, state {}. Abort install
snapshot from Leader.",
- omState);
+ if (!isRunningOrBootstrapping() || testInstallSnapshot) {
+ LOG.warn("OzoneManager is not in running state nor bootstrapping, state
{}. "
+ + "Abort install snapshot from Leader.", omState);
return null;
}
Review Comment:
The WARN log in this guard can be misleading when install is aborted due to
the test hook (testInstallSnapshot) rather than the OM state. Consider handling
the test flag separately so the log message reflects the real reason for the
early return.
--
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]