Skip to content

Commit

Permalink
fix validator/transitioner race
Browse files Browse the repository at this point in the history
svn path=/trunk/boinc/; revision=7963
  • Loading branch information
davidpanderson committed Sep 10, 2005
1 parent cdd8d87 commit 98e6124
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
8 changes: 8 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -11586,3 +11586,11 @@ Bruce 10 Sept 2005
api/
boinc_api.C
graphics_impl_lib.C

David 9 Sept 2005
- validator: when find a canonical result, trigger the assimilator
but do NOT trigger the transitioner; doing so creates a race condition.
(from Bruce Allen)

sched/
validator.C
42 changes: 29 additions & 13 deletions sched/validator.C
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ using namespace std;
#define SELECT_LIMIT 1000
#define SLEEP_PERIOD 5

typedef enum {
NEVER,
DELAYED,
IMMEDIATE,
NO_CHANGE
} TRANSITION_TIME;

extern int check_set(
vector<RESULT>&, WORKUNIT& wu, int& canonical, double& credit,
bool& retry
Expand Down Expand Up @@ -163,10 +170,10 @@ int grant_credit(RESULT& result, double credit) {
void handle_wu(
DB_VALIDATOR_ITEM_SET& validator, std::vector<VALIDATOR_ITEM>& items
) {
int canonical_result_index = -1;
int canonical_result_index = -1;
bool update_result, retry;
bool need_immediate_transition = false, need_delayed_transition = false;
int retval = 0, canonicalid = 0;
TRANSITION_TIME transition_time = NO_CHANGE;
int retval = 0, canonicalid = 0, x;
double credit = 0;
unsigned int i;

Expand Down Expand Up @@ -230,7 +237,7 @@ void handle_wu(
);
exit(retval);
}
if (retry) need_delayed_transition = true;
if (retry) transition_time = DELAYED;
update_result = false;

if (result.outcome == RESULT_OUTCOME_VALIDATE_ERROR) {
Expand All @@ -240,7 +247,7 @@ void handle_wu(
// this might be last result, so let validator
// trigger file delete etc. if needed
//
need_immediate_transition = true;
transition_time = IMMEDIATE;

switch (result.validate_state) {
case VALIDATE_STATE_VALID:
Expand Down Expand Up @@ -332,7 +339,7 @@ void handle_wu(
);
exit(retval);
}
if (retry) need_delayed_transition = true;
if (retry) transition_time = DELAYED;

// scan results.
// update as needed, and count the # of results
Expand All @@ -344,7 +351,7 @@ void handle_wu(
update_result = false;
RESULT& result = results[i];
if (result.outcome == RESULT_OUTCOME_VALIDATE_ERROR) {
need_immediate_transition = true;
transition_time = IMMEDIATE;
update_result = true;
} else {
nsuccess_results++;
Expand Down Expand Up @@ -392,7 +399,11 @@ void handle_wu(
}

if (canonicalid) {
need_immediate_transition = true;
// if we found a canonical result,
// trigger the assimilator, but do NOT trigger
// the transitioner - doing so creates a race condition
//
transition_time = NEVER;
log_messages.printf(
SCHED_MSG_LOG::DEBUG,
"[WU#%d %s] Found a canonical result: id=%d\n",
Expand Down Expand Up @@ -429,7 +440,7 @@ void handle_wu(
//
if (nsuccess_results > wu.max_success_results) {
wu.error_mask |= WU_ERROR_TOO_MANY_SUCCESS_RESULTS;
need_immediate_transition = true;
transition_time = IMMEDIATE;
}

// if #success results == than target_nresults,
Expand All @@ -439,19 +450,24 @@ void handle_wu(
//
if (nsuccess_results >= wu.target_nresults) {
wu.target_nresults = nsuccess_results+1;
need_immediate_transition = true;
transition_time = IMMEDIATE;
}
}
}
}

--log_messages;

if (need_immediate_transition) {
switch (transition_time) {
case IMMEDIATE:
wu.transition_time = time(0);
} else if (need_delayed_transition) {
int x = time(0) + 6*3600;
break;
case DELAYED:
x = time(0) + 6*3600;
if (x < wu.transition_time) wu.transition_time = x;
break;
case NEVER:
wu.transition_time = INT_MAX;
}

wu.need_validate = 0;
Expand Down

0 comments on commit 98e6124

Please sign in to comment.