From ddecd26ac962530b87b6cb5ce552d838432d7d1f Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 24 May 2017 17:19:44 +0200 Subject: [PATCH] Add more debug in src/cats/bvfs.c --- bacula/src/cats/bvfs.c | 17 ++++++++++------- bacula/src/cats/sql_list.c | 3 +-- bacula/src/dird/ua_dotcmds.c | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bacula/src/cats/bvfs.c b/bacula/src/cats/bvfs.c index c43eddcaa0..6b97bb21f9 100644 --- a/bacula/src/cats/bvfs.c +++ b/bacula/src/cats/bvfs.c @@ -1342,9 +1342,11 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, (*hardlink && !is_a_number_list(hardlink))|| (!*hardlink && !*fileid && !*dirid && !*hardlink)) { + Dmsg0(dbglevel, "ERROR: One or more of FileId, DirId or HardLink is not given or not a number.\n"); return false; } if (!check_temp(output_table)) { + Dmsg0(dbglevel, "ERROR: Wrong format for table name (in path field).\n"); return false; } @@ -1374,12 +1376,13 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, Mmsg(tmp, "SELECT Path FROM Path WHERE PathId=%lld", id); if (!db->bdb_sql_query(tmp.c_str(), get_path_handler, (void *)&tmp2)) { - Dmsg0(dbglevel, "Can't search for path\n"); + Dmsg3(dbglevel, "ERROR: Path not found %lld q=%s s=%s\n", + id, tmp.c_str(), tmp2.c_str()); /* print error */ goto bail_out; } if (!strcmp(tmp2.c_str(), "")) { /* path not found */ - Dmsg3(dbglevel, "Path not found %lld q=%s s=%s\n", + Dmsg3(dbglevel, "ERROR: Path not found %lld q=%s s=%s\n", id, tmp.c_str(), tmp2.c_str()); break; } @@ -1431,7 +1434,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, prev_jobid=0; while (get_next_id_from_list(&hardlink, &jobid) == 1) { if (get_next_id_from_list(&hardlink, &id) != 1) { - Dmsg0(dbglevel, "hardlink should be two by two\n"); + Dmsg0(dbglevel, "ERROR: hardlink should be two by two\n"); goto bail_out; } if (jobid != prev_jobid) { /* new job */ @@ -1464,7 +1467,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, Dmsg1(dbglevel_sql, "query=%s\n", query.c_str()); if (!db->bdb_sql_query(query.c_str(), NULL, NULL)) { - Dmsg1(dbglevel, "Can't execute query=%s\n", query.c_str()); + Dmsg1(dbglevel, "ERROR executing query=%s\n", query.c_str()); goto bail_out; } @@ -1474,7 +1477,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, /* TODO: handle jobid filter */ Dmsg1(dbglevel_sql, "query=%s\n", query.c_str()); if (!db->bdb_sql_query(query.c_str(), NULL, NULL)) { - Dmsg1(dbglevel, "Can't execute query=%s\n", query.c_str()); + Dmsg1(dbglevel, "ERROR executing query=%s\n", query.c_str()); goto bail_out; } @@ -1484,7 +1487,7 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, output_table, output_table); Dmsg1(dbglevel_sql, "query=%s\n", query.c_str()); if (!db->bdb_sql_query(query.c_str(), NULL, NULL)) { - Dmsg1(dbglevel, "Can't execute query=%s\n", query.c_str()); + Dmsg1(dbglevel, "ERROR executing query=%s\n", query.c_str()); goto bail_out; } } @@ -1537,7 +1540,7 @@ bail_out: db->bdb_unlock(); return ret; } - + void Bvfs::insert_missing_delta(char *output_table, int64_t *res) { char ed1[50]; diff --git a/bacula/src/cats/sql_list.c b/bacula/src/cats/sql_list.c index 1bd7e65a85..0090a25490 100644 --- a/bacula/src/cats/sql_list.c +++ b/bacula/src/cats/sql_list.c @@ -499,12 +499,11 @@ alist *BDB::bdb_list_job_records(JCR *jcr, JOB_DBR *jr, DB_LIST_HANDLER *sendit, default: break; } - Dmsg1(100, "SQL: %s\n", cmd); free_pool_memory(tmp); free_pool_memory(where); - Dmsg1(000, "cmd: %s\n", cmd); + Dmsg1(100, "SQL: %s\n", cmd); if (!QueryDB(jcr, cmd)) { bdb_unlock(); return NULL; diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index 450d25fd3f..f684e3b094 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -565,6 +565,7 @@ static bool dot_bvfs_restore(UAContext *ua, const char *cmd) char *path=NULL, *jobid=NULL, *username=NULL; char *empty = (char *)""; char *fileid, *dirid, *hardlink; + fileid = dirid = hardlink = empty; if (!bvfs_parse_arg(ua, &pathid, &path, &jobid, &username, @@ -598,7 +599,7 @@ static bool dot_bvfs_restore(UAContext *ua, const char *cmd) if (fs.compute_restore_list(fileid, dirid, hardlink, path)) { ua->send_msg("OK\n"); } else { - ua->error_msg("Can't create restore list\n"); + ua->error_msg("Cannot create restore list.\n"); } return true; -- 2.39.5