From e68ba1ea79af3d12a8d789df870616747581344c Mon Sep 17 00:00:00 2001 From: Alex Anderson <191496+alxndrsn@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:23:11 +0300 Subject: [PATCH] runSequentially(): expand docs on current usage (#1367) The "current use" documentation does not cover all current uses. Alternatively, this documentation could be removed completely, and intention for calling runSequentially() could be defined at the call sites. --- lib/util/promise.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/util/promise.js b/lib/util/promise.js index 75a901155..b32544570 100644 --- a/lib/util/promise.js +++ b/lib/util/promise.js @@ -78,8 +78,12 @@ const runSequentially = async (functions) => { for (const fn of functions) { // reason: we want to run functions sequentially - // Current use: each function is dependent on DB transaction - // we can't do parallel processing with transaction + // Current uses: + // 1. prevent deadlock due to parallel queries starting sub-transactions + // See: #868 / worker.runJobs() + // 2. reduce number of parallel database connections compared Promise.all() + // See: #1344 / Analytics.previewMetrics() + // eslint-disable-next-line no-await-in-loop results.push(await fn()); }