[meta] partners: don't hold a DB transaction open during the partner HTTP fetch

Open Beginner friendly
#2,726 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
postgresql, python
Domain
backend, database

Research direction

Start in jobs/harvest_partner_outings.py at run_source: trace where partner_sources is read and where adapter.fetch is called. Read the job's session/transaction helper and any existing job tests or transport test double. Done means the row read is finished before the fetch, lookup cache writes are buffered in memory, outings/lookups/health are written in one short transaction, and a test proves no transaction is open while the transport is called.

Written by the indexing model from the issue text.

Description

metaskirando

From the M1 integration review of meta. Target branch: meta. Tracking: c2corg/metaskirando-archive#2

run_source (jobs/harvest_partner_outings.py) reads partner_sources and then keeps the transaction open through adapter.fetch. For gulliver that can mean up to 40 requests with 20 s timeouts and sleeps, so minutes "idle in transaction": a pinned connection, a row lock, and vacuum held back on prod (PostgreSQL 9.6).

Fix: read the row and end the transaction before the fetch. Keep the lookup cache writes in memory during the fetch, then write outings, lookups and health in one short transaction. Add a test asserting that no transaction is open while the transport is called.


Generated by Claude Code

Dominant language
Python
Stars
25
Forks
30
Avg merge
8h 3m
Merged PRs (30d)
255

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

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 c2corg/v6_api

All issues in c2corg/v6_api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.