aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2014-09-26 17:00:41 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2014-09-26 17:00:41 -0400
commit8c2a47c2ed2ca8fa0f546d459e837a03daee5347 (patch)
tree34256f96b0f89430ebc7e72cfc2d9efb18fb8a2b
parent438fbeab987043f16b8b804f1f84e1d94c8e8bd1 (diff)
save results in sorted order to avoid deadlock
-rwxr-xr-xrtss14/database.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/rtss14/database.py b/rtss14/database.py
index d3d10fe..2357b02 100755
--- a/rtss14/database.py
+++ b/rtss14/database.py
@@ -384,8 +384,10 @@ def store_sched_results(db_name, data, ndp = 0):
384 # must be merged with prior results in the 'scaled_sched_results' table 384 # must be merged with prior results in the 'scaled_sched_results' table
385 c = conn.cursor(db.cursors.DictCursor) 385 c = conn.cursor(db.cursors.DictCursor)
386 try: 386 try:
387 # get IDs for all design points 387 # get IDs for all design points.
388 dp_ids = [lookup_dp_id(c, d.dp) for d in data] 388 # sort to ensure that we update scaled design points
389 # in a consistent order (no deadlocks!).
390 dp_ids = sorted([lookup_dp_id(c, d.dp) for d in data])
389 391
390 # insert the normal sched data in one go 392 # insert the normal sched data in one go
391 begin_sync(conn, c) 393 begin_sync(conn, c)
@@ -406,6 +408,10 @@ def store_sched_results(db_name, data, ndp = 0):
406 # TODO: mark unsaved design points as not taken in dp_pending 408 # TODO: mark unsaved design points as not taken in dp_pending
407 # rethrow 409 # rethrow
408 raise e 410 raise e
411 except BaseException, e:
412 print 'Caught unknown exception. Rolling back transaction before exiting.'
413 rollback(conn)
414 raise e
409 c.close() 415 c.close()
410 if ndp > 0: 416 if ndp > 0:
411 fetched = __get_design_points(conn, ndp) 417 fetched = __get_design_points(conn, ndp)