]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/accurate-batch.patch
ebl Tweak accurate mode to use a dedicate connexion
[bacula/bacula] / bacula / patches / testing / accurate-batch.patch
1 Index: src/dird/backup.c
2 ===================================================================
3 --- src/dird/backup.c   (revision 7339)
4 +++ src/dird/backup.c   (working copy)
5 @@ -133,6 +133,7 @@
6        return true;
7     }
8     POOLMEM *jobids = get_pool_memory(PM_FNAME);
9 +
10     db_accurate_get_jobids(jcr, jcr->db, &jcr->jr, jobids);
11  
12     if (*jobids == 0) {
13 @@ -150,8 +151,14 @@
14     Dmsg2(200, "jobids=%s nb=%s\n", jobids, nb);
15     jcr->file_bsock->fsend("accurate files=%s\n", nb); 
16  
17 -   db_get_file_list(jcr, jcr->db, jobids, accurate_list_handler, (void *)jcr);
18 +   if (!db_open_batch_connexion(jcr, jcr->db)) {
19 +      Mmsg1(&jcr->db->errmsg, "Can't start accurate mode");
20 +      Jmsg1(jcr, M_FATAL, 0, "%s", jcr->db->errmsg);
21 +      return false;
22 +   }
23  
24 +   db_get_file_list(jcr, jcr->db_batch, jobids, accurate_list_handler, (void *)jcr);
25 +
26     free_pool_memory(jobids);
27     free_pool_memory(nb);
28  
29 Index: src/cats/sql_create.c
30 ===================================================================
31 --- src/cats/sql_create.c       (revision 7339)
32 +++ src/cats/sql_create.c       (working copy)
33 @@ -758,7 +758,7 @@
34  {
35     int JobStatus = jcr->JobStatus;
36  
37 -   if (!jcr->db_batch) {         /* no files to backup ? */
38 +   if (!jcr->batch_started) {         /* no files to backup ? */
39        Dmsg0(50,"db_create_file_record : no files\n");
40        return true;
41     }
42 @@ -831,20 +831,8 @@
43     return true;
44  }
45  
46 -/*
47 - * Create File record in B_DB
48 - *
49 - *  In order to reduce database size, we store the File attributes,
50 - *  the FileName, and the Path separately.  In principle, there
51 - *  is a single FileName record and a single Path record, no matter
52 - *  how many times it occurs.  This is this subroutine, we separate
53 - *  the file and the path and fill temporary tables with this three records.
54 - */
55 -bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
56 +bool db_open_batch_connexion(JCR *jcr, B_DB *mdb)
57  {
58 -   Dmsg1(dbglevel, "Fname=%s\n", ar->fname);
59 -   Dmsg0(dbglevel, "put_file_into_catalog\n");
60 -
61     if (!jcr->db_batch) {
62        Dmsg2(100, "Opendb attr. Stream=%d fname=%s\n", ar->Stream, ar->fname);
63        jcr->db_batch = db_init_database(jcr, 
64 @@ -868,15 +856,42 @@
65           Jmsg1(jcr, M_FATAL, 0, "%s", mdb->errmsg);
66           return false;
67        }      
68 -      
69 +      Dmsg3(100, "initdb ref=%d connected=%d db=%p\n", jcr->db_batch->ref_count,
70 +            jcr->db_batch->connected, jcr->db_batch->db);
71 +
72 +   }
73 +   return true;
74 +}
75 +
76 +/*
77 + * Create File record in B_DB
78 + *
79 + *  In order to reduce database size, we store the File attributes,
80 + *  the FileName, and the Path separately.  In principle, there
81 + *  is a single FileName record and a single Path record, no matter
82 + *  how many times it occurs.  This is this subroutine, we separate
83 + *  the file and the path and fill temporary tables with this three records.
84 + */
85 +bool db_create_file_attributes_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
86 +{
87 +   Dmsg1(dbglevel, "Fname=%s\n", ar->fname);
88 +   Dmsg0(dbglevel, "put_file_into_catalog\n");
89 +
90 +   if (!jcr->batch_started) {
91 +
92 +      if (!db_open_batch_connexion(jcr, mdb)) {
93 +         Mmsg1(&mdb->errmsg, 
94 +              "Can't start batch mode: ERR=%s", db_strerror(jcr->db_batch));
95 +         Jmsg1(jcr, M_FATAL, 0, "%s", mdb->errmsg);
96 +         return false;
97 +      }
98        if (!sql_batch_start(jcr, jcr->db_batch)) {
99           Mmsg1(&mdb->errmsg, 
100                "Can't start batch mode: ERR=%s", db_strerror(jcr->db_batch));
101           Jmsg1(jcr, M_FATAL, 0, "%s", mdb->errmsg);
102           return false;
103        }
104 -      Dmsg3(100, "initdb ref=%d connected=%d db=%p\n", jcr->db_batch->ref_count,
105 -            jcr->db_batch->connected, jcr->db_batch->db);
106 +      jcr->batch_started = true;
107     }
108     B_DB *bdb = jcr->db_batch;
109