From: Kern Sibbald Date: Thu, 13 Sep 2007 07:21:47 +0000 (+0000) Subject: kes Cancel storage daemon in all cases where FD reports error. This X-Git-Tag: Release-7.0.0~5686 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fea2349fabe05fbddfbe3fb1b44939c187175d0a;p=bacula%2Fbacula kes Cancel storage daemon in all cases where FD reports error. This should fix virtually all cases of bug #920. kes Fix db_escape_string() for MySQL which did not compile. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5539 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 8eed47c6b8..aa994f4d83 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -68,8 +68,14 @@ Professional Needs: See email of 21Aug2007 for details. Priority: +- KIWI +- Implement wait on multiple objects + - Multiple max times + - pthread signal + - socket input ready - Implement SDErrors (must return from SD) - Implement USB keyboard support in rescue CD. +- Implement continue spooling while despooling. - Remove all install temp files in Win32 PLUGINSDIR. - Audit retention periods to make sure everything is 64 bit. - Use E'xxx' to escape PostgreSQL strings. diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index a84fd502ef..631e6a474f 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -295,9 +295,9 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index) * the escaped output. */ void -db_escape_string(JCR *jcr, B_DB *db, char *snew, char *old, int len) +db_escape_string(JCR *jcr, B_DB *mdb, char *snew, char *old, int len) { - mysql_real_escape_string(jcr->db, snew, old, len); + mysql_real_escape_string(mdb->db, snew, old, len); } /* diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 161d390c09..ba1bdfe00d 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -165,7 +165,6 @@ bool do_backup(JCR *jcr) set_jcr_job_status(jcr, JS_WaitFD); if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) { - cancel_storage_daemon_job(jcr); goto bail_out; } @@ -246,9 +245,7 @@ bail_out: set_jcr_job_status(jcr, JS_ErrorTerminated); Dmsg1(400, "wait for sd. use=%d\n", jcr->use_count()); /* Cancel SD */ - if (jcr->store_bsock) { - jcr->store_bsock->fsend("cancel Job=%s\n", jcr->Job); - } + cancel_storage_daemon_job(jcr); wait_for_storage_daemon_termination(jcr); Dmsg1(400, "after wait for sd. use=%d\n", jcr->use_count()); return false; @@ -298,6 +295,11 @@ int wait_for_job_termination(JCR *jcr) } bnet_sig(fd, BNET_TERMINATE); /* tell Client we are terminating */ + /* Force cancel in SD if failing */ + if (job_canceled(jcr) || !fd_ok) { + cancel_storage_daemon_job(jcr); + } + /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */ wait_for_storage_daemon_termination(jcr); diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index e3a60613b0..978f81476a 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -135,7 +135,6 @@ bool do_restore(JCR *jcr) */ set_jcr_job_status(jcr, JS_WaitFD); if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) { - cancel_storage_daemon_job(jcr); restore_cleanup(jcr, JS_ErrorTerminated); return false; } @@ -247,6 +246,10 @@ void restore_cleanup(JCR *jcr, int TermCode) jcr->unlink_bsr = false; } + if (job_canceled(jcr)) { + cancel_storage_daemon_job(jcr); + } + switch (TermCode) { case JS_Terminated: if (jcr->ExpectedFiles > jcr->jr.JobFiles) { diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 26c8b2f589..17e1443c50 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -211,8 +211,7 @@ bool do_verify(JCR *jcr) */ set_jcr_job_status(jcr, JS_Blocked); if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) { - cancel_storage_daemon_job(jcr); - return false; + goto bail_out; } set_jcr_job_status(jcr, JS_Running); @@ -221,12 +220,12 @@ bool do_verify(JCR *jcr) Dmsg0(30, ">filed: Send include list\n"); if (!send_include_list(jcr)) { - return false; + goto bail_out; } Dmsg0(30, ">filed: Send exclude list\n"); if (!send_exclude_list(jcr)) { - return false; + goto bail_out; } /* @@ -249,7 +248,7 @@ bool do_verify(JCR *jcr) } bnet_fsend(fd, storaddr, jcr->rstore->address, jcr->rstore->SDDport); if (!response(jcr, fd, OKstore, "Storage", DISPLAY_ERROR)) { - return false; + goto bail_out; } /* @@ -257,12 +256,12 @@ bool do_verify(JCR *jcr) */ if (!send_bootstrap_file(jcr, fd) || !response(jcr, fd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { - return false; + goto bail_out; } if (!jcr->RestoreBootstrap) { Jmsg0(jcr, M_FATAL, 0, _("Deprecated feature ... use bootstrap.\n")); - return false; + goto bail_out; } level = "volume"; @@ -276,19 +275,19 @@ bool do_verify(JCR *jcr) default: Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->JobLevel, jcr->JobLevel); - return false; + goto bail_out; } if (!send_runscripts_commands(jcr)) { - return false; + goto bail_out; } /* * Send verify command/level to File daemon */ - bnet_fsend(fd, verifycmd, level); + fd->fsend(verifycmd, level); if (!response(jcr, fd, OKverify, "Verify", DISPLAY_ERROR)) { - return false; + goto bail_out; } /* @@ -329,7 +328,7 @@ bool do_verify(JCR *jcr) default: Jmsg1(jcr, M_FATAL, 0, _("Unimplemented verify level %d\n"), jcr->JobLevel); - return false; + goto bail_out; } stat = wait_for_job_termination(jcr); @@ -337,6 +336,9 @@ bool do_verify(JCR *jcr) verify_cleanup(jcr, stat); return true; } + +bail_out: + verify_cleanup(jcr, JS_ErrorTerminated); return false; } @@ -374,6 +376,10 @@ void verify_cleanup(JCR *jcr, int TermCode) update_job_end(jcr, TermCode); + if (job_canceled(jcr)) { + cancel_storage_daemon_job(jcr); + } + if (jcr->unlink_bsr && jcr->RestoreBootstrap) { unlink(jcr->RestoreBootstrap); jcr->unlink_bsr = false; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 4d1d4e8842..8154946c41 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,10 @@ Technical notes on version 2.3 General: +13Sep07 +kes Cancel storage daemon in all cases where FD reports error. This + should fix virtually all cases of bug #920. +kes Fix db_escape_string() for MySQL which did not compile. 12Sep07 kes Fix error message that was clobbered when Dir tells SD it does not have write permission on Volume. This should fix a minor point