Skip to content

[bugfix] Fix duplicate collector job timeouts#4169

Open
hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:codex/fix-hertzbeat-4153-timer-duplicate
Open

[bugfix] Fix duplicate collector job timeouts#4169
hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:codex/fix-hertzbeat-4153-timer-duplicate

Conversation

@hutiefang76

Copy link
Copy Markdown

What's changed?

Fixes #4153.

When the collector receives the same job id again, TimerDispatcher replaced the timeout stored in the task map but did not cancel the previous HashedWheelTimer timeout. The replaced timeout could stay active until it fired, so repeated job updates may accumulate unnecessary HashedWheelTimeout instances.

This change cancels the previous timeout when a cyclic or temporary job is replaced by a new timeout for the same job id. It keeps the latest timeout in the map and only cancels the old one.

Added regression coverage for both cyclic and temporary jobs to verify that:

  • the timeout map is updated to the new timeout
  • the old timeout is cancelled
  • the new timeout remains active

Validation:

  • git diff --check -- hertzbeat-collector/hertzbeat-collector-common/src/main/java/org/apache/hertzbeat/collector/timer/TimerDispatcher.java hertzbeat-collector/hertzbeat-collector-common/src/test/java/org/apache/hertzbeat/collector/timer/TimerDispatcherTest.java
  • ./mvnw -pl hertzbeat-collector/hertzbeat-collector-common -am -Dsurefire.failIfNoSpecifiedTests=false test

Checklist

  • I have read the Contributing Guide
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Add or update API

No API is added or updated in this PR.

  • I have added the necessary e2e tests and all cases have passed.

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.

[BUG] 内存溢出,HashedWheelTimer无法回收

1 participant