Skip to content
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

Merged
merged 2 commits into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/scheduler/simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 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);
Expand Down Expand Up @@ -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)
return 0;
if (te == NULL) {
errflag++;
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
}

Expand Down
31 changes: 28 additions & 3 deletions test/tests/pbs_smoketest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,42 @@ def test_submit_job_array(self):
self.server.expect(JOB, {'job_state=R': 3}, count=True,
id=jid, extend='t')

@skipOnCpuSet
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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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 + 10,
'reserve_end': now + 110}
r.set_attributes(a)
rid = self.server.submit(r)
rid_q = rid.split('.')[0]
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_q}
j1 = Job(TEST_USER, attrs=a)
jid1 = self.server.submit(j1)

a = {'Resource_List.select': '1:ncpus=1',
ATTR_q: rid_q, ATTR_J: '1-2'}
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
Expand Down