]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Do not increment the device num_writers if the call to dir_update_volume_info() fails
authorEric Bollengier <eric@baculasystems.com>
Mon, 12 Mar 2018 10:11:42 +0000 (11:11 +0100)
committerKern Sibbald <kern@sibbald.com>
Sun, 15 Jul 2018 06:17:58 +0000 (08:17 +0200)
 The function dir_update_volume_info() can return false, and we leave the
 function with num_writers that is not correct, and it blocks further restore jobs.

bacula/src/stored/acquire.c

index 016f76b65487fe7855651ea8ccd6ebf0802024e9..e68a57cf834ef2c872eaba215759f18b7222a240 100644 (file)
@@ -446,10 +446,17 @@ DCR *acquire_device_for_append(DCR *dcr)
       jcr->NumWriteVolumes = 1;
    }
    dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs on vol */
+
+   ok = dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
+
+   if (!ok) {                   /* We cannot use this volume/device */
+      dev->num_writers--;       /* on fail update_volume do not update num_writers */
+      /* TODO: See if we revert the NumWriteVolumes as well */
+   }
+
    Dmsg4(100, "=== nwriters=%d nres=%d vcatjob=%d dev=%s\n",
       dev->num_writers, dev->num_reserved(), dev->VolCatInfo.VolCatJobs,
       dev->print_name());
-   ok = dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
 
 get_out:
    /* Don't plugin close here, we might have multiple writers */