scheduler race condition

svn path=/trunk/boinc/; revision=9666
This commit is contained in:
David Anderson 2006-03-17 04:47:51 +00:00
parent cd66c37327
commit 1b3e1fe484
10 changed files with 51 additions and 14 deletions

View File

@ -2906,3 +2906,17 @@ Rom 16 Mar 2006
clientlib/win/
boinc_dll.cpp
NetworkTracker.cpp
David 16 Mar 2006
- scheduler: when mark a result as sent, make sure its
server_state is what we expected (e.g. UNSENT).
This guards against two scheduler instances trying to
send the same result at about the same time.
(from Bruce Allen)
db/
boinc_db.C,h
db_base.C,h
sched/
sched_resend.C
sched_send.C

View File

@ -736,16 +736,22 @@ void DB_RESULT::db_print_values(char* buf){
UNESCAPE(stderr_out);
}
// called from scheduler when dispatch this result
// called from scheduler when dispatch this result.
// The "... and server_state=%d" is a safeguard against
// the case where another scheduler tries to send this result at the same time
//
int DB_RESULT::update_subset() {
int DB_RESULT::mark_as_sent(int old_server_state) {
char query[MAX_QUERY_LEN];
int retval;
sprintf(query,
"update result set server_state=%d, hostid=%d, userid=%d, sent_time=%d, report_deadline=%d where id=%d",
server_state, hostid, userid, sent_time, report_deadline, id
"update result set server_state=%d, hostid=%d, userid=%d, sent_time=%d, report_deadline=%d where id=%d and server_state=%d",
server_state, hostid, userid, sent_time, report_deadline, id,
old_server_state
);
return db->do_query(query);
retval = db->do_query(query);
if (retval) return retval;
if (db->affected_rows() != 1) return ERR_DB_NOT_FOUND;
}
void DB_RESULT::db_parse(MYSQL_ROW &r) {

View File

@ -560,7 +560,7 @@ class DB_RESULT : public DB_BASE, public RESULT {
public:
DB_RESULT(DB_CONN* p=0);
int get_id();
int update_subset();
int mark_as_sent(int old_server_state);
void db_print(char*);
void db_print_values(char*);
void db_parse(MYSQL_ROW &row);

View File

@ -63,6 +63,10 @@ int DB_CONN::do_query(const char* p) {
return retval;
}
int DB_CONN::affected_rows() {
return mysql_affected_rows(mysql);
}
int DB_CONN::insert_id() {
int retval;
MYSQL_ROW row;

View File

@ -62,6 +62,7 @@ public:
DB_CONN();
int open(char* name, char* host, char* user, char* passwd);
int do_query(const char*);
int affected_rows();
void close();
int insert_id();
void print_error(const char*);

View File

@ -1,6 +1,16 @@
<?
$project_news = array(
array("March 15, 2006",
"The <a href=http://attribution.cpdn.org/>Seasonal Attribution Project</a>,
a spin-off of Climateprediction.net,
seeks to determine the extent to which extreme weather events
are attributable to human-induced climate change.
Its application is a high-resolution simulation of the world's climate,
and is recommended only for computers
with at least 1 GB of RAM, and a 2.4GHz Pentium or faster processor.
"
),
array("March 5, 2006",
"Tony/Knightrider/Chuggybus has created BOINC coinage.
See the <a href=images/coins/>large</a>

View File

@ -12,12 +12,12 @@ General comments about graphics:
<ul>
<li>
The graphics often provide a
visualization of what the application is doing scientifically.
The graphics code must run concurrently with the science code,
and must share data structures with it.
This can be done using any of
several <b>process structures</b>.
It is desirable for the graphics to provide a
visualization of what the application is currently doing.
Usually the easiest way to do this is for
the graphics code to run concurrently with the science code,
and to share data structures with it.
This can be done using any of several <b>process structures</b>.
For example, you can use separate threads in a single address space,
or shared memory between separate programs.
BOINC supports various process structures (see below).

View File

@ -112,6 +112,7 @@ language("French", array(
site("http://boinc-quebec.org", "boinc-quebec.org")
));
language("German", array(
site("http://www.seti-leipzig.de/", "SETI-Leipzig"),
site("http://www.dc-gemeinschaft.de/", "DC - Gemeinschaft"),
site("http://boinccast.podhost.de/", "BOINCcast (Podcast)"),
site("http://www.boinc-team.de/", "BOINC@Heidelberg"),

View File

@ -166,7 +166,7 @@ bool resend_lost_work(
possibly_give_result_new_deadline(result, wu, reply)
) {
result.report_deadline = time(0);
retval = result.update_subset();
retval = result.mark_as_sent(result.server_state);
if (retval) {
log_messages.printf(
SCHED_MSG_LOG::MSG_CRITICAL,

View File

@ -590,6 +590,7 @@ int add_result_to_reply(
result.hostid = reply.host.id;
result.userid = reply.user.id;
result.sent_time = time(0);
int old_server_state = result.server_state;
if (result.server_state != RESULT_SERVER_STATE_IN_PROGRESS) {
// We are sending this result for the first time
@ -617,7 +618,7 @@ int add_result_to_reply(
result.id, reply.host.id
);
}
retval = result.update_subset();
retval = result.mark_as_sent(old_server_state);
if (retval) {
log_messages.printf(
SCHED_MSG_LOG::MSG_CRITICAL,