Skip to content

HDDS-15429. Fix updateAndRestart deadlock with BackgroundService.PeriodicalTask#10388

Merged
smengcl merged 1 commit into
apache:masterfrom
smengcl:HDDS-15429-deadlock
May 31, 2026
Merged

HDDS-15429. Fix updateAndRestart deadlock with BackgroundService.PeriodicalTask#10388
smengcl merged 1 commit into
apache:masterfrom
smengcl:HDDS-15429-deadlock

Conversation

@smengcl
Copy link
Copy Markdown
Contributor

@smengcl smengcl commented May 30, 2026

What changes were proposed in this pull request?

Any thread that calls shutdown() also can't hold the monitor lock on BackgroundService instance, in this case updateAndRestart. Otherwise, it can deadlock. This is a follow-up to HDDS-14645.

Context: #10378 (comment)

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15429

How was this patch tested?

  • n/a

@smengcl smengcl marked this pull request as ready for review May 30, 2026 20:44
Copilot AI review requested due to automatic review settings May 30, 2026 20:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request addresses a potential deadlock when runtime reconfiguration triggers updateAndRestart() on services built on BackgroundService, by ensuring shutdown() is not invoked while holding the service instance monitor (which is also used by BackgroundService.PeriodicalTask).

Changes:

  • Avoid calling shutdown() while holding the service monitor in DirectoryDeletingService.updateAndRestart.
  • Avoid calling shutdown() while holding the service monitor in BlockDeletingService.updateAndRestart.
  • Document the BackgroundService.shutdown() locking constraint to prevent similar deadlocks in other callers.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/service/DirectoryDeletingService.java Reworks updateAndRestart to call shutdown() outside the instance monitor, then reconfigure/restart under synchronization.
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java Adds Javadoc clarifying that calling shutdown() while holding the instance monitor can deadlock with PeriodicalTask.
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/BlockDeletingService.java Reworks updateAndRestart to call shutdown() outside the instance monitor, then reconfigure/restart under synchronization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@smengcl smengcl merged commit fcf2ca1 into apache:master May 31, 2026
61 checks passed
@smengcl
Copy link
Copy Markdown
Contributor Author

smengcl commented May 31, 2026

Thanks @adoroszlai for reviewing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants