fix: preserve processed_entries during stale buffer cleanup#13094
Conversation
Baoyuantop
left a comment
There was a problem hiding this comment.
Please add a test case:
-
Configure
max_pending_entriesand send several requests to generateprocessed_entriesin the buffer. -
Trigger a stale cleanup using
set_check_stale_interval(1) + ngx.sleepto remove the buffer. -
Send requests again to verify that the new requests are not incorrectly blocked by
max_pending_entries(i.e.,processed_entriesare correctly preserved).
|
Hi @grapestore, please fix the failed CI |
|
Hi @grapestore, code LGTM, after fixing the failed tests, we can proceed with the merge. |
2fb5d02 to
8cf10bc
Compare
nic-6443
left a comment
There was a problem hiding this comment.
LGTM. The fix correctly preserves processed_entries from stale buffers via the total_stale_processed_entries accumulator, preventing unbounded pending count growth. Test is well-designed.
Description
remove_stale_objectsinbatch-processor-manager.luadeletes stale buffers (emptyentry_bufferandbatch_to_process) every 1800 seconds. When a buffer is deleted, itsprocessed_entriescount is lost.However,
total_pushed_entrieslives on the manager instance and accumulates permanently across the worker lifetime. The pending entry count is calculated astotal_pushed_entries - total_processed_entries, wheretotal_processed_entries()sums only living buffers'processed_entries.This mismatch causes
pendingto grow unboundedly after repeated stale cleanups, eventually exceedingmax_pending_entries. Once exceeded, bothadd_entryandadd_entry_to_new_processorreject all new entries — no new processor can be created, soprocessed_entriesstays at 0 permanently. All log entries are dropped until worker restart.Reproduction (max_pending=10, 3 entries/cycle)
Fix
Add
total_stale_processed_entriesfield to the manager instance. Before deleting a stale buffer, accumulate itsprocessed_entriesinto this field. Use it as the base value intotal_processed_entries().Changes in 3 places:
_M.new— initializetotal_stale_processed_entries = 0remove_stale_objects— preserveprocessed_entriesbefore buffer deletiontotal_processed_entries— start summation fromtotal_stale_processed_entries