Skip to content

HDDS-16926. Cancel pending health check on NodeStateManager close - #11480

Draft
smengcl wants to merge 2 commits into
apache:masterfrom
smengcl:HDDS-16926
Draft

smengcl wants to merge 2 commits into
apache:masterfrom
smengcl:HDDS-16926

Conversation

@smengcl

@smengcl smengcl commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Generated-by: Claude Code (Opus 5.5)

What changes were proposed in this pull request?

NodeStateManager schedules its health check as a one-shot task ozone.scm.heartbeat.thread.interval (3s by default) in the future, and reschedules it after each run. close() calls executorService.shutdown(), which still lets already scheduled delayed tasks run, and then awaitTermination. As a result close() blocks until the pending health check fires, up to 3s. This delays every SCM stop, and every test that closes a real SCMNodeManager pays the wait once per test.

This PR sets setExecuteExistingDelayedTasksAfterShutdownPolicy(false) on the executor, so shutdown() discards the pending health check and close() no longer waits for it.

Test class time in CI, four recent master runs compared to a run of this fix on my fork:

Test class master (s) with fix (s)
TestDeletedBlockLog 99 to 100 16.0
TestSCMNodeManager 118 to 119 54.5
TestSCMBlockProtocolServer 52 9.2
TestIncrementalContainerReportHandler 38 3.2
TestReconNodeManager 30 3.2
TestDeadNodeHandler 15 5.2

What is the link to the Apache JIRA

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

How was this patch tested?

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 12, 2026 04:30

Copilot AI left a comment

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.

🟡 Changes recommended

Shutdown cancellation can race with health-check rescheduling, allowing delayed tasks to keep close() blocked.

1 open finding
What changed in this PR

This PR reduces SCM shutdown latency by cancelling the pending NodeStateManager health check and adding regression coverage.

Changes:

  • Cancel the scheduled health-check task during shutdown.
  • Add a test ensuring close() returns promptly.
File Description
hadoop-hdds/​server-scm/​src/​test/​java/​org/​apache/​hadoop/​hdds/​scm/​node/​TestNodeStateManager.java Verifies close() does not wait for the delayed health check.
hadoop-hdds/​server-scm/​src/​main/​java/​org/​apache/​hadoop/​hdds/​scm/​node/​NodeStateManager.java Cancels the pending health-check task during shutdown.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…olicy

Cancelling the future in close() could race with a running health check that reschedules itself before shutdown(). Let shutdown() discard delayed tasks instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants