Skip to content

Commit 344de9b

Browse files
fix(jobs): use NOW(3) to match CURRENT_TIMESTAMP(3) precision
The scheduled_time column uses CURRENT_TIMESTAMP(3) with milliseconds, so comparisons must also use NOW(3) for consistent precision. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 4f4a924 commit 344de9b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/datajoint/autopopulate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ def handler(signum, frame):
487487
if refresh:
488488
self.jobs.refresh(*restrictions, priority=priority)
489489

490-
# Fetch pending jobs ordered by priority
491-
pending_query = self.jobs.pending & "scheduled_time <= NOW()"
490+
# Fetch pending jobs ordered by priority (use NOW(3) to match CURRENT_TIMESTAMP(3) precision)
491+
pending_query = self.jobs.pending & "scheduled_time <= NOW(3)"
492492
if priority is not None:
493493
pending_query = pending_query & f"priority <= {priority}"
494494

src/datajoint/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ def reserve(self, key: dict) -> bool:
447447
bool
448448
True if reservation successful, False if job not available.
449449
"""
450-
# Check if job is pending and scheduled (use MySQL NOW() for consistent timing)
451-
job = (self & key & 'status="pending"' & "scheduled_time <= NOW()").to_dicts()
450+
# Check if job is pending and scheduled (use NOW(3) to match CURRENT_TIMESTAMP(3) precision)
451+
job = (self & key & 'status="pending"' & "scheduled_time <= NOW(3)").to_dicts()
452452

453453
if not job:
454454
return False

0 commit comments

Comments
 (0)