Commit 4dbb5ea
committed
fix: resolve race condition in telemetry queue persist operations
- Move pendingPersist flag clearing inside persistQueue() method
- Implement loop-based draining to handle concurrent persist requests
- Add comprehensive tests for concurrent operations
- Ensures no telemetry events are lost during rapid enqueue operations
The previous implementation had a lost-notification bug where the pendingPersist
flag was cleared in the setImmediate callback before calling persistQueue().
This could cause events enqueued during an in-flight persist to remain unpersisted.
The fix implements Option A: clearing the flag inside persistQueue() and using
a while loop to drain all pending requests, ensuring any enqueue that happens
during a persist operation triggers another persist pass immediately after.1 parent ef3aeb3 commit 4dbb5ea
1 file changed
+14
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
235 | 234 | | |
236 | 235 | | |
237 | 236 | | |
| |||
240 | 239 | | |
241 | 240 | | |
242 | 241 | | |
243 | | - | |
| 242 | + | |
244 | 243 | | |
245 | 244 | | |
246 | | - | |
247 | 245 | | |
248 | 246 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
254 | 260 | | |
255 | 261 | | |
256 | 262 | | |
| |||
0 commit comments