Skip to content

Commit c9dade9

Browse files
authored
Bugfix: Fix crashing in postgres-backed storage (microsoft#1000)
# Pull Request ## Title In PostgreSQL, attempting to insert a record with conflicting keys fails (a benign action in MLOS), fails the entire transaction thus preventing the update of other tables. Splitting the update into two independent transactions solves the problem. ______________________________________________________________________ ## Description Update tables `trial_status` and `trial` in separate transactions (that's OK for MLOS) to make sure PG won't fail the update of `trial` if there is a duplicate record in `trial_status`. - **Issue link**: Closes microsoft#999 ______________________________________________________________________ ## Type of Change - 🛠️ Bug fix ______________________________________________________________________ ## Testing Run TQP benchmark with PostgreSQL storage.
1 parent f5b8e63 commit c9dade9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • mlos_bench/mlos_bench/storage/sql

mlos_bench/mlos_bench/storage/sql/trial.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ def update(
116116
metrics = super().update(status, timestamp, metrics)
117117
with self._engine.begin() as conn:
118118
self._update_status(conn, status, timestamp)
119+
# Use a separate transaction to avoid issues with PostgreSQL's duplicate key
120+
# constraint handling. (See Issue #999).
121+
with self._engine.begin() as conn:
119122
try:
120123
if status.is_completed():
121124
# Final update of the status and ts_end:

0 commit comments

Comments
 (0)