Skip to content

HDDS-14645. Speed up TestBlockDeletingService#10378

Merged
adoroszlai merged 1 commit into
apache:masterfrom
adoroszlai:HDDS-14645-simple
May 30, 2026
Merged

HDDS-14645. Speed up TestBlockDeletingService#10378
adoroszlai merged 1 commit into
apache:masterfrom
adoroszlai:HDDS-14645-simple

Conversation

@adoroszlai
Copy link
Copy Markdown
Contributor

@adoroszlai adoroszlai commented May 28, 2026

What changes were proposed in this pull request?

PeriodicalTask runs in BackgroundService's executor, and wants to lock BackgroundService before spawning background tasks. BackgroundService.shutdown should not awaitTermination of the executor while holding the same lock: if shutdown is initiated while the task is before the critical section, the task cannot complete, causing awaitTermination to timeout after 1 minute.

"BlockDeletingService#0" #223 [893291] daemon prio=5 os_prio=0 cpu=1.69ms elapsed=42.58s allocated=49192B defined_classes=0 tid=0x0000721a69ac9790 nid=893291 waiting for monitor entry  [0x0000721a4082d000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at org.apache.hadoop.hdds.utils.BackgroundService$PeriodicalTask.run(BackgroundService.java:165)

...

"main" #1 [891422] prio=5 os_prio=0 cpu=2925.67ms elapsed=247.75s allocated=431M defined_classes=6151 tid=0x0000721a6801c170 nid=891422 waiting on condition  [0x0000721a6f7fa000]
	...
	at java.util.concurrent.ThreadPoolExecutor.awaitTermination(java.base@21.0.10/ThreadPoolExecutor.java:1475)
	at org.apache.hadoop.hdds.utils.BackgroundService.shutdown(BackgroundService.java:198)
	- locked <0x000000060b86a0d0> (a org.apache.hadoop.ozone.container.common.impl.BlockDeletingService)

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

How was this patch tested?

Before:

Tests run: 72, Failures: 0, Errors: 0, Skipped: 4, Time elapsed: 325.3 s -- in org.apache.hadoop.ozone.container.common.TestBlockDeletingService

After:

Tests run: 72, Failures: 0, Errors: 0, Skipped: 4, Time elapsed: 25.42 s -- in org.apache.hadoop.ozone.container.common.TestBlockDeletingService

https://github.com/adoroszlai/ozone/actions/runs/26556849091

@adoroszlai adoroszlai self-assigned this May 28, 2026
@adoroszlai adoroszlai requested a review from smengcl May 28, 2026 19:39
Copy link
Copy Markdown
Contributor

@SaketaChalamchala SaketaChalamchala left a comment

Choose a reason for hiding this comment

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

Thanks for the patch @adoroszlai. LGTM

LOG.info("Shutting down service {}", this.serviceName);
exec.shutdown();
final ScheduledThreadPoolExecutor current;
synchronized (this) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it necessary to synchronize here and assign current = exec? I mean the reference is essentially immutable after initialization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Spotbugs may complain about inconsistent synchronization. That's why shutdown was changed to synchronized in HDDS-13320 (#8677 (comment), 57f39f9).

@adoroszlai adoroszlai merged commit ee0de97 into apache:master May 30, 2026
48 checks passed
@adoroszlai adoroszlai deleted the HDDS-14645-simple branch May 30, 2026 05:30
@adoroszlai
Copy link
Copy Markdown
Contributor Author

Thanks @jojochuang, @SaketaChalamchala for the review.

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.

4 participants