diff --git a/NEWS b/NEWS
index df2e80a76f528a18d9a0eacd54fc39bede70966a..f0361758da50328a571ba5ff0da97e52949fbf83 100644
--- a/NEWS
+++ b/NEWS
@@ -111,6 +111,8 @@ documents those changes that are of interest to users and admins.
     interface instead of through the normal method.
  -- smap - spread node information across multiple lines for larger systems.
  -- Cray - Defer salloc until after PrologSlurmctld completes.
+ -- Correction to slurmdbd communications failure handling logic, incorrect
+    error codes returned in some cases.
 
 * Changes in SLURM 2.4.3
 ========================
diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
index 1de13dc4fa1086594df62fe7bc1ae61027ec1e5d..bfa529b3aa1030eb8ec94380275169b7baf5bd0a 100644
--- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
+++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c
@@ -1297,7 +1297,7 @@ extern int acct_storage_p_remove_reservation(void *db_conn,
 	rc = slurm_send_slurmdbd_recv_rc_msg(SLURMDBD_VERSION,
 					     &req, &resp_code);
 
-	if (resp_code != SLURM_SUCCESS)
+	if ((rc == SLURM_SUCCESS) && (resp_code != SLURM_SUCCESS))
 		rc = resp_code;
 
 	return rc;
diff --git a/testsuite/expect/test17.25 b/testsuite/expect/test17.25
index 15eb701e2edcc49a355264785938692259856993..093059cce4872f92f481bb5f64fd2abca14e935e 100755
--- a/testsuite/expect/test17.25
+++ b/testsuite/expect/test17.25
@@ -101,10 +101,10 @@ if {$matches != 3} {
 	send_user "\nFAILURE: processed $matches of 3 environment variables\n"
 	set exit_code 1
 }
+cancel_job $job_id
 
 if {$exit_code == 0} {
 	exec $bin_rm -f $file_in
 	send_user "\nSUCCESS\n"
 }
-cancel_job $job_id
 exit $exit_code