Commit 4f3fcd8
committed
fix(pubsub): count a published message while its batch lock is held
The failure callback decrements messagesWaiter for the messages it cancels
out of a MessagesBatch, but publish() incremented after releasing
messagesBatchLock. A message visible in the batch and not yet counted would
therefore be decremented for without ever having been counted, taking
pendingCount below zero and letting waitComplete() return early.
Incrementing while the lock is still held makes "in a MessagesBatch" and
"counted" one state. Lock ordering is messagesBatchLock -> Waiter monitor
here and nowhere the reverse, and incrementPendingCount never blocks. The
paused-key path still returns before the increment, as before.1 parent 330af86 commit 4f3fcd8
1 file changed
Lines changed: 6 additions & 2 deletions
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
325 | 331 | | |
326 | 332 | | |
327 | 333 | | |
| |||
340 | 346 | | |
341 | 347 | | |
342 | 348 | | |
343 | | - | |
344 | | - | |
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| |||
0 commit comments