Skip to content

fix(jobs): judge refresh cleanup against the unrestricted key_source - #1595

Open
dimitri-yatsenko wants to merge 1 commit into
masterfrom
fix/jobs-refresh-restriction
Open

dimitri-yatsenko wants to merge 1 commit into
masterfrom
fix/jobs-refresh-restriction

Conversation

@dimitri-yatsenko

Copy link
Copy Markdown
Member

Closes #1594. Part of #1577.

Job.refresh(*restrictions) narrowed key_source to add jobs, then reused the narrowed key_source in its cleanup step. Every job older than stale_timeout whose key fell outside the restriction therefore looked vanished and was deleted, including jobs reserved by other workers and error records. populate(*restrictions, reserve_jobs=True) calls refresh this way.

Tests: tests/integration/test_jobs_refresh.py, on MySQL and PostgreSQL. It covers a restricted refresh, a restricted populate, records of vanished keys, records of rows that still exist, stale_timeout=0, and the statement count. The jobs and autopopulate suites pass locally.

The same commit goes onto maint/2.3 for the v2.3.5 patch release.

`Job.refresh(*restrictions)` narrowed key_source to add jobs and then
reused the narrowed key_source in its cleanup step. Every job older than
stale_timeout whose key fell outside the restriction therefore looked
vanished and was deleted, including jobs reserved by other workers and
error records. `populate(*restrictions, reserve_jobs=True)` calls
refresh this way. Cleanup now checks keys against the unrestricted
key_source; the restrictions still limit which jobs are added and
re-pended.

Success and error records whose key has left both key_source and the
target (because the upstream row was deleted) are now removed on every
refresh, whatever their age, instead of lingering until stale_timeout.
Records of rows that still exist are kept. The age-based check for the
other statuses, and stale_timeout=0 skipping it, are unchanged.

Cleanup now issues one DELETE per step instead of an existence query
and a DELETE for each key.

Closes #1594. Part of #1577.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restricted populate with reserve_jobs deletes other workers' reservations and error records

1 participant