Files
Groene AIandClaude Opus 4.8 1672335a40 Do not leak in-flight ZooKeeper metric when sendThread insert throws
The sendThread request window now completes the dropped callback via the
SCOPE_EXIT guard for any throw, so a throw from the operations map insert no
longer breaks the promise. But the in-flight CurrentMetrics::ZooKeeperRequest
gauge was incremented before the insert, while finalize() only subtracts
operations.size() on teardown. A throwing insert therefore left the gauge
incremented for a request that never entered operations, leaking one count per
failure forever.

Register in operations first and increment the gauge only on a successful
insert, so each increment corresponds 1:1 with an entry that finalize() will
subtract. insert_or_assign keeps the previous overwrite semantics while giving
an all-or-nothing insert (operator[] could leave a default-constructed stale
entry if assignment throws).

Add a zk_send_thread_operations_insert_throw failpoint at the insert site and a
regression case asserting the gauge returns to its baseline after repeated
in-window insert failures. With the old ordering the gauge climbed by one per
iteration (baseline=0, after=20); with the fix it stays at the baseline.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-24 11:41:01 +00:00
..