idle-in-transaction for harvest record selection

Open Beginner friendly
#6,514 1 comment 0 reactions 0 assignees View on GitHub

@theyottaboy is already working on this.

Since Nov 21, 2026.

  • #1118 by @theyottaboy — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
postgresql, python
Domain
backend, databases

Research direction

Start by reading acquire_minimum_internal_data() and HarvesterDBInterface.get_latest_harvest_records_by_source_orm(), which the issue identifies as the likely query path. Check how the session is managed around the HTTP request and whether it is closed on every exit path. The issue is resolved when this path no longer leaves a transaction idle for over 60 seconds.

Written by the indexing model from the issue text.

Description

bug

new relic alert indicating there's an idle-in-transaction lasting over 60 seconds.

How to reproduce

based on the history of this alert it doesn't appear there's a pattern.

Expected behavior

no idle in transactions over 60 seconds

Actual behavior

app code which causes transactions to sit idling over 60 seconds

Sketch

  • the emitted query looks like SELECT anon_1.identifier AS anon_1_identifier, anon_1.record_type AS anon_1_record_type, anon_1.source_hash AS anon_1_source_hash, anon_1.ckan_id AS anon_1_ckan_id, anon_1.date_created AS anon_1_date_created, anon_1.date_finished AS anon_1_date_finished,. emitted queries with anon_ means a subquery was used which the interface method HarvesterDBInterface.get_latest_harvest_records_by_source_orm() uses. the column order also matches those which are used in that function.
  • acquire_minimum_internal_data() uses that function and is followed by an HTTP request to retrieve the external source. This pattern often times leaves a database transaction in the idle-in-transaction state.
  • close the session in a finally statement in acquire_minimum_internal_data may resolve the issue.
Dominant language
Python
Stars
1.2k
Forks
207
Avg merge
3d 16h
Merged PRs (30d)
5

Getting set up

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 GSA/data.gov

All issues in GSA/data.gov

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.