void db_end_transaction(JCR *jcr, B_DB *mdb);
int db_int64_handler(void *ctx, int num_fields, char **row);
void db_thread_cleanup();
+void _db_print_dbg(JCR *jcr, FILE *fp);
/* sql_create.c */
bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar);
return true;
}
+/*
+ * !!! WARNING !!! Use this function only when bacula is stopped.
+ * ie, after a fatal signal and before exiting the program
+ * Print information about a B_DB object.
+ */
+void _db_print_dbg(JCR *jcr, FILE *fp)
+{
+ B_DB *mdb = jcr->db;
+
+ if (!mdb) {
+ return;
+ }
+
+ fprintf(fp, "B_DB %p db_name=%s db_user=%s connected=%i\n",
+ mdb, NPRTB(mdb->db_name), NPRTB(mdb->db_user), mdb->connected);
+ fprintf(fp, "\tcmd=\"%s\" changes=%i\n", NPRTB(mdb->cmd), mdb->changes);
+ if (mdb->lock.valid == RWLOCK_VALID) {
+ fprintf(fp, "\tRWLOCK %p w_active=%i w_wait=%i\n", &mdb->lock, mdb->lock.w_active, mdb->lock.w_wait);
+#ifndef HAVE_WIN32
+ fprintf(fp, "\t\tthreadid=0x%x mutex=%p\n", (int)mdb->lock.writer_id, &mdb->lock.mutex);
+#endif
+ }
+}
+
#endif /* HAVE_SQLITE3 || HAVE_MYSQL || HAVE_SQLITE || HAVE_POSTGRESQL*/
FDConnectTimeout = (int)director->FDConnectTimeout;
SDConnectTimeout = (int)director->SDConnectTimeout;
-
#if !defined(HAVE_WIN32)
signal(SIGHUP, reload_config);
#endif
init_job_server(director->MaxConcurrentJobs);
+ dbg_add_hook(_db_print_dbg); /* used to debug B_DB connexion after fatal signal */
+
// init_device_resources();
Dmsg0(200, "wait for next job\n");
extern void free_jcr(JCR *jcr);
#endif
+/* Used to display job information after a fatal signal */
+typedef void (dbg_jcr_hook)(JCR *jcr, FILE *fp);
+void dbg_add_hook(dbg_jcr_hook *fct);
+
#endif /* __JCR_H_ */
return; /* thus interrupting the function */
}
+/* Used to display mdb information after a fatal signal */
+#define MAX_DBG_HOOK 10
+static dbg_jcr_hook *dbg_hooks[MAX_DBG_HOOK];
+static int dbg_jcr_handler_count;
+
+void dbg_add_hook(dbg_jcr_hook *fct)
+{
+ ASSERT(dbg_jcr_handler_count < MAX_DBG_HOOK);
+ dbg_hooks[dbg_jcr_handler_count++] = fct;
+}
+
/*
* !!! WARNING !!!
*
fprintf(fp, "\tdequeing=%i\n", jcr->dequeuing);
fprintf(fp, "\tdb=%p db_batch=%p batch_started=%i\n",
jcr->db, jcr->db_batch, jcr->batch_started);
+
+ for(int i=0; i < dbg_jcr_handler_count; i++) {
+ dbg_jcr_hook *fct = dbg_hooks[i];
+ fct(jcr, fp);
+ }
}
}
mixed priorities
General:
+11Nov08
+ebl Add db and rwlock debug after a fatal signal.
10Nov08
ebl Fix maxwaittime to fit documentation, this time is now counted
from the job start and group all wait periods.