From 41fc196dcb0c73c2c83b5db7bdbd89f67ef39392 Mon Sep 17 00:00:00 2001 From: Michal Rakowski Date: Tue, 1 Dec 2020 14:57:59 +0100 Subject: [PATCH] Fix bscan's flushing file records in batch --- bacula/src/stored/bscan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 3341a71ef..615cbf552 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -756,7 +756,11 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) edit_uint64_with_commas(rec->Addr, ed2), edit_uint64_with_commas(mr.VolBytes, ed3)); } - create_file_attributes_record(mjcr, attr, rec); + if (!create_file_attributes_record(mjcr, attr, rec)) { + Jmsg2(mjcr, M_ERROR, 0, _("Failed to insert record for file: %s. err: %s\n"), + attr->fname, db_strerror(db)); + break; + } break; case STREAM_RESTORE_OBJECT: @@ -1007,9 +1011,12 @@ static void bscan_free_jcr(JCR *jcr) /* Close thej jcr's db connections */ if (jcr->db_batch) { + if (!db_write_batch_file_records(bjcr)) { /* used by bulk batch file insert */ + Jmsg0(jcr, M_ERROR, 0, _("Failed to flush file records!\n")); + } + db_close_database(jcr, jcr->db_batch); jcr->db_batch = NULL; - jcr->batch_started = false; } if (jcr->db) { db_close_database(jcr, jcr->db); -- 2.47.3