Per-user major operation limit for classification grids and exports

Open
#2,869 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
django, python
Domain
backend, data

Research direction

Read library/django_utils/major_operation.py and MajorOperationViewMixin first, then inspect the listed export views and the classification and grouping DataTables grids. Decide how limits should differ for exports and machine users, how streamed operations refresh slot expiry, and how statement timeouts interact with batch reads. Done means the uncovered exports and grids have suitable per-user concurrency limits, with streamed slots held for the operation's duration.

Written by the indexing model from the issue text.

Description

🤖 Written by Claude

Classification exports have no per-user concurrency limit, so one user can run several heavy exports at once. Several JSON exports running together is what led to #2867.

What exists: library/django_utils/major_operation.py:major_operation caps a user's concurrent heavy operations and lowers statement_timeout while one runs. MajorOperationViewMixin opts a class-based view in with major_operation_name, and for a streamed response it holds the slot until the stream finishes or the client disconnects. Only the node grid (analysis/views/views_grid.py) and three variantopedia grids (variant_tags, all_variants, tagged_variants) use it.

Not covered:

  • classification_grouping_export (classification/views/exports_grouping/classification_grouping_export_view.py:serve_export): JSON, CSV, VCF, Franklin.
  • export_classifications_grid / export_classifications_grid_redcap (classification/views/views.py).
  • classification_export_api (classification/views/classification_export_view.py:ClassificationApiExportView).
  • The classification and grouping DataTables grids.

Things to settle:

  • Limit size: MAJOR_OPERATION_MAX_CONCURRENT_PER_USER is 20 and shared by every operation type, so it wouldn't stop a handful of exports. Exports may need a lower limit of their own, e.g. an optional per-operation limit in major_operation.
  • Slot expiry vs export length: MAJOR_OPERATION_SLOT_EXPIRE_SECONDS is 10 minutes, a safety expiry for crashed requests. A large JSON export can stream for longer than that, after which its slot is freed while it is still running. The streamed-response holder may need to refresh the expiry as it yields.
  • Statement timeout: MAJOR_OPERATION_STATEMENT_TIMEOUT_SECONDS (5 minutes) applies to each statement. That is fine once #2867 reads in batches, but a single .iterator() cursor query would hit it.
  • Machine users: the API export is used by integrations and sync, whose accounts might legitimately run several at once. Decide whether they share the limit.
  • Function views: serve_export and the grid export views are function views, so they need major_operation used directly and the streamed response wrapped the same way MajorOperationViewMixin does it (_StreamHoldingOperation). Factoring that wrapping out would serve both.
Dominant language
Python
Stars
31
Forks
4
Avg merge
4h 52m
Merged PRs (30d)
183

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SACGF/variantgrid

All issues in SACGF/variantgrid

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.