Skip to content

fix: populate() with reserve_jobs=True ignores restrictions (#1413)#1414

Open
dimitri-yatsenko wants to merge 2 commits intomasterfrom
fix/1413-populate-reserve-jobs-restrictions
Open

fix: populate() with reserve_jobs=True ignores restrictions (#1413)#1414
dimitri-yatsenko wants to merge 2 commits intomasterfrom
fix/1413-populate-reserve-jobs-restrictions

Conversation

@dimitri-yatsenko
Copy link
Copy Markdown
Member

Summary

Fixes #1413.

_populate_distributed() was passing *restrictions to self.jobs.refresh() but then fetching all pending jobs without applying those restrictions. This meant populate(restriction, reserve_jobs=True) processed every pending key instead of only those matching the restriction.

Root cause: The pending key query at line 495 used self.jobs.pending unfiltered:

pending_query = self.jobs.pending & "scheduled_time <= CURRENT_TIMESTAMP(3)"

Fix: Intersect with _jobs_to_do(restrictions), reusing the existing method that correctly applies restrictions (identical to _populate_direct() behaviour):

if restrictions:
    pending_query = pending_query & self._jobs_to_do(restrictions)

Test plan

  • Verify populate(restriction, reserve_jobs=True) processes only keys matching the restriction
  • Verify populate(reserve_jobs=True) (no restriction) is unchanged
  • Run existing autopopulate tests: pixi run test -k autopopulate

🤖 Generated with Claude Code

dimitri-yatsenko and others added 2 commits March 27, 2026 14:15
Fixes #1413 — populate() with reserve_jobs=True was ignoring
restrictions passed by the caller. _populate_distributed() refreshed
the job queue with the correct restrictions but then fetched all
pending keys without filtering them. The fix intersects the pending
query with _jobs_to_do(restrictions), matching the behaviour of
_populate_direct().

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
…ctions

Adds test_populate_reserve_jobs_respects_restrictions which verifies
that _populate_distributed() honours the caller's restriction when
reserve_jobs=True.

The test seeds a full job queue for all subjects, then calls
populate(restriction, reserve_jobs=True, refresh=False) for a single
subject and asserts that only that subject's rows were created.

Also fixes the restrict() call in _populate_distributed to use
semantic_check=False, matching the pattern in jobs.py refresh(),
because the jobs table PK has different attribute lineage than
key_source.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
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.

populate() with reserve_jobs=True ignores *restrictions

1 participant