From bcdb95730824620eeaaf12b564d5a9d81ebb5b02 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 28 Jul 2026 11:33:27 +0000 Subject: [PATCH] :bug: Add concurrency limit to import-binfile RPC handler Apply climit with 4 global permits and 1 per-profile permit (queue 2) to prevent connection pool exhaustion from concurrent imports. Each import holds a DB connection for its entire duration with idle transaction timeout disabled, so unbounded concurrency could exhaust the pool (default 60 connections). AI-assisted-by: mimo-v2.5-pro --- backend/resources/climit.edn | 8 +++++++- backend/src/app/rpc/commands/binfile.clj | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/resources/climit.edn b/backend/resources/climit.edn index 7d8234499b..9e3f94f652 100644 --- a/backend/resources/climit.edn +++ b/backend/resources/climit.edn @@ -39,4 +39,10 @@ {:permits 3} :create-file-snapshot/by-profile - {:permits 1 :queue 2 :timeout 60000}} + {:permits 1 :queue 2 :timeout 60000} + + :import-binfile/global + {:permits 4} + + :import-binfile/by-profile + {:permits 1 :queue 2}} diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 79b0bf7cf9..eb831b3e3c 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -21,6 +21,7 @@ [app.loggers.webhooks :as-alias webhooks] [app.media :as media] [app.rpc :as-alias rpc] + [app.rpc.climit :as-alias climit] [app.rpc.commands.files :as files] [app.rpc.commands.media :as media-cmd] [app.rpc.commands.projects :as projects] @@ -148,7 +149,9 @@ ::webhooks/event? true ::sse/stream? true - ::sm/params schema:import-binfile} + ::sm/params schema:import-binfile + ::climit/id [[:import-binfile/by-profile ::rpc/profile-id] + [:import-binfile/global]]} [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id project-id version file-id upload-id] :as params}] (projects/check-edition-permissions! pool profile-id project-id) (let [version (or version 3)