smengcl commented on code in PR #11246:
URL: https://github.com/apache/ozone/pull/11246#discussion_r4033233390
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java:
##########
@@ -547,24 +550,30 @@ public OnDemandContainerScanner getOnDemandScanner() {
* @throws IOException
*/
public void start(String clusterId) throws IOException {
- // If SCM HA is enabled, OzoneContainer#start() will be called multi-times
- // from VersionEndpointTask. The first call should do the initializing job,
- // the successive calls should wait until OzoneContainer is initialized.
- if (!initializingStatus.compareAndSet(
- InitializingStatus.UNINITIALIZED, InitializingStatus.INITIALIZING)) {
-
- // wait OzoneContainer to finish its initializing.
- while (initializingStatus.get() != InitializingStatus.INITIALIZED) {
- try {
- Thread.sleep(1);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
+ synchronized (initializationLock) {
+ // SCM endpoints share one initialization attempt, including its failure.
+ if (initializingStatus.get() == InitializingStatus.INITIALIZED) {
+ LOG.info("Ignore. OzoneContainer already started.");
+ return;
+ }
+ if (initializingStatus.get() == InitializingStatus.FAILED) {
+ throw new IOException("OzoneContainer initialization previously
failed", initializationFailure);
+ }
+
+ initializingStatus.set(InitializingStatus.INITIALIZING);
+ try {
+ initializeContainerServices(clusterId);
+ initializingStatus.set(InitializingStatus.INITIALIZED);
+ } catch (IOException | RuntimeException | Error ex) {
Review Comment:
This catch only records the terminal failure and immediately rethrows the
same throwable, including `OutOfMemoryError`. It does not attempt recovery.
Recording `FAILED` ensures other startup callers do not remain waiting for
successful initialization.
At the endpoint boundary, the failure triggers fatal shutdown. Executor
tasks capture `Error`s in their futures, so simply letting an `Error` escape
would not reliably terminate the DN. Actual heap exhaustion can still prevent
logging or orderly shutdown.
`InterruptedException` is not caught by this union. Acquiring a
`synchronized` monitor is noninterruptible, which is a separate limitation.
--
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]