From: Eric Bollengier Date: Sun, 2 Aug 2009 09:54:01 +0000 (+0200) Subject: work on stats, fix bug with batch connection X-Git-Tag: Release-5.0.0~345 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1affbc0c7efd608c41fc5dc838ef0493a65020db;p=bacula%2Fbacula work on stats, fix bug with batch connection --- diff --git a/bacula/src/cats/sql_create.c b/bacula/src/cats/sql_create.c index 17d5dd26b3..5d6e16d497 100644 --- a/bacula/src/cats/sql_create.c +++ b/bacula/src/cats/sql_create.c @@ -1145,7 +1145,7 @@ bool db_create_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar) ret = db_create_file_attributes_record(jcr, mdb, ar); } else if (jcr->HasBase) { - ret = db_create_base_file_attributes_record(jcr, jcr->db_batch, ar); + ret = db_create_base_file_attributes_record(jcr, mdb, ar); } else { Jmsg0(jcr, M_FATAL, 0, _("Can't Copy/Migrate job using BaseJob")); @@ -1227,8 +1227,8 @@ bool db_commit_base_file_attributes_record(JCR *jcr, B_DB *mdb) "AND A.Name = B.Name " "ORDER BY B.FileId)", edit_uint64(jcr->JobId, ed1), ed1, ed1); - ret = INSERT_DB(jcr, mdb, mdb->cmd); - Dmsg1(0, "commit_base_file_list = %lld\n", (uint64_t) mdb->num_rows); + ret = QUERY_DB(jcr, mdb, mdb->cmd); + jcr->nb_base_files_used = sql_affected_rows(mdb); db_cleanup_base_file(jcr, mdb); db_unlock(mdb); @@ -1273,8 +1273,7 @@ bool db_create_base_file_list(JCR *jcr, B_DB *mdb, char *jobids) "JOIN File ON (File.FileId = Temp.FileId) " "WHERE File.FileIndex > 0)", (uint64_t)jcr->JobId, jobids); - ret = INSERT_DB(jcr, mdb, mdb->cmd); - Dmsg1(0, "create_base_file_list = %lld\n", (uint64_t) mdb->num_rows); + ret = QUERY_DB(jcr, mdb, mdb->cmd); bail_out: db_unlock(mdb); return ret; diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 8bd170aac8..bbbb4460e0 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -214,8 +214,9 @@ bool send_accurate_current_files(JCR *jcr) } if (jcr->HasBase) { - db_create_base_file_list(jcr, jcr->db_batch, jobids); - db_get_base_file_list(jcr, jcr->db_batch, + jcr->nb_base_files = str_to_int64(nb); + db_create_base_file_list(jcr, jcr->db, jobids); + db_get_base_file_list(jcr, jcr->db, accurate_list_handler, (void *)jcr); } else { @@ -385,9 +386,9 @@ bool do_backup(JCR *jcr) db_write_batch_file_records(jcr); /* used by bulk batch file insert */ if (jcr->HasBase && - !db_commit_base_file_attributes_record(jcr, jcr->db_batch)) + !db_commit_base_file_attributes_record(jcr, jcr->db)) { - Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db_batch)); + Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); } if (stat == JS_Terminated) { @@ -617,6 +618,11 @@ void backup_cleanup(JCR *jcr, int TermCode) jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + if (jcr->HasBase) { + Dmsg3(0, "Base files/Used files %lld/%lld=%.2f%%\n", jcr->nb_base_files, + jcr->nb_base_files_used, + jcr->nb_base_files_used*100.0/jcr->nb_base_files); + } // bmicrosleep(15, 0); /* for debugging SIGHUP */ Jmsg(jcr, msg_type, 0, _("%s %s %s (%s): %s\n" diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index 4ebfe82791..287dd4421c 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -187,7 +187,11 @@ bool accurate_finish(JCR *jcr) } accurate_free(jcr); - } + if (jcr->get_JobLevel() == L_FULL) { + Dmsg1(0, "Space saved with Base jobs: %lld MB\n", + jcr->base_size/(1024*1024)); + } + } return ret; } @@ -372,6 +376,11 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) } #endif + /* compute space saved with basefile */ + if (jcr->get_JobLevel() == L_FULL && !stat) { + jcr->base_size += ff_pkt->statp.st_size; + } + accurate_mark_file_as_seen(jcr, &elt); // Dmsg2(dbglvl, "accurate %s = %d\n", fname, stat); diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 68044dea20..d67f9178e3 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -379,6 +379,7 @@ public: bool VSS; /* VSS used by FD */ bool multi_restore; /* Dir can do multiple storage restore */ htable *file_list; /* Previous file list (accurate mode) */ + uint64_t base_size; /* compute space saved with base job */ #endif /* FILE_DAEMON */