Keep stats workers serial: shared accumulator state is not coroutine-safe

StatsUsage batches metrics across messages on shared instance state
($stats/$keys/$projects/$statDocuments); concurrent consume coroutines
race the flush in commitToDB, losing aggregates on reset and
double-applying upsertDocumentsWithIncrease on overlapping flushes.

StatsResources resets its shared $documents buffer at the start of each
job, so a second coroutine starting mid-count wipes the first one's
batch and the projects' metrics interleave into one write.

Both stay at 1 coroutine until accumulation moves to per-message state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
loks0nandClaude Opus 4.8 committed 2026-06-02 21:35:08 +01:00
1 parent e3afc66bac
commit ead860457c
1 file changed
+2 -2
+2 -2
View File
@@ -1068,7 +1068,7 @@ services:
environment:
- _APP_ENV
- _APP_WORKERS_NUM=1
- _APP_WORKER_MAX_COROUTINES=8
- _APP_WORKER_MAX_COROUTINES=1
- _APP_WORKER_PER_CORE
- _APP_POOL_ADAPTER
- _APP_OPENSSL_KEY_V1
@@ -1104,7 +1104,7 @@ services:
environment:
- _APP_ENV
- _APP_WORKERS_NUM=1
- _APP_WORKER_MAX_COROUTINES=8
- _APP_WORKER_MAX_COROUTINES=1
- _APP_WORKER_PER_CORE
- _APP_POOL_ADAPTER
- _APP_OPENSSL_KEY_V1