From f77420c2c0710105d4a5443bbd1a6f3f4fb07b9e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 8 Feb 2008 17:20:09 +0000 Subject: [PATCH] - scheduler: do "careful update" of workunit.hr_class in case someone else changed since we read it. Hopefully this will fix a race condition where WU results get sent to different HR classes. (Alternatively we could use transactions, or acquire the semaphore during read/update, but this could impact performance). svn path=/trunk/boinc/; revision=14710 --- bolt_checkin_notes.txt | 8 ++++++++ checkin_notes | 14 ++++++++++++++ db/db_base.C | 8 ++++++-- db/db_base.h | 2 +- doc/boinc_news.php | 6 ++++++ html/inc/bolt_ex.inc | 6 +++--- sched/sched_hr.C | 8 ++++++-- 7 files changed, 44 insertions(+), 8 deletions(-) diff --git a/bolt_checkin_notes.txt b/bolt_checkin_notes.txt index 9a5446d0a7..c794b39939 100644 --- a/bolt_checkin_notes.txt +++ b/bolt_checkin_notes.txt @@ -122,3 +122,11 @@ David Feb 7 2008 bolt_xset.inc user/ bolt_sched.php + +David Feb 8 2008 + - removed "bolt_" from API functions. + I don't think this prefix is useful; + Bolt isn't going to be used within large existing PHP code + + html/inc + bolt_ex.inc diff --git a/checkin_notes b/checkin_notes index 72ba1c5c9e..293f877f95 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1274,3 +1274,17 @@ Charlie Feb 7 2008 clientgui/ MainDocument.cpp,h AdvancedFrame.cpp + +David Feb 8 2008 + - scheduler: do "careful update" of workunit.hr_class + in case someone else changed since we read it. + Hopefully this will fix a race condition + where WU results get sent to different HR classes. + (Alternatively we could use transactions, + or acquire the semaphore during read/update, + but this could impact performance). + + db/ + db_base.C,h + sched/ + sched_hr.C diff --git a/db/db_base.C b/db/db_base.C index 7034ccd81a..47b1453691 100644 --- a/db/db_base.C +++ b/db/db_base.C @@ -157,9 +157,13 @@ int DB_BASE::update() { // update one or more fields // "clause" is something like "foo=5, blah='xxx'" or "foo=foo+5" // -int DB_BASE::update_field(const char* clause) { +int DB_BASE::update_field(const char* clause, const char* where_clause) { char query[MAX_QUERY_LEN]; - sprintf(query, "update %s set %s where id=%d", table_name, clause, get_id()); + if (where_clause) { + sprintf(query, "update %s set %s where id=%d and %s", table_name, clause, get_id(), where_clause); + } else { + sprintf(query, "update %s set %s where id=%d", table_name, clause, get_id()); + } return db->do_query(query); } diff --git a/db/db_base.h b/db/db_base.h index 9060a09509..331cce9009 100644 --- a/db/db_base.h +++ b/db/db_base.h @@ -93,7 +93,7 @@ public: int insert(); int insert_batch(std::string&); int update(); - int update_field(const char*); + int update_field(const char*, const char* where_clause=NULL); int delete_from_db(); int get_field_int(const char*, int&); int get_field_str(const char*, char*, int); diff --git a/doc/boinc_news.php b/doc/boinc_news.php index d1b76b81f5..e18b819202 100644 --- a/doc/boinc_news.php +++ b/doc/boinc_news.php @@ -1,6 +1,12 @@ Proteins@Home + has resumed operations. + Check out their paper on computational protein design + in the Journal of Computational Chemistry." +), array("Jan 31, 2008", "The TSP project is featured in International Science Grid This Week: Traveling salesman meets distributed computing." diff --git a/html/inc/bolt_ex.inc b/html/inc/bolt_ex.inc index 367e565e9a..738d7fe79f 100644 --- a/html/inc/bolt_ex.inc +++ b/html/inc/bolt_ex.inc @@ -8,7 +8,7 @@ $bolt_ex_state = 0; $bolt_ex_score = 0; $bolt_ex_query_string = ""; -function bolt_exclusive_choice($choices) { +function exclusive_choice($choices) { global $bolt_ex_mode; // input global $bolt_ex_index; // input global $bolt_ex_score; // incremental output if SCORE @@ -71,7 +71,7 @@ function bolt_exclusive_choice($choices) { $bolt_ex_index++; } -function bolt_inclusive_choice($choices) { +function inclusive_choice($choices) { global $bolt_ex_mode; // input global $bolt_ex_index; // input global $bolt_ex_score; // incremental output if SCORE @@ -130,7 +130,7 @@ function bolt_inclusive_choice($choices) { $bolt_ex_index++; } -function bolt_image_rect($img, $rect) { +function image_rect($img, $rect) { global $bolt_ex_mode; // input global $bolt_ex_index; // input global $bolt_ex_state; // output if SHOW, else input diff --git a/sched/sched_hr.C b/sched/sched_hr.C index 507f432e5e..54a16a88dd 100644 --- a/sched/sched_hr.C +++ b/sched/sched_hr.C @@ -96,8 +96,12 @@ bool already_sent_to_different_platform_careful( wreq.hr_reject_temp = true; } } else { - sprintf(buf, "hr_class=%d", host_hr_class); - db_wu.update_field(buf); + // do a "careful update" to make sure the WU's hr_class hasn't + // changed since we read it earlier + // + sprintf(buf, "hr_class=%d", "hr_class=%d", host_hr_class, wu_hr_class); + retval = db_wu.update_field(buf); + if (retval) return true; } return wreq.hr_reject_temp; }