Skip to content

fix: preserve target status during healthcheck retries - #14261

Draft
moonming wants to merge 8 commits into
apache:masterfrom
moonming:codex/healthcheck-preserve-target-status
Draft

moonming wants to merge 8 commits into
apache:masterfrom
moonming:codex/healthcheck-preserve-target-status

Conversation

@moonming

@moonming moonming commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes #14276. Follow-up to #14218.

When only upstream nodes change and an incremental target update fails, rebuilding the live checker discards its worker-local health information. Keep the checker and its current configuration version until the update succeeds. The working-pool timer retries without requiring route traffic.

This change relies on api7/lua-resty-healthcheck#77 to protect the complete target list while replacing it in shared memory. A failed staging write leaves the previous list authoritative. If replacing the primary key deletes its old value, readers can use the committed staged list while the primary remains unavailable. Independent eviction of all registration lists is tracked separately in #14277.

Validation

Tested APISIX master eb836dbf0 with these changes using etcd 3.5.15, the real Admin API, active probes, the library's working timers, and HTTP upstreams. The fault hook targets real shared-dictionary writes. The suites distinguish a rejected update from a committed update whose primary write failed.

  • With library PR optimize: used lru way to cache the validator object for schema. #77 at 98c7ed9, the target-list replacement, initial retry and existing incremental-update suites passed 149/149 assertions (23 + 53 + 73).
  • When the failed write rejects a mixed removal/addition, the previous node remains listed until retry, the manager clears the removed state, and 40/40 requests reach healthy upstreams. Updating the probe Host before retry routes 20/20 requests to the two healthy upstreams.
  • A failed primary write during delayed cleanup can commit through the staged copy. The rebuilt checker removes the old node, preserves the unhealthy survivor and starts a re-added node healthy.
  • Holding both the primary replacement and its republication unavailable leaves the staged list serving 40/40 requests to healthy upstreams. The primary remains absent throughout that traffic. Once writes resume, re-add republishes the primary and starts healthy.
  • Restoring only the manager from APISIX master while keeping the candidate library makes the nodes-only addition and removal/re-add cases fail their checker-reuse assertions. Both paths create a replacement checker.
  • With either the current 3.2.5-0 pin or the published 3.2.6-0 release, the first two suites pass 53/76 assertions. These releases do not implement the staged-list contract.
  • make lint, the repository-wide codespell 2.1.0 check, LuaJIT compilation and git diff --check passed.

Draft release dependency. The rockspec still pins 3.2.5-0. Upgrade it only after a release containing the library fix is published, then rerun the suites on the published package and verify CI.

Checklist

  • I have explained the problem and implementation.
  • I have added tests for the affected request and configuration paths.
  • I have checked public API and configuration compatibility. This internal reliability change requires no documentation update.

@moonming
moonming marked this pull request as draft November 24, 2026 12:05
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.

bug: a partial healthcheck target update can discard a live checker when only upstream nodes change

1 participant