# Policy monitor stops dispatching: agents enroll and check in but never receive their first policy

**URL:** <https://discuss.elastic.co/t/policy-monitor-stops-dispatching-agents-enroll-and-check-in-but-never-receive-their-first-policy/391759>\
**Category:** Elastic Security\
**Created:** [November 20, 2026, 4:31pm UTC](https://discuss.elastic.co/t/policy-monitor-stops-dispatching-agents-enroll-and-check-in-but-never-receive-their-first-policy/391759 "2026-11-20T16:31:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nblair2](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@nblair2](https://discuss.elastic.co/u/nblair2)\
**Post date:** [November 20, 2026, 4:31pm UTC](https://discuss.elastic.co/t/policy-monitor-stops-dispatching-agents-enroll-and-check-in-but-never-receive-their-first-policy/391759/1 "2026-11-20T16:31:58Z")

</div>

I think I have a bug that I want to report. GitHub discourages making issues and points this way.

**Repo:** elastic/fleet-server (`internal/pkg/policy/monitor.go`)

**Version:** Fleet Server, Elastic Agent, Elasticsearch and Kibana 9.5.5. Fleet Server runs as the  
`elastic-agent` container; a single Fleet Server, default limits (`run policy monitor burst=1 rate=200`).

## What happens

A fresh deployment enrolls 9 Windows agents into one agent policy within about a minute of each  
other. Six receive the policy normally. The other three enroll, keep checking in, and stay at

```auto
fleet: (HEALTHY) Connected
elastic-agent: (STARTING) Waiting for initial configuration and composable variables

```

indefinitely (observed for more than nine hours). Kibana shows them as `updating` with  
`policy_revision: null`. They run no inputs and ship no data. Neither Fleet Server nor the agents  
log a warning or an error about it.

The same deployment was brought up four times from identical images and configuration. It  
happened in one of the four.

## Timeline

Times are relative to the first Windows enrollment. "First check-in" is the first  
`applying new components data` line for the agent; "dispatched" is `generating output API key`.

| Agent | Enrolled | First check-in | Dispatched |
| --- | --- | --- | --- |
| A | +0:00.0 | +1:20.0 | +1:20.2 |
| B | +0:00.0 | +1:20.2 | +1:20.5 |
| C | +0:06.0 | +1:26.0 | +1:26.3 |
| D | +0:32.7 | +1:38.3 | +1:38.6 |
| E | +0:51.2 | +1:56.1 | +1:56.3 |
| F | +1:08.2 | +2:13.099 | +2:13.353 |
| G | +1:00.2 | +2:13.099 | never |
| H | +1:05.1 | +2:28.4 | never |
| I | +6:05.5 | +7:10.7 | never |

Every healthy agent is dispatched about 250 ms after its first check-in. Agents F and G have  
first check-ins logged in the same millisecond; F is served, G is not. After that point no agent  
is served, including H and I, which check in alone 15 seconds and 5 minutes later. So this is not  
three agents each losing a race: dispatch for the policy stops after F and does not resume.

Log lines for a healthy agent (F) and a stuck one (G), complete for each:

```auto
+2:13.099 info F applying new components data
+2:13.099 info F applying new rollback data
+2:13.353 info F generating output API key <id>:default
+2:13.383 info F Updating agent record to pick up default output key.
+2:13.657 info F Action delivered to agent on checkin
+2:14.149 info F ack event
+2:14.423 info F ack policy

+2:13.099 info G applying new components data
+2:13.099 info G applying new rollback data
(nothing further for G)

```

None of the early-exit messages in `dispatchPending` appear anywhere in the log (`Policy limit error`, `logic error: policy missing on dispatch`, `logic error: should never block on policy channel`). Debug logging was not enabled, so `deploy pending on subscribe`, `dispatch policy change` and `policy monitor dispatch complete` are not available.

## Recovery

Saving the agent policy unchanged in Kibana (revision 6 to 7) fixes it immediately. All three  
stuck agents log `generating output API key` within 10 ms of each other, acknowledge the policy and  
go `online`. Nothing was restarted.

## Analysis

`Subscribe()` only wakes the dispatcher when the pending queue was empty before the push:

```go
case s.isUpdate(&p.pp.Policy):
    empty := m.pendingQ.isEmpty()
    m.pendingQ.pushBack(s)
    ...
    if empty {
        m.kickDeploy()
    }

```

That makes any stranded subscription permanent. If one subscription is ever left in `pendingQ`  
with no drain running and no signal in `deployCh`, the queue is non-empty for every later  
`Subscribe()`, so none of them kicks. Agents re-subscribe at the end of each long poll, but with  
more than one agent stranded their polls overlap and the queue never empties. The only remaining  
wake-ups are the ones in `Run()` after `loadPolicies` and `processHits`, which is why a new policy  
revision clears it.

This matches everything observed: the stall begins at one instant, every later subscriber to that  
policy is affected, nothing is logged, and a new revision drains all of them at once.

What we have not identified is how the first subscription (G) was stranded. `dispatchPending`  
releases `m.mut` between `popFront()` and the next queue access (per the comment, so that  
`Subscribe`/`Unsubscribe`/`updatePolicy` are not blocked during rate limiting and the channel send),  
and F and G subscribed within the same millisecond while a drain was in progress. We could not  
construct the exact interleaving from reading the code, and we have not reproduced it on demand.

## Suggested fix

- Make the wake-up unconditional in `Subscribe()` (`kickDeploy()` is already non-blocking and  
coalesces), or have `runDispatcher` re-check `pendingQ` on a timer. Either removes the  
"stranded forever" property regardless of the triggering race.
- Log at warn level when a subscription has been pending longer than some threshold, so the  
condition is visible without debug logging.

---

<div class="post-metadata">

**Author:** ![nblair2](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@nblair2](https://discuss.elastic.co/u/nblair2)\
**Post date:** [November 23, 2026, 2:33am UTC](https://discuss.elastic.co/t/policy-monitor-stops-dispatching-agents-enroll-and-check-in-but-never-receive-their-first-policy/391759/2 "2026-11-23T02:33:27Z")

</div>

Update: this is fixed in 9.5.6 (and 9.4.9) by elastic/fleet-server#7923. In 9.5.5, two agents subscribing at the same instant could leave one stranded on the pending queue, and every later agent then queued behind it until a new policy revision. I reproduced the stall against the 9.5.5 binary and could not reproduce it against 9.5.6 in 1,000 rounds.

One note for the maintainers: 9.5.6 and `main` still have the `if empty` check in `Subscribe()` (`internal/pkg/policy/monitor.go`, lines 601–609 at v9.5.6: [fleet-server/internal/pkg/policy/monitor.go at v9.5.6 · elastic/fleet-server · GitHub](https://github.com/elastic/fleet-server/blob/v9.5.6/internal/pkg/policy/monitor.go#L601-L609)). I could not trigger a stall through it on 9.5.6, but making that wake-up unconditional would stop any future stranded subscription from blocking everyone behind it.
