diff --git a/src/slurmctld/node_scheduler.c b/src/slurmctld/node_scheduler.c
index 5a44aaef8790a2aae595bffe5a6ecc4e8e090253..7443aad96091218950ee768cf16375a2364a0228 100644
--- a/src/slurmctld/node_scheduler.c
+++ b/src/slurmctld/node_scheduler.c
@@ -2572,6 +2572,10 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 	if (select_g_job_begin(job_ptr) != SLURM_SUCCESS) {
 		/* Leave job queued, something is hosed */
 		error("select_g_job_begin(%u): %m", job_ptr->job_id);
+
+		/* Since we began the job earlier we have to cancel it */
+		(void) bb_g_job_cancel(job_ptr);
+
 		error_code = ESLURM_NODES_BUSY;
 		job_ptr->start_time = 0;
 		job_ptr->time_last_active = 0;
@@ -2591,6 +2595,10 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 		error("Select plugin failed to set job resources, nodes");
 		/* Do not attempt to allocate the select_bitmap nodes since
 		 * select plugin failed to set job resources */
+
+		/* Since we began the bb job earlier we have to cancel it */
+		(void) bb_g_job_cancel(job_ptr);
+
 		error_code = ESLURM_NODES_BUSY;
 		job_ptr->start_time = 0;
 		job_ptr->time_last_active = 0;
@@ -2605,6 +2613,11 @@ extern int select_nodes(struct job_record *job_ptr, bool test_only,
 		if (!job_ptr->job_resrcs) {
 			/* If we don't exit earlier the empty job_resrcs might
 			 * be dereferenced later */
+
+			/* Since we began the bb job earlier we have to cancel
+			 * it */
+			(void) bb_g_job_cancel(job_ptr);
+
 			error_code = ESLURM_NODES_BUSY;
 			job_ptr->start_time = 0;
 			job_ptr->time_last_active = 0;