Skip to content

fix(server): stop polling instances after deregistration - #6005

Merged
SteKoe merged 1 commit into
codecentric:masterfrom
Aminark:fix/stop-checking-deregistered-instances
Nov 28, 2026
Merged

SteKoe merged 1 commit into
codecentric:masterfrom
Aminark:fix/stop-checking-deregistered-instances

Conversation

@Aminark

@Aminark Aminark commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

The status and info monitors retained every instance ID they had checked. After an instance deregistered, each timer kept calling its updater and looking it up in the repository. In a deployment where instances are replaced regularly, the work per tick grew with the number of past instances.

Remove the ID from both schedules on deregistration. An update already in flight can refresh the completion time only while the ID is still tracked. A subsequent registration can start monitoring the same ID again.

Each trigger has a regression test that holds an update open, deregisters the instance, and lets the update finish. It verifies that another instance continues to be polled, that the removed ID stays quiet, and that polling resumes when it returns.

@Aminark
Aminark requested a review from a team as a code owner November 27, 2026 17:04
@SteKoe
SteKoe merged commit d820741 into codecentric:master Nov 28, 2026
2 checks passed
@Exar-lab

Copy link
Copy Markdown
Contributor

Thanks for this, the unbounded growth of the tracked IDs is a real problem. One side effect I want to flag after reading the diff.

checkNow sets lastChecked to Instant.MAX, and only markAsCheckedIfTracked (called from doFinally) lowers it again. Before this change a check that never completed was simply retried on the next tick, because the entry was only written when a check finished. Now a check that never completes leaves the entry at Instant.MAX, so that instance is never polled again until it is deregistered and registered again.

I confirmed the mechanics with a throwaway test on master (5b6662b6): IntervalCheck with a check function returning Mono.never(), interval 10 ms, minRetention zero, 500 ms of runtime.

  • via checkNow: the check function is called exactly once.
  • via markAsChecked (previous behavior): it is called more than 5 times.

What I could not verify is whether a real check can fail to complete. In StatusUpdater.doUpdateStatus only the HTTP call has a timeout (interval - 1s). repository.computeIfPresent has none, and neither does InfoUpdater. So a stalled event store write, for example with a clustered store, would never be bounded. I have no reproduction of that, so this is a robustness concern and not a confirmed bug.

If you agree, a small follow-up could add an outer .timeout(...) in StatusUpdateTrigger.updateStatus and InfoUpdateTrigger.updateInfo, so doFinally always runs. I am happy to open that PR. Let me know if you would rather handle it differently.

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