From ead860457ca6eb47975ed3af0df6097ee16c85f2 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 2 Jun 2026 21:35:08 +0100 Subject: [PATCH] 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) --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5bada8bb6b..2a175751a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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