BulkUploadGuard's one-upload-per-user limit holds per process, not per user

オープン
#2,578 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
postgresql, python
領域
api, backend, database

調査の方向性

Start in api/bulk_upload_guard.py, reading the module docstring and the current per-user and global admission paths. Compare the shared-state options described in the issue and determine how the chosen approach should coordinate across mod_wsgi processes. Done means one user cannot exceed the intended limit globally while the configured global cap still behaves correctly.

索引モデルが issue の本文から書いたものです。

説明

API bug

BulkUploadGuard (api/bulk_upload_guard.py) is meant to allow at most one running bulk upload per user, plus a global cap (BULK_UPLOAD_MAX_CONCURRENT, default 2). Its state is an in-memory set behind a threading.Lock, so it lives in one WSGI process. The module docstring says so ("a multi-worker deployment bounds concurrency per worker process").

What that means in production, which runs several mod_wsgi processes:

  • One user can run one upload per process, not one in total. This was reproduced on production on 2026-08-11, when the main group had 4 processes: 8 concurrent uploads by the same user gave 4 × 201 and 4 × 429. The process count has been raised since (12 in the main group when read on 2026-09-21; it is host configuration, not in this repo).
  • The global cap never binds for a single user. Each process admits up to BULK_UPLOAD_MAX_CONCURRENT uploads, and every rejection in the measurement came from the per-user branch, so for one user the effective ceiling is the process count, whatever the setting says.

The guard exists because a bulk upload pins a worker and holds an open transaction for its whole duration (synchronous WSGI by design), so the real ceiling matters for how many workers one client can occupy.

Possible fixes, roughly from cheapest:

  • a Postgres advisory lock per user (pg_try_advisory_lock(hash(user))) plus a counter for the global cap, which is shared by all processes for free;
  • a row in a small table with a TTL;
  • or accept per-process semantics and document the real ceiling (processes × 1 per user).

Related: #2362 (Bulk Upload).

主要言語
Python
スター
65
フォーク
28
平均マージ
4日 7時間
マージ済み PR(30日)
25

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

OpenEnergyPlatform/oeplatform のほかの issue

OpenEnergyPlatform/oeplatform の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。