From 0fad1070a69d66c9fe1a09b2571a7e3313a1e611 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 4 Sep 2019 21:33:42 +0000 Subject: [PATCH] fix: addressed issue with count doubling (#2518) --- src/core/server/models/story/counts/shared.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/server/models/story/counts/shared.ts b/src/core/server/models/story/counts/shared.ts index b40039bfd..fe369bf99 100644 --- a/src/core/server/models/story/counts/shared.ts +++ b/src/core/server/models/story/counts/shared.ts @@ -106,8 +106,10 @@ export async function recalculateSharedModerationQueueQueueCounts( // Increment the hash key values. const pipeline = redis.pipeline(); - // Mark the key as fresh, and update the values! - pipeline.mhincrby( + // Mark the key as fresh, and update the values! We're using `HMSET` here + // because this can still result in race conditions when the call is made + // twice. + pipeline.hmset( key, ...queues.reduce((acc, queue) => [...acc, queue._id, queue.total], []) );