]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2500 .bvfs_get_jobids jobid=X must return X in the list
authorAlain Spineux <alain@baculasystems.com>
Fri, 19 Feb 2021 10:22:20 +0000 (11:22 +0100)
committerEric Bollengier <eric@baculasystems.com>
Fri, 30 Apr 2021 08:26:58 +0000 (10:26 +0200)
- when multiple backups of the same job finish at the exact same time,
  then .bvfs_get_jobids can "mix" them.
- it is not "admissible" to ask bacula for restoring job X and
  see bacula restore job Y because they are "interchangeable".
- this mostly happens in regression test
- the code does : If the jobid is specified then force the SQL query
  to use it.

bacula/src/cats/sql_get.c

index 22eaeb7e42d9ea9784864cda76c4505dd3ed058f..e64fc36ff74f50401cd15eab45b9577572f90a1b 100644 (file)
@@ -1461,7 +1461,7 @@ bool BDB::bdb_get_accurate_jobids(JCR *jcr,
    char clientid[50], jobid[50], filesetid[50];
    char date[MAX_TIME_LENGTH];
    char esc[MAX_ESCAPE_NAME_LENGTH];
-   POOL_MEM query(PM_MESSAGE), name(PM_FNAME);
+   POOL_MEM query(PM_MESSAGE), name(PM_FNAME), aux(PM_FNAME);
 
    /* Take the current time as upper limit if nothing else specified */
    utime_t StartTime = (jr->StartTime)?jr->StartTime:time(NULL);
@@ -1478,11 +1478,13 @@ bool BDB::bdb_get_accurate_jobids(JCR *jcr,
       V(btemp_mutex);
    } else {
       edit_uint64(jcr->JobId, jobid);
+      Mmsg(aux, " AND JobId = %s ", jobid);
    }
 
    if (jr->Name[0] != 0) {
       bdb_escape_string(jcr, esc, jr->Name, strlen(jr->Name));
       Mmsg(name, " AND Name = '%s' ", esc);
+      aux.strcat(name.c_str());
    }
 
    /* First, find the last good Full backup for this job/client/fileset */
@@ -1491,7 +1493,7 @@ bool BDB::bdb_get_accurate_jobids(JCR *jcr,
         edit_uint64(jr->ClientId, clientid),
         date,
         edit_uint64(jr->FileSetId, filesetid),
-        name.c_str()
+        aux.c_str()
       );
 
    if (!bdb_sql_query(query.c_str(), NULL, NULL)) {