Commit ae600c4
committed
publish leader state before signaling
A newly elected leader could still look like a follower when
`GainedLeadership` was observed. The elector did not publish
`isLeader = true` until `keepLeadershipLoop`, so a `request_resign`
notification arriving in that transition window could be dropped as if
no leader existed.
Move leadership publication to the point immediately after election
succeeds and before the gained-leadership signal is emitted. That makes
the signal truthful: once observers see it, subscriber state and
`isLeader` already reflect leadership.
Add a DB-backed regression that keeps the initial subscriber
notification buffered and verifies `GainedLeadership` waits for leader
state publication. The immediate-resign regression comments now document
the intended ordering.1 parent 7db0510 commit ae600c4
2 files changed
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
199 | 201 | | |
200 | 202 | | |
201 | 203 | | |
| |||
312 | 314 | | |
313 | 315 | | |
314 | 316 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | 317 | | |
319 | 318 | | |
320 | 319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
263 | 294 | | |
264 | 295 | | |
265 | 296 | | |
| |||
472 | 503 | | |
473 | 504 | | |
474 | 505 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
480 | 510 | | |
481 | 511 | | |
482 | 512 | | |
| |||
0 commit comments