Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlaa Eddine Elamri <alaeddine.elamri@bareos.com>2022-11-12 19:07:59 +0300
committerAlaa Eddine Elamri <alaeddine.elamri@bareos.com>2022-11-12 19:07:59 +0300
commitdd6ff441392617cbc13ca5521e972ce9e3931b18 (patch)
tree0905f4dd0804c022530ee0bbdf803165e7bb37e6
parent34c8fd766e9540b0632da2e3f20a3c37ca6e6b2d (diff)
make sure stored updates last checkpoint time and provide it in jcr
asa
-rw-r--r--core/src/cats/sql_update.cc12
-rw-r--r--core/src/dird/catreq.cc9
-rw-r--r--core/src/include/jcr.h1
-rw-r--r--core/src/stored/append.cc8
-rw-r--r--core/src/stored/askdir.cc7
5 files changed, 22 insertions, 15 deletions
diff --git a/core/src/cats/sql_update.cc b/core/src/cats/sql_update.cc
index fbb28479d..0f36128b1 100644
--- a/core/src/cats/sql_update.cc
+++ b/core/src/cats/sql_update.cc
@@ -113,15 +113,12 @@ bool BareosDb::UpdateJobStartRecord(JobControlRecord* jcr, JobDbRecord* jr)
bool BareosDb::UpdateRunningJobRecord(JobControlRecord* jcr)
{
- char timestamp[MAX_TIME_LENGTH];
+ char last_checkpoint_timestamp[MAX_TIME_LENGTH];
- auto now
- = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
-
- bstrutime(timestamp, sizeof(timestamp), now);
+ bstrutime(last_checkpoint_timestamp, sizeof(last_checkpoint_timestamp),
+ jcr->last_checkpoint_time);
jcr->UpdateJobStats();
-
DbLocker _{this};
Mmsg(cmd,
"UPDATE Job SET "
@@ -130,7 +127,8 @@ bool BareosDb::UpdateRunningJobRecord(JobControlRecord* jcr)
"LastCheckpointTime='%s',LastFileProcessed='%s'"
" WHERE JobId=%lu",
jcr->JobFiles, jcr->LastCheckpointFiles, jcr->JobBytes, jcr->AverageRate,
- jcr->LastRate, timestamp, jcr->ar ? jcr->ar->fname : "", jcr->JobId);
+ jcr->LastRate, last_checkpoint_timestamp, jcr->ar ? jcr->ar->fname : "",
+ jcr->JobId);
return UPDATE_DB(jcr, cmd) > 0;
}
diff --git a/core/src/dird/catreq.cc b/core/src/dird/catreq.cc
index a16c472ce..446e3ef80 100644
--- a/core/src/dird/catreq.cc
+++ b/core/src/dird/catreq.cc
@@ -69,7 +69,8 @@ static char Create_job_media[]
static char Update_filelist[] = "Catreq Job=%127s UpdateFileList\n";
static char Update_jobrecord[]
- = "Catreq Job=%127s UpdateJobRecord LastCheckpointFiles=%lu JobFiles=%lu "
+ = "Catreq Job=%127s UpdateJobRecord LastCheckpointTime=%llu "
+ "LastCheckpointFiles=%lu JobFiles=%lu "
"JobBytes=%llu\n";
static char Update_jobstats[]
@@ -364,9 +365,9 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs)
_("Batch database connection not found. Cannot update file list\n"));
}
- } else if (sscanf(bs->msg, Update_jobrecord, &Job, &jcr->LastCheckpointFiles,
- &jcr->JobFiles, &jcr->JobBytes)
- == 4) {
+ } else if (sscanf(bs->msg, Update_jobrecord, &Job, &jcr->last_checkpoint_time,
+ &jcr->LastCheckpointFiles, &jcr->JobFiles, &jcr->JobBytes)
+ == 5) {
Dmsg0(0, "Updating job record\n");
if (!jcr->db->UpdateRunningJobRecord(jcr)) {
diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h
index 22a95c8b2..39b8d99b0 100644
--- a/core/src/include/jcr.h
+++ b/core/src/include/jcr.h
@@ -178,6 +178,7 @@ class JobControlRecord {
time_t start_time{}; /**< When job actually started */
time_t run_time{}; /**< Used for computing speed */
time_t last_time{}; /**< Last sample time */
+ time_t last_checkpoint_time{};/**< Last sample time */
time_t end_time{}; /**< Job end time */
time_t wait_time_sum{}; /**< Cumulative wait time since job start */
time_t wait_time{}; /**< Timestamp when job have started to wait */
diff --git a/core/src/stored/append.cc b/core/src/stored/append.cc
index 9c351a2aa..db7825db2 100644
--- a/core/src/stored/append.cc
+++ b/core/src/stored/append.cc
@@ -39,7 +39,7 @@
#include "lib/berrno.h"
#include "lib/berrno.h"
-#define STATS_UPDATE_INTERVAL 5
+#define STATS_UPDATE_INTERVAL 3
namespace storagedaemon {
@@ -126,6 +126,12 @@ static void UpdateJobStats(JobControlRecord* jcr)
void DoBackupCheckpoint(JobControlRecord* jcr)
{
Dmsg0(100, _("Checkpoint: Syncing current backup status to catalog\n"));
+
+ auto now
+ = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
+
+ jcr->last_checkpoint_time = now;
+
UpdateJobrecord(jcr);
UpdateFileList(jcr);
UpdateJobmediaRecord(jcr);
diff --git a/core/src/stored/askdir.cc b/core/src/stored/askdir.cc
index 6c516a956..6bc59a5c3 100644
--- a/core/src/stored/askdir.cc
+++ b/core/src/stored/askdir.cc
@@ -66,7 +66,8 @@ static char Create_job_media[]
static char Update_filelist[] = "Catreq Job=%s UpdateFileList\n";
static char Update_jobrecord[]
- = "Catreq Job=%s UpdateJobRecord LastCheckpointFiles=%lu JobFiles=%lu "
+ = "Catreq Job=%s UpdateJobRecord LastCheckpointTime=%llu "
+ "LastCheckpointFiles=%lu JobFiles=%lu "
"JobBytes=%llu\n";
static char Update_jobstats[]
@@ -635,8 +636,8 @@ bool StorageDaemonDeviceControlRecord::DirAskToUpdateFileList()
bool StorageDaemonDeviceControlRecord::DirAskToUpdateJobRecord()
{
BareosSocket* dir = jcr->dir_bsock;
- return dir->fsend(Update_jobrecord, jcr->Job, jcr->LastCheckpointFiles,
- jcr->JobFiles, jcr->JobBytes);
+ return dir->fsend(Update_jobrecord, jcr->Job, jcr->last_checkpoint_time,
+ jcr->LastCheckpointFiles, jcr->JobFiles, jcr->JobBytes);
}