Skip to content

Commit

Permalink
bugfix: MySQL can round microseconds into the future causing schedule…
Browse files Browse the repository at this point in the history
…r to skip trials (microsoft#775)

Solution: truncate microseconds of the current timestamp when scheduling
new trials to be executed ASAP

Closes microsoft#756
  • Loading branch information
motus authored and DelphianCalamity committed Jul 12, 2024
1 parent 1cacddd commit c1908e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mlos_bench/mlos_bench/storage/sql/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ def _get_config_id(self, conn: Connection, tunables: TunableGroups) -> int:

def new_trial(self, tunables: TunableGroups, ts_start: Optional[datetime] = None,
config: Optional[Dict[str, Any]] = None) -> Storage.Trial:
ts_start = utcify_timestamp(ts_start or datetime.now(UTC), origin="local")
# MySQL can round microseconds into the future causing scheduler to skip trials.
# Truncate microseconds to avoid this issue.
ts_start = utcify_timestamp(ts_start or datetime.now(UTC), origin="local").replace(microsecond=0)
_LOG.debug("Create trial: %s:%d @ %s", self._experiment_id, self._trial_id, ts_start)
with self._engine.begin() as conn:
try:
Expand Down

0 comments on commit c1908e0

Please sign in to comment.