Skip to content

fix(healthcheck): read shm status so workers do not keep unhealthy nodes - #13894

Open
BetterAndBetterII wants to merge 1 commit into
apache:masterfrom
BetterAndBetterII:fix/healthcheck-worker-state-diverge
Open

fix(healthcheck): read shm status so workers do not keep unhealthy nodes#13894
BetterAndBetterII wants to merge 1 commit into
apache:masterfrom
BetterAndBetterII:fix/healthcheck-worker-state-diverge

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Description

Active health checks write the real target state to shared memory, then notify other nginx workers over resty.events. Routing still used get_target_status(), which only reads that worker-local cache, and the balancer picker was keyed on checker.status_ver (bumped only when this worker receives the event).

A worker that missed the event (or whose checker was created after another worker already flipped the node) kept sending traffic to a node that was already unhealthy in shm — for minutes in multi-worker deployments with priority failover.

This change:

  1. Consults shm first in fetch_node_status (falling back to the local cache when shm has no entry yet).
  2. Includes shm health in the picker / health-status cache key so a shm-only flip rebuilds the picker without waiting for a local event.

Checklist

  • I have explained the purpose of this PR based on the related issue.
  • I have added related tests.
  • I have updated related documents.
  • I have resolved conflicts related to this PR.

Fixes #13888

Active checks write health to shared memory, then notify peers over
resty.events. Routing still used get_target_status(), which only reads
the worker-local cache, and the balancer picker was keyed on
status_ver (bumped only on a local event). A worker that missed the
event kept sending traffic to a node already marked unhealthy in shm.

Consult shm in fetch_node_status and include shm health in the picker
cache key so a shm-only flip rebuilds the picker.

Fixes apache#13888
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

1 participant