From: Kern Sibbald Date: Fri, 4 Jul 2008 18:18:15 +0000 (+0000) Subject: kes Add some SD debug code. X-Git-Tag: Release-3.0.0~1189 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=518c87e65219f6002ec2daf333325313ad4e7723;p=bacula%2Fbacula kes Add some SD debug code. kes Do find_a_volume() each time an unload is done. kes Apply Joao's DBI patch that adds easier configuration of DBI drivers, and adds --with-db-port to ./configure. kes Use Qmsg() in job.c watchdog callback. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7308 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/bacula-macros/db.m4 b/bacula/autoconf/bacula-macros/db.m4 index 7e1a043c42..4ff0db9f77 100644 --- a/bacula/autoconf/bacula-macros/db.m4 +++ b/bacula/autoconf/bacula-macros/db.m4 @@ -104,6 +104,7 @@ AC_ARG_WITH(dbi, support_dbi=yes db_type=DBI DB_TYPE=dbi + uncomment_dbi=" " else AC_MSG_RESULT(no) @@ -115,6 +116,7 @@ AC_SUBST(SQL_LFLAGS) AC_SUBST(SQL_INCLUDE) AC_SUBST(SQL_BINDIR) AC_SUBST(DBI_DBD_DRIVERDIR) +AC_SUBST(uncomment_dbi) ]) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index fbe179b313..ad5564c124 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1252,6 +1252,20 @@ AC_ARG_WITH(db_password, ) AC_SUBST(db_password) +# +# Pickup a database port +# +db_port=" " +AC_ARG_WITH(db_port, + [ --with-db-port=DBPORT specify a database port (default null)], + [ + if test "x$withval" != "x" ; then + db_port=$withval + fi + ] +) +AC_SUBST(db_port) + # # Handle users and groups for each daemon # @@ -1405,9 +1419,14 @@ if test x$DB_TYPE = xdbi; then else support_batch_insert=yes fi]) - fi + fi +else +# If dbi was not chosen, let the comment in file +uncomment_dbi="#" fi +AC_SUBST(uncomment_dbi) + if test $support_batch_insert = yes ; then AC_DEFINE(HAVE_BATCH_FILE_INSERT, 1, [Set if DB batch insert code enabled]) fi @@ -2463,6 +2482,7 @@ Configuration on `date`: Statically Linked DIR: ${support_static_dir} Statically Linked CONS: ${support_static_cons} Database type: ${db_type} + Database port: ${db_port} Database lib: ${DB_LIBS} Database name: ${db_name} Database user: ${db_user} diff --git a/bacula/configure b/bacula/configure index 565f72d116..deb5ff1966 100755 --- a/bacula/configure +++ b/bacula/configure @@ -824,6 +824,7 @@ mon_sd_password db_name db_user db_password +db_port dir_user dir_group sd_user @@ -835,6 +836,7 @@ SQL_LFLAGS SQL_INCLUDE SQL_BINDIR DBI_DBD_DRIVERDIR +uncomment_dbi DB_PROG DB_PROG_LIB cats @@ -1515,6 +1517,7 @@ Optional Packages: --with-db-name=DBNAME specify database name (default bacula) --with-db-user=UNAME specify database user (default bacula) --with-db-password=UNAME specify database password (default *none*) + --with-db-port=DBPORT specify a database port (default null) --with-dir-user=USER specify user for Director daemon --with-dir-group=GROUP specify group for Director daemon --with-sd-user=USER specify user for Storage daemon @@ -17079,6 +17082,23 @@ fi +# +# Pickup a database port +# +db_port=" " + +# Check whether --with-db_port was given. +if test "${with_db_port+set}" = set; then + withval=$with_db_port; + if test "x$withval" != "x" ; then + db_port=$withval + fi + + +fi + + + # # Handle users and groups for each daemon # @@ -18009,6 +18029,7 @@ echo "${ECHO_T}yes" >&6; } support_dbi=yes db_type=DBI DB_TYPE=dbi + uncomment_dbi=" " else { echo "$as_me:$LINENO: result: no" >&5 @@ -18030,6 +18051,7 @@ fi + db_found=no db_prog=no { echo "$as_me:$LINENO: checking for DBI drivers support" >&5 @@ -18222,8 +18244,13 @@ if test "${enable_batch_insert+set}" = set; then fi fi +else +# If dbi was not chosen, let the comment in file +uncomment_dbi="#" fi + + if test $support_batch_insert = yes ; then cat >>confdefs.h <<\_ACEOF @@ -31509,6 +31536,7 @@ mon_sd_password!$mon_sd_password$ac_delim db_name!$db_name$ac_delim db_user!$db_user$ac_delim db_password!$db_password$ac_delim +db_port!$db_port$ac_delim dir_user!$dir_user$ac_delim dir_group!$dir_group$ac_delim sd_user!$sd_user$ac_delim @@ -31520,6 +31548,7 @@ SQL_LFLAGS!$SQL_LFLAGS$ac_delim SQL_INCLUDE!$SQL_INCLUDE$ac_delim SQL_BINDIR!$SQL_BINDIR$ac_delim DBI_DBD_DRIVERDIR!$DBI_DBD_DRIVERDIR$ac_delim +uncomment_dbi!$uncomment_dbi$ac_delim DB_PROG!$DB_PROG$ac_delim DB_PROG_LIB!$DB_PROG_LIB$ac_delim cats!$cats$ac_delim @@ -31550,7 +31579,7 @@ DISTVER!$DISTVER$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 59; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 61; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -32241,6 +32270,7 @@ Configuration on `date`: Statically Linked DIR: ${support_static_dir} Statically Linked CONS: ${support_static_cons} Database type: ${db_type} + Database port: ${db_port} Database lib: ${DB_LIBS} Database name: ${db_name} Database user: ${db_user} diff --git a/bacula/src/dird/bacula-dir.conf.in b/bacula/src/dird/bacula-dir.conf.in index b39bd408d0..c39275d5d0 100644 --- a/bacula/src/dird/bacula-dir.conf.in +++ b/bacula/src/dird/bacula-dir.conf.in @@ -232,7 +232,7 @@ Storage { Catalog { Name = MyCatalog # Uncomment the following line if you want the dbi driver -# dbdriver = "dbi:mysql"; dbaddress = 127.0.0.1; dbport = 3306 +@uncomment_dbi@ dbdriver = "dbi:@DB_TYPE@"; dbaddress = 127.0.0.1; dbport = @db_port@ dbname = "@db_name@"; dbuser = "@db_user@"; dbpassword = "@db_password@" } diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 0c735578dd..59a83d760c 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -501,17 +501,17 @@ static void job_monitor_watchdog(watchdog_t *self) /* check MaxWaitTime */ if (job_check_maxwaittime(jcr)) { set_jcr_job_status(jcr, JS_Canceled); - Jmsg(jcr, M_FATAL, 0, _("Max wait time exceeded. Job canceled.\n")); + Qmsg(jcr, M_FATAL, 0, _("Max wait time exceeded. Job canceled.\n")); cancel = true; /* check MaxRunTime */ } else if (job_check_maxruntime(jcr)) { set_jcr_job_status(jcr, JS_Canceled); - Jmsg(jcr, M_FATAL, 0, _("Max run time exceeded. Job canceled.\n")); + Qmsg(jcr, M_FATAL, 0, _("Max run time exceeded. Job canceled.\n")); cancel = true; /* check MaxRunSchedTime */ } else if (job_check_maxschedruntime(jcr)) { set_jcr_job_status(jcr, JS_Canceled); - Jmsg(jcr, M_FATAL, 0, _("Max sched run time exceeded. Job canceled.\n")); + Qmsg(jcr, M_FATAL, 0, _("Max sched run time exceeded. Job canceled.\n")); cancel = true; } diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 1e97a4e12c..1fb6b98235 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -424,7 +424,7 @@ void free_jcr(JCR *jcr) lock_jcr_chain(); jcr->dec_use_count(); /* decrement use count */ if (jcr->use_count() < 0) { - Emsg2(M_ERROR, 0, _("JCR use_count=%d JobId=%d\n"), + Jmsg2(jcr, M_ERROR, 0, _("JCR use_count=%d JobId=%d\n"), jcr->use_count(), jcr->JobId); } if (jcr->JobId > 0) { @@ -484,8 +484,8 @@ void free_jcr(JCR *jcr) break; default: break; - } + if (jcr->daemon_free_jcr) { jcr->daemon_free_jcr(jcr); /* call daemon free routine */ } @@ -825,7 +825,7 @@ bool init_jcr_subsystem(void) static void jcr_timeout_check(watchdog_t *self) { JCR *jcr; - BSOCK *fd; + BSOCK *bs; time_t timer_start; Dmsg0(dbglvl, "Start JCR timeout checks\n"); @@ -838,37 +838,37 @@ static void jcr_timeout_check(watchdog_t *self) if (jcr->JobId == 0) { continue; } - fd = jcr->store_bsock; - if (fd) { - timer_start = fd->timer_start; - if (timer_start && (watchdog_time - timer_start) > fd->timeout) { - fd->timer_start = 0; /* turn off timer */ - fd->set_timed_out(); - Jmsg(jcr, M_ERROR, 0, _( + bs = jcr->store_bsock; + if (bs) { + timer_start = bs->timer_start; + if (timer_start && (watchdog_time - timer_start) > bs->timeout) { + bs->timer_start = 0; /* turn off timer */ + bs->set_timed_out(); + Qmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading Storage daemon.\n"), watchdog_time - timer_start); pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); } } - fd = jcr->file_bsock; - if (fd) { - timer_start = fd->timer_start; - if (timer_start && (watchdog_time - timer_start) > fd->timeout) { - fd->timer_start = 0; /* turn off timer */ - fd->set_timed_out(); - Jmsg(jcr, M_ERROR, 0, _( + bs = jcr->file_bsock; + if (bs) { + timer_start = bs->timer_start; + if (timer_start && (watchdog_time - timer_start) > bs->timeout) { + bs->timer_start = 0; /* turn off timer */ + bs->set_timed_out(); + Qmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading File daemon.\n"), watchdog_time - timer_start); pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); } } - fd = jcr->dir_bsock; - if (fd) { - timer_start = fd->timer_start; - if (timer_start && (watchdog_time - timer_start) > fd->timeout) { - fd->timer_start = 0; /* turn off timer */ - fd->set_timed_out(); - Jmsg(jcr, M_ERROR, 0, _( + bs = jcr->dir_bsock; + if (bs) { + timer_start = bs->timer_start; + if (timer_start && (watchdog_time - timer_start) > bs->timeout) { + bs->timer_start = 0; /* turn off timer */ + bs->set_timed_out(); + Qmsg(jcr, M_ERROR, 0, _( "Watchdog sending kill after %d secs to thread stalled reading Director.\n"), watchdog_time - timer_start); pthread_kill(jcr->my_thread_id, TIMEOUT_SIGNAL); diff --git a/bacula/src/lib/rwlock.c b/bacula/src/lib/rwlock.c index 692f02d2c6..563752c0b8 100644 --- a/bacula/src/lib/rwlock.c +++ b/bacula/src/lib/rwlock.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2007 Free Software Foundation Europe e.V. + Copyright (C) 2001-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -294,11 +294,13 @@ int rwl_writeunlock(brwlock_t *rwl) return stat; } if (rwl->w_active <= 0) { - Emsg0(M_ABORT, 0, _("rwl_writeunlock called too many times.\n")); + pthread_mutex_unlock(&rwl->mutex); + Jmsg0(NULL, M_ABORT, 0, _("rwl_writeunlock called too many times.\n")); } rwl->w_active--; if (!pthread_equal(pthread_self(), rwl->writer_id)) { - Emsg0(M_ABORT, 0, _("rwl_writeunlock by non-owner.\n")); + pthread_mutex_unlock(&rwl->mutex); + Jmsg0(NULL, M_ABORT, 0, _("rwl_writeunlock by non-owner.\n")); } if (rwl->w_active > 0) { stat = 0; /* writers still active */ @@ -364,7 +366,7 @@ void *thread_routine(void *arg) status = rwl_writelock(&data[element].lock); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Write lock failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Write lock failed. ERR=%s\n"), be.bstrerror(status)); } data[element].data = self->thread_num; data[element].writes++; @@ -372,7 +374,7 @@ void *thread_routine(void *arg) status = rwl_writeunlock(&data[element].lock); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Write unlock failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Write unlock failed. ERR=%s\n"), be.bstrerror(status)); } } else { /* @@ -383,7 +385,7 @@ void *thread_routine(void *arg) status = rwl_readlock(&data[element].lock); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Read lock failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Read lock failed. ERR=%s\n"), be.bstrerror(status)); } self->reads++; if (data[element].data == self->thread_num) @@ -391,7 +393,7 @@ void *thread_routine(void *arg) status = rwl_readunlock(&data[element].lock); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Read unlock failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Read unlock failed. ERR=%s\n"), be.bstrerror(status)); } } element++; @@ -433,7 +435,7 @@ int main (int argc, char *argv[]) status = rwl_init (&data[data_count].lock); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Init rwlock failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Init rwlock failed. ERR=%s\n"), be.bstrerror(status)); } } @@ -449,7 +451,7 @@ int main (int argc, char *argv[]) NULL, thread_routine, (void*)&threads[count]); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Create thread failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Create thread failed. ERR=%s\n"), be.bstrerror(status)); } } @@ -461,7 +463,7 @@ int main (int argc, char *argv[]) status = pthread_join (threads[count].thread_id, NULL); if (status != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Join thread failed. ERR=%s\n"), be.bstrerror(status)); + Jmsg1(NULL, M_ABORT, 0, _("Join thread failed. ERR=%s\n"), be.bstrerror(status)); } thread_writes += threads[count].writes; printf (_("%02d: interval %d, writes %d, reads %d\n"), diff --git a/bacula/src/lib/watchdog.c b/bacula/src/lib/watchdog.c index 47e90cf6f0..72263d92cd 100644 --- a/bacula/src/lib/watchdog.c +++ b/bacula/src/lib/watchdog.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2007 Free Software Foundation Europe e.V. + Copyright (C) 2002-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -80,7 +80,7 @@ int start_watchdog(void) if ((errstat=rwl_init(&lock)) != 0) { berrno be; - Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"), + Jmsg1(NULL, M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"), be.bstrerror(errstat)); } wd_queue = New(dlist(dummy, &dummy->link)); @@ -177,13 +177,13 @@ watchdog_t *new_watchdog(void) bool register_watchdog(watchdog_t *wd) { if (!wd_is_init) { - Emsg0(M_ABORT, 0, _("BUG! register_watchdog called before start_watchdog\n")); + Jmsg0(NULL, M_ABORT, 0, _("BUG! register_watchdog called before start_watchdog\n")); } if (wd->callback == NULL) { - Emsg1(M_ABORT, 0, _("BUG! Watchdog %p has NULL callback\n"), wd); + Jmsg1(NULL, M_ABORT, 0, _("BUG! Watchdog %p has NULL callback\n"), wd); } if (wd->interval == 0) { - Emsg1(M_ABORT, 0, _("BUG! Watchdog %p has zero interval\n"), wd); + Jmsg1(NULL, M_ABORT, 0, _("BUG! Watchdog %p has zero interval\n"), wd); } wd_lock(); @@ -203,7 +203,7 @@ bool unregister_watchdog(watchdog_t *wd) bool ok = false; if (!wd_is_init) { - Emsg0(M_ABORT, 0, _("BUG! unregister_watchdog_unlocked called before start_watchdog\n")); + Jmsg0(NULL, M_ABORT, 0, _("BUG! unregister_watchdog_unlocked called before start_watchdog\n")); } wd_lock(); @@ -322,7 +322,7 @@ static void wd_lock() int errstat; if ((errstat=rwl_writelock(&lock)) != 0) { berrno be; - Emsg1(M_ABORT, 0, _("rwl_writelock failure. ERR=%s\n"), + Jmsg1(NULL, M_ABORT, 0, _("rwl_writelock failure. ERR=%s\n"), be.bstrerror(errstat)); } } @@ -337,7 +337,7 @@ static void wd_unlock() int errstat; if ((errstat=rwl_writeunlock(&lock)) != 0) { berrno be; - Emsg1(M_ABORT, 0, _("rwl_writeunlock failure. ERR=%s\n"), + Jmsg1(NULL, M_ABORT, 0, _("rwl_writeunlock failure. ERR=%s\n"), be.bstrerror(errstat)); } } diff --git a/bacula/src/version.h b/bacula/src/version.h index 6c1ddaf4ea..fba4a3771e 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.1" -#define BDATE "02 July 2008" -#define LSMDATE "02Jul08" +#define BDATE "04 July 2008" +#define LSMDATE "04Jul08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index e7fc045302..236aee1588 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -30,7 +30,17 @@ vtape driver General: +04Jul08 +kes Add some SD debug code. +kes Do find_a_volume() each time an unload is done. +kes Apply Joao's DBI patch that adds easier configuration of DBI drivers, + and adds --with-db-port to ./configure. +kes Use Qmsg() in job.c watchdog callback. 03Jul08 +kes Release main control rwlock if ABORTing. +kes Make watchdog connect timeout queue messages rather than sending + directly to avoid lock conflicts with the real thread. +kes Add const char in dbd.c to avoid compiler warnings. kes Fix python compiler string warning. Note, IMO the GNU C++ compiler guys have made a *very* bad change to their compiler. They now force all strings to be 'const' unless you explicitly