return false;
}
jcr->JobFiles = job.value;
+ Dmsg1(100, "==== FI=%ld\n", jcr->JobFiles);
Mmsg(buf, "SELECT VolSessionId FROM Job WHERE JobId=%s", ed1);
if (!db_sql_query(jcr->db, buf.c_str(), db_int64_handler, &job)) {
Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
}
if (is_bnet_error(fd)) {
+ int i = 0;
Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"),
job_type_to_str(jcr->getJobType()), fd->bstrerror());
+ while (i++ < 10 && jcr->job->RescheduleIncompleteJobs && jcr->is_canceled()) {
+ bmicrosleep(3, 0);
+ }
+
}
fd->signal(BNET_TERMINATE); /* tell Client we are terminating */
}
* Force cancel in SD if failing, but not for Incomplete jobs
* so that we let the SD despool.
*/
- if (jcr->is_canceled() || !fd_ok) {
+ Dmsg5(100, "cancel=%d fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", jcr->is_canceled(), fd_ok, jcr->FDJobStatus,
+ jcr->JobStatus, jcr->SDJobStatus);
+ if (jcr->is_canceled() || (!jcr->job->RescheduleIncompleteJobs && !fd_ok)) {
+ Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus,
+ jcr->JobStatus, jcr->SDJobStatus);
cancel_storage_daemon_job(jcr);
}
jcr->wait_time = time(NULL);
}
jcr->SDJobStatus = SDJobStatus;
+ if (jcr->SDJobStatus == JS_Incomplete) {
+ jcr->setJobStatus(JS_Incomplete);
+ }
+
}
/*
bool is_incomplete() { return JobStatus == JS_Incomplete; };
bool is_JobLevel(int32_t JobLevel) { return JobLevel == m_JobLevel; };
bool is_JobType(int32_t JobType) { return JobType == m_JobType; };
+ bool is_JobStatus(int32_t aJobStatus) { return aJobStatus == JobStatus; };
void set_JobLevel(int32_t JobLevel) { m_JobLevel = JobLevel; };
void setJobLevel(int32_t JobLevel) { m_JobLevel = JobLevel; };
void set_JobType(int32_t JobType) { m_JobType = JobType; };
int m_port; /* desired port */
btimer_t *m_tid; /* timer id */
boffset_t m_data_end; /* offset of last valid data written */
+ int32_t m_FileIndex; /* last valid attr spool FI */
volatile bool m_timed_out: 1; /* timed out in read/write */
volatile bool m_terminated: 1; /* set when BNET_TERMINATE arrives */
bool m_duped: 1; /* set if duped BSOCK */
if (sscanf(fd->msg, "%ld %ld", &file_index, &stream) != 2) {
Jmsg1(jcr, M_FATAL, 0, _("Malformed data header from FD: %s\n"), fd->msg);
ok = false;
+ possible_incomplete_job(jcr, last_file_index);
break;
}
if (ok && !jcr->is_job_canceled()) {
Jmsg1(jcr, M_FATAL, 0, _("Error writing end session label. ERR=%s\n"),
dev->bstrerror());
+ possible_incomplete_job(jcr, last_file_index);
}
set_jcr_job_status(jcr, JS_ErrorTerminated);
ok = false;
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
dev->print_name(), dev->bstrerror());
Dmsg0(100, _("Set ok=FALSE after write_block_to_device.\n"));
+ possible_incomplete_job(jcr, last_file_index);
}
set_jcr_job_status(jcr, JS_ErrorTerminated);
ok = false;
}
- if (dev->VolCatInfo.VolCatName[0] == 0) {
- Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
- Dmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
- }
}
- if (!ok && (jcr->getJobStatus() != JS_Incomplete)) {
+ if (!ok && !jcr->is_JobStatus(JS_Incomplete)) {
discard_data_spool(dcr);
} else {
/* Note: if commit is OK, the device will remain blocked */
*/
release_device(dcr);
- if ((!ok || jcr->is_job_canceled()) && (jcr->getJobStatus() != JS_Incomplete)) {
+ if ((!ok || jcr->is_job_canceled()) && !jcr->is_JobStatus(JS_Incomplete)) {
discard_attribute_spool(jcr);
} else {
commit_attribute_spool(jcr);
Dmsg1(1800, ">dird %s\n", dir->msg); /* Attributes */
if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES ||
rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) {
- dir->set_data_end(); /* set offset of last valid data */
+ Dmsg2(100, "==== set_data_end FI=%ld %s\n", rec->FileIndex, rec->data);
+ dir->set_data_end(rec->FileIndex); /* set offset of last valid data */
}
return dir->send();
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-2011 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
JCR *jcr = dcr->jcr;
int stat;
char ec1[50];
+ BSOCK *dir = jcr->dir_bsock;
Dmsg0(100, "Despooling data\n");
if (jcr->dcr->job_spool_size == 0) {
Dmsg3(800, "Write block ok=%d FI=%d LI=%d\n", ok, block->FirstIndex, block->LastIndex);
}
+ /*
+ * If this Job is incomplete, we need to backup the FileIndex
+ * to the last correctly saved file so that the JobMedia
+ * LastIndex is correct.
+ */
+ if (jcr->is_JobStatus(JS_Incomplete)) {
+ dcr->VolLastIndex = dir->get_FileIndex();
+ Dmsg1(100, "======= Set FI=%ld\n", dir->get_FileIndex());
+ }
+
if (!dir_create_jobmedia_record(dcr)) {
Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
dcr->getVolCatName(), jcr->Job);
bool commit_attribute_spool(JCR *jcr)
{
- boffset_t size;
+ boffset_t size, data_end;
char ec1[30];
char tbuf[100];
+ BSOCK *dir;
Dmsg1(100, "Commit attributes at %s\n", bstrftimes(tbuf, sizeof(tbuf),
(utime_t)time(NULL)));
if (are_attributes_spooled(jcr)) {
- if (fseeko(jcr->dir_bsock->m_spool_fd, 0, SEEK_END) != 0) {
+ dir = jcr->dir_bsock;
+ if (fseeko(dir->m_spool_fd, 0, SEEK_END) != 0) {
berrno be;
Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
be.bstrerror());
goto bail_out;
}
- size = ftello(jcr->dir_bsock->m_spool_fd);
+ size = ftello(dir->m_spool_fd);
+ if (jcr->is_JobStatus(JS_Incomplete)) {
+ data_end = dir->get_data_end();
+ /* Check and truncate to last valid data_end if necssary */
+ if (size > data_end) {
+ if (ftruncate(fileno(dir->m_spool_fd), data_end) != 0) {
+ berrno be;
+ Jmsg(jcr, M_FATAL, 0, _("Truncate on attributes file failed: ERR=%s\n"),
+ be.bstrerror());
+ goto bail_out;
+ }
+ Dmsg2(100, "=== Attrib spool truncated from %lld to %lld\n",
+ size, data_end);
+ size = data_end;
+ }
+ }
if (size < 0) {
berrno be;
Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
/* Can't read spool file from director side,
* send content over network.
*/
- jcr->dir_bsock->despool(update_attr_spool_size, size);
+ dir->despool(update_attr_spool_size, size);
}
- return close_attr_spool_file(jcr, jcr->dir_bsock);
+ return close_attr_spool_file(jcr, dir);
}
return true;
bail_out:
- close_attr_spool_file(jcr, jcr->dir_bsock);
+ close_attr_spool_file(jcr, dir);
return false;
}
Maximum Concurrent Jobs = 10
SpoolData=yes
Max Run Time = 30min
- Reschedule On Error = yes
+ Reschedule On Error = no
Reschedule Interval = 10
Reschedule Times = 1
}
# new files, do a Differental then a bunch of query commands
# and finally restore the two files.
#
+
+
+# Query test no longer works because the query file is empty
+exit
+
+
+
+
+
+
TestName="query-test"
JobName=query
. scripts/functions