-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sched crash when array job and reservation is submitted #1109
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -858,11 +858,21 @@ create_events(server_info *sinfo) | |
int errflag = 0; | ||
int i = 0; | ||
time_t end = 0; | ||
resource_resv **all_resresv_copy; | ||
int all_resresv_len; | ||
|
||
/* all_resresv is sorted such that the timed events are in the front of | ||
* the array. Once the first non-timed event is reached, we're done | ||
/* create a temporary copy of all_resresv array which is sorted such that | ||
* the timed events are in the front of the array. | ||
* Once the first non-timed event is reached, we're done | ||
*/ | ||
all = sinfo->all_resresv; | ||
all_resresv_len = count_array((void **)sinfo->all_resresv); | ||
all_resresv_copy = (resource_resv **)malloc((all_resresv_len + 1) * sizeof(resource_resv *)); | ||
if (all_resresv_copy == NULL) | ||
return 0; | ||
for (i = 0; sinfo->all_resresv[i] != NULL; i++) | ||
all_resresv_copy[i] = sinfo->all_resresv[i]; | ||
all_resresv_copy[i] = NULL; | ||
all = all_resresv_copy; | ||
|
||
/* sort the all resersv list so all the timed events are in the front */ | ||
qsort(all, count_array((void **)all), sizeof(resource_resv *), cmp_events); | ||
|
@@ -901,18 +911,22 @@ create_events(server_info *sinfo) | |
if (node->is_sleeping) { | ||
te = create_event(TIMED_NODE_UP_EVENT, sinfo->server_time + PROVISION_DURATION, | ||
(event_ptr_t *) node, (event_func_t) node_up_event, NULL); | ||
if (te == NULL) | ||
if (te == NULL) { | ||
free(all_resresv_copy); | ||
return 0; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is actually a bug. If we return here, we'll leak events. Instead of returning, errflag++ and break (that is what happens above). That will cause the code below to free everything and return. |
||
events = add_timed_event(events, te); | ||
} | ||
} | ||
|
||
/* A malloc error was encountered, free all allocated memory and return */ | ||
if (errflag > 0) { | ||
free_timed_event_list(events); | ||
free(all_resresv_copy); | ||
return 0; | ||
} | ||
|
||
free(all_resresv_copy); | ||
return events; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,15 +79,38 @@ def test_submit_job_array(self): | |
|
||
def test_advance_reservation(self): | ||
""" | ||
Test to submit an advanced reservation | ||
Test to submit an advanced reservation and submit jobs to that | ||
reservation. Check if the reservation gets confimed and the jobs | ||
inside the reservation starts running when the reservation runs. | ||
""" | ||
r = Reservation() | ||
a = {'Resource_List.select': '1:ncpus=1'} | ||
a = {'resources_available.ncpus': 4} | ||
self.server.manager(MGR_CMD_SET, NODE, a, id=self.mom.shortname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you do this, I think you need to add the skip on cpuset decorator to this test. You can't modify the resources on a cpuset machine to differ from what the mom reported. |
||
r = Reservation(TEST_USER) | ||
now = int(time.time()) | ||
a = {'Resource_List.select': '1:ncpus=4', | ||
'reserve_start': now + 5, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5s might be too short on slow machines. I'd use 10s. |
||
'reserve_end': now + 105} | ||
r.set_attributes(a) | ||
rid = self.server.submit(r) | ||
a = {'reserve_state': (MATCH_RE, "RESV_CONFIRMED|2")} | ||
self.server.expect(RESV, a, id=rid) | ||
|
||
# submit a normal job and an array job to the reservation | ||
a = {'Resource_List.select': '1:ncpus=1', | ||
ATTR_q: rid.split('.')[0]} | ||
j1 = Job(TEST_USER, attrs=a) | ||
jid1 = self.server.submit(j1) | ||
|
||
a = {'Resource_List.select': '1:ncpus=1', | ||
ATTR_q: rid.split('.')[0], ATTR_J: '1-2'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're splitting the rid twice, why not do it once and store it into a local variable? |
||
j2 = Job(TEST_USER, attrs=a) | ||
jid2 = self.server.submit(j2) | ||
|
||
a = {'reserve_state': (MATCH_RE, "RESV_RUNNING|5")} | ||
self.server.expect(RESV, a, id=rid, interval=1) | ||
self.server.expect(JOB, {'job_state': 'R'}, jid1) | ||
self.server.expect(JOB, {'job_state': 'B'}, jid2) | ||
|
||
def test_standing_reservation(self): | ||
""" | ||
Test to submit a standing reservation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to cast the return value of malloc()