devmadhuu commented on code in PR #8962:
URL: https://github.com/apache/ozone/pull/8962#discussion_r2315815056
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/OzoneManagerServiceProviderImpl.java:
##########
@@ -776,13 +796,22 @@ private void executeFullSnapshot(ReconTaskStatusUpdater
fullSnapshotReconTaskUpd
fullSnapshotReconTaskUpdater.recordRunCompletion();
deltaReconTaskStatusUpdater.updateDetails();
+ // Update the current OM metadata manager in task controller
+ reconTaskController.updateOMMetadataManager(omMetadataManager);
+
// Reinitialize tasks that are listening.
- LOG.info("Calling reprocess on Recon tasks.");
- reconTaskController.reInitializeTasks(omMetadataManager, null);
+ LOG.info("Queueing async reinitialization event instead of blocking
call");
+ 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 snapshot operation",
+ result);
+ metrics.incrNumSnapshotRequestsFailed();
+ fullSnapshotReconTaskUpdater.setLastTaskRunStatus(-1);
Review Comment:
done.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/ReconTaskControllerImpl.java:
##########
@@ -431,4 +457,156 @@ public boolean hasDeltaTasksFailed() {
public void resetDeltaTasksFailureFlag() {
deltaTasksFailed.set(false);
}
+
+ @Override
+ public boolean
queueReInitializationEvent(ReconTaskReInitializationEvent.ReInitializationReason
reason) {
+ LOG.info("Queueing task reinitialization event due to: {}", reason);
+
+ try {
+ // Create checkpoint of current OM metadata manager before queueing
reinitialization event
+ // This prevents data inconsistency as parallel DB updates will continue
on the original
+ // omMetadataManager reference while reinitialization uses the
checkpointed snapshot
+ ReconOMMetadataManager checkpointedOMMetadataManager =
createOMCheckpoint(currentOMMetadataManager);
+
+ resetEventBuffer();
+
+ // Create and queue the reinitialization event with checkpointed
metadata manager
+ ReconTaskReInitializationEvent reinitEvent =
+ new ReconTaskReInitializationEvent(reason,
checkpointedOMMetadataManager);
+ boolean queued = eventBuffer.offer(reinitEvent);
+ if (!queued) {
+ // CAUTION: If this failure happens, something is seriously wrong as
we just cleared the buffer
+ // and are trying to queue a single event, also since we cleared all
other delta events, next delta sync cycle
+ // will not have these lost events as new OMDBUpdatesHandler will be
created with last sequence number
+ LOG.error(
+ "Failed to queue reinitialization event. Ideally should not
happen, so dropping event and " +
+ "checkpointed data.");
+ // Close the checkpointed metadata manager as it won't be used
+ try {
+ checkpointedOMMetadataManager.stop();
+ } catch (Exception e) {
+ LOG.warn("Failed to close checkpointed OM metadata manager", e);
+ }
+ return false;
+ }
+ resetEventBufferOverflowFlag();
+ resetDeltaTasksFailureFlag();
+ return true;
+ } catch (IOException e) {
+ LOG.error("Failed to create checkpoint for reinitialization", e);
+ return false;
+ }
+ }
+
+ @Override
+ public void resetEventBuffer() {
+ // Clear the buffer to discard all pending events
+ eventBuffer.clear();
+ }
+
+ @Override
+ public void updateOMMetadataManager(ReconOMMetadataManager
omMetadataManager) {
+ this.currentOMMetadataManager = omMetadataManager;
+ }
+
+ @Override
+ public ReconOMMetadataManager createOMCheckpoint(ReconOMMetadataManager
omMetaManager)
+ throws IOException {
+ // Create temporary directory for checkpoint
+ String parentPath = cleanTempCheckPointPath(omMetaManager);
Review Comment:
ok done.
--
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]