Skip to content

OpenConceptLab/ocl_issues#2830 | expire Auto Match runs left running for over 24 hours - #960

Merged
snyaggarwal merged 1 commit into
masterfrom
issues#2830
Oct 27, 2026
Merged

snyaggarwal merged 1 commit into
masterfrom
issues#2830

Conversation

@snyaggarwal

Copy link
Copy Markdown
Contributor

Part of OpenConceptLab/ocl_issues#2830, alongside OpenConceptLab/oclmap#114.

The Mapper closes an Auto Match run's record when the run ends, when the user leaves the project, and as the tab closes. It can't close one whose create request was still in flight when the tab closed: the browser never gets the run id, so the record stays running for good. This closes such records on the server.

Changes

  • AutomatchRun.expire_stale(older_than=None) marks runs still running with no update for STALE_AFTER (24 hours) as cancelled and sets completed_at. It returns how many it changed.
  • New expire_stale_auto_match_runs celery task, scheduled hourly in CELERYBEAT_SCHEDULE.

Notes

  • The Mapper only updates a run's record when the run ends, so the cutoff must be longer than the longest real run. 24 hours is a guess at that; raise STALE_AFTER if runs can last longer.
  • If an expired run later reports in, its own result replaces cancelled. completed_at keeps the expiry time.

Testing

  • python manage.py test core.map_projects: 71 pass, including 3 new tests in AutomatchRunExpireStaleTest.
  • pylint 10/10 on the changed files.

🤖 Generated with Claude Code

@snyaggarwal

Copy link
Copy Markdown
Contributor Author

This is the server side of OpenConceptLab/ocl_issues#2830. It covers the case flagged in review on OpenConceptLab/oclmap#114: a tab that closes while the run's create request is in flight leaves the record running, because the Mapper never gets its id. Please check the 24-hour cutoff against the longest Auto Match runs you see. The Mapper only updates a run's record when the run ends, so a shorter cutoff would cancel runs that are still going.

🤖 Generated with Claude Code

@snyaggarwal snyaggarwal left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed alongside Mapper PR #114. The hourly task covers the orphaned run-record case when the tab closes before the create response arrives. I found no additional blocker in this PR. Please confirm the 24-hour inactivity cutoff exceeds the longest legitimate run before deployment.

@snyaggarwal
snyaggarwal requested a review from paynejd October 26, 2026 12:41
@snyaggarwal snyaggarwal self-assigned this Oct 26, 2026
@paynejd

paynejd commented Oct 27, 2026

Copy link
Copy Markdown
Member

Codex review, pass 1 (codex-cli 0.164.0, commit cc93552)

An independent pass for my review.

Verdict: clean. No findings.

On the 24-hour cutoff: the longest Auto Match run that has finished in production took 2.4 hours, and the 99th percentile is under 2 hours, so 24 hours leaves a wide margin. There are 11 records still running with no update for over 24 hours, the oldest from July. The task's first run will mark them cancelled, which is what we want.

findings.json
{
  "reviewer": "codex-cli 0.164.0",
  "perspective": "defects",
  "mode": "full",
  "commit": "cc93552",
  "verdict": "clean",
  "prior": [],
  "findings": []
}

@paynejd paynejd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Codex found nothing (pass above), and 24 hours is about 10× the longest run in production. This can merge before OpenConceptLab/oclmap#114, which has open findings.

@snyaggarwal
snyaggarwal merged commit 120cb24 into master Oct 27, 2026
3 checks passed
@snyaggarwal
snyaggarwal deleted the issues#2830 branch October 27, 2026 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants