From: Kern Sibbald Date: Thu, 6 Nov 2008 21:40:43 +0000 (+0000) Subject: kes Fix bug with job name duplication if more than 60 jobs created X-Git-Tag: Release-3.0.0~624 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8fa2d4cce592cd35a0c9bccc7c99b3c8ce0f19a6;p=bacula%2Fbacula kes Fix bug with job name duplication if more than 60 jobs created during a minute. kes Correct some bugs of cleanup in SD if the FD connection fails git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7999 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index f7f7810c26..2fb91119be 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -874,17 +874,17 @@ void create_unique_job_name(JCR *jcr, const char *base_name) static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static time_t last_start_time = 0; static int seq = 0; - time_t now; + time_t now = time(NULL); struct tm tm; char dt[MAX_TIME_LENGTH]; char name[MAX_NAME_LENGTH]; char *p; + int len; /* Guarantee unique start time -- maximum one per second, and * thus unique Job Name */ P(mutex); /* lock creation of jobs */ - now = time(NULL); seq++; if (seq > 59) { /* wrap as if it is seconds */ seq = 0; @@ -899,9 +899,10 @@ void create_unique_job_name(JCR *jcr, const char *base_name) /* Form Unique JobName */ (void)localtime_r(&now, &tm); /* Use only characters that are permitted in Windows filenames */ - strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M", &tm); + strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm); + len = strlen(dt) + 5; /* dt + .%02d EOS */ bstrncpy(name, base_name, sizeof(name)); - name[sizeof(name)-22] = 0; /* truncate if too long */ + name[sizeof(name)-len] = 0; /* truncate if too long */ bsnprintf(jcr->Job, sizeof(jcr->Job), "%s.%s.%02d", name, dt, seq); /* add date & time */ /* Convert spaces into underscores */ for (p=jcr->Job; *p; p++) { @@ -909,6 +910,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name) *p = '_'; } } + Dmsg2(100, "JobId=%u created Job=%s\n", jcr->JobId, jcr->Job); } /* Called directly from job rescheduling */ diff --git a/bacula/src/lib/bnet_server.c b/bacula/src/lib/bnet_server.c index fcd9483f1c..eb3969d199 100644 --- a/bacula/src/lib/bnet_server.c +++ b/bacula/src/lib/bnet_server.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2000-2008 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. @@ -137,7 +137,7 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq, be.bstrerror()); } } - listen(fd_ptr->fd, 5); /* tell system we are ready */ + listen(fd_ptr->fd, 50); /* tell system we are ready */ sockfds.append(fd_ptr); } /* Start work queue thread */ @@ -239,4 +239,3 @@ bnet_thread_server(dlist *addrs, int max_clients, workq_t *client_wq, } } - diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index a53efa31c3..47370524a1 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -175,6 +175,7 @@ void *handle_connection_request(void *arg) if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) { Dmsg1(110, "Got a FD connection at %s\n", bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL))); + Dmsg1(50, "%s", bs->msg); handle_filed_connection(bs, name); return NULL; } diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 431071c582..c76beb8816 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -154,7 +154,7 @@ bool job_cmd(JCR *jcr) bsnprintf(seed, sizeof(seed), "%p%d", jcr, JobId); make_session_key(auth_key, seed, 1); dir->fsend(OKjob, jcr->VolSessionId, jcr->VolSessionTime, auth_key); - Dmsg2(100, ">dird jid=%u: %s", (uint32_t)jcr->JobId, dir->msg); + Dmsg2(50, ">dird jid=%u: %s", (uint32_t)jcr->JobId, dir->msg); jcr->sd_auth_key = bstrdup(auth_key); memset(auth_key, 0, sizeof(auth_key)); generate_daemon_event(jcr, "JobStart"); @@ -186,7 +186,7 @@ bool run_cmd(JCR *jcr) timeout.tv_nsec = tv.tv_usec * 1000; timeout.tv_sec = tv.tv_sec + me->client_wait; - Dmsg3(050, "%s waiting %d sec for FD to contact SD key=%s\n", + Dmsg3(50, "%s waiting %d sec for FD to contact SD key=%s\n", jcr->Job, (int)(timeout.tv_sec-time(NULL)), jcr->sd_auth_key); /* @@ -201,14 +201,14 @@ bool run_cmd(JCR *jcr) break; } } - Dmsg3(100, "Auth=%d canceled=%d errstat=%d\n", jcr->authenticated, + Dmsg3(50, "Auth=%d canceled=%d errstat=%d\n", jcr->authenticated, job_canceled(jcr), errstat); V(mutex); memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); if (jcr->authenticated && !job_canceled(jcr)) { - Dmsg1(100, "Running job %s\n", jcr->Job); + Dmsg1(50, "Running job %s\n", jcr->Job); run_job(jcr); /* Run the job */ } return false; @@ -230,30 +230,35 @@ void handle_filed_connection(BSOCK *fd, char *job_name) if (!(jcr=get_jcr_by_full_name(job_name))) { Jmsg1(NULL, M_FATAL, 0, _("FD connect failed: Job name not found: %s\n"), job_name); Dmsg1(3, "**** Job \"%s\" not found.\n", job_name); + fd->close(); return; } - jcr->file_bsock = fd; - jcr->file_bsock->set_jcr(jcr); - Dmsg1(110, "Found Job %s\n", job_name); + Dmsg1(50, "Found Job %s\n", job_name); if (jcr->authenticated) { Jmsg2(jcr, M_FATAL, 0, _("Hey!!!! JobId %u Job %s already authenticated.\n"), (uint32_t)jcr->JobId, jcr->Job); + Dmsg2(50, "Hey!!!! JobId %u Job %s already authenticated.\n", + (uint32_t)jcr->JobId, jcr->Job); + fd->close(); free_jcr(jcr); return; } + jcr->file_bsock = fd; + jcr->file_bsock->set_jcr(jcr); + /* * Authenticate the File daemon */ if (jcr->authenticated || !authenticate_filed(jcr)) { - Dmsg1(100, "Authentication failed Job %s\n", jcr->Job); + Dmsg1(50, "Authentication failed Job %s\n", jcr->Job); Jmsg(jcr, M_FATAL, 0, _("Unable to authenticate File daemon\n")); } else { jcr->authenticated = true; - Dmsg2(110, "OK Authentication jid=%u Job %s\n", (uint32_t)jcr->JobId, jcr->Job); + Dmsg2(50, "OK Authentication jid=%u Job %s\n", (uint32_t)jcr->JobId, jcr->Job); } if (!jcr->authenticated) { diff --git a/bacula/src/version.h b/bacula/src/version.h index ac7612dc90..b3826f0c95 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.5.18" -#define BDATE "02 November 2008" -#define LSMDATE "02Nov08" +#define VERSION "2.5.19" +#define BDATE "06 November 2008" +#define LSMDATE "06Nov08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 6746fb782d..2c8df3f552 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -11,7 +11,10 @@ mixed priorities General: 06Nov08 -ebl Add code to get more information after a violent signal. +kes Fix bug with job name duplication if more than 60 jobs created + during a minute. +kes Correct some bugs of cleanup in SD if the FD connection fails. +ebl Add code to get more information after a fatal signal. 05Nov08 ebl Apply Bastian's patch that add spooldata=yes|no option to run command.