/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2000-2017 Kern Sibbald
+ Copyright (C) 2000-2019 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
boffset_t m_last_data_end; /* offset of last valid data written */
int32_t m_FileIndex; /* attr spool FI */
int32_t m_lastFileIndex; /* last valid attr spool FI */
+ int32_t m_lastFlushIndex; /* Last FileIndex flushed */
bool m_spool: 1; /* set for spooling */
bool m_compress: 1; /* set to use comm line compression */
uint64_t m_CommBytes; /* Bytes sent */
m_data_end = ftello(m_spool_fd);
}
};
+ void set_lastFlushIndex(int32_t FlushIndex) { m_lastFlushIndex = FlushIndex; };
boffset_t get_last_data_end() { return m_last_data_end; };
- int32_t get_lastFileIndex() { return m_lastFileIndex; };
+ uint32_t get_lastFileIndex() { return m_lastFileIndex; };
+ uint32_t get_lastFlushIndex() { return m_lastFlushIndex; };
uint32_t CommBytes() { return m_CommBytes; };
uint32_t CommCompressedBytes() { return m_CommCompressedBytes; };
void set_spooling() { m_spool = true; };
/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2000-2017 Kern Sibbald
+ Copyright (C) 2000-2019 Kern Sibbald
The original author of Bacula is Kern Sibbald, with contributions
from many others, a complete list can be found in the file AUTHORS.
* Check if we can mark this job incomplete
*
*/
-void possible_incomplete_job(JCR *jcr, int32_t last_file_index)
+void possible_incomplete_job(JCR *jcr, uint32_t last_file_index)
{
+ BSOCK *dir = jcr->dir_bsock;
/*
* Note, here we decide if it is worthwhile to restart
* the Job at this point. For the moment, if at least
* 10 Files have been seen.
- * We must be sure that the saved files are safe.
- * Using this function when their is as comm line problem is probably safe,
+ * We must be sure that the saved files are safe.
+ * Using this function when there is as comm line problem is probably safe,
* it is inappropriate to use it for a any failure that could
* involve corrupted data.
+ * We cannot mark a job Incomplete if we have already flushed
+ * a bad JobMedia record (i.e. one beyond the last FileIndex
+ * that is known to be good).
*/
- if (jcr->spool_attributes && last_file_index > 10) {
+ if (jcr->spool_attributes && last_file_index > 10 &&
+ dir->get_lastFlushIndex() < last_file_index) {
jcr->setJobStatus(JS_Incomplete);
}
}
dir->fsend(Create_jobmedia, jcr->JobId);
foreach_dlist(item, jcr->jobmedia_queue) {
+ if (jcr->is_JobStatus(JS_Incomplete)) {
+ if (item->VolFirstIndex >= dir->get_lastFileIndex()) {
+ continue;
+ }
+ if (item->VolLastIndex >= dir->get_lastFileIndex()) {
+ item->VolLastIndex = dir->get_lastFileIndex() - 1;
+ }
+ }
ok = dir->fsend("%u %u %u %u %u %u %lld\n",
item->VolFirstIndex, item->VolLastIndex,
item->StartFile, item->EndFile,
item->StartBlock, item->EndBlock,
item->VolMediaId);
+ /* Keep track of last FileIndex flushed */
+ dir->set_lastFlushIndex(item->VolLastIndex);
Dmsg2(400, "sd->dir: ok=%d Jobmedia=%s", ok, dir->msg);
}
dir->signal(BNET_EOD);
* to the last correctly saved file so that the JobMedia
* LastIndex is correct.
*
- * Note: ***FIXME*** though it is not required, we probably
- * should also keep a last EndFile and last EndBlock and
- * reset them correctly too so that the JobMedia record is
- * really correct.
*/
if (jcr->is_JobStatus(JS_Incomplete)) {
dcr->VolLastIndex = dir->get_lastFileIndex();
item->VolMediaId = dcr->VolMediaId;
}
jcr->jobmedia_queue->append(item);
- /* Flush at 100 queue size of 100 jobmedia records */
- if (zero || jcr->jobmedia_queue->size() >= 100) {
+ /* Flush at queue size of 1000 jobmedia records */
+ if (zero || jcr->jobmedia_queue->size() >= 1000) {
ok = flush_jobmedia_queue(jcr);
}