int len;
struct stat statbuf;
int errstat;
+ int retry = 0;
P(mutex);
if (mdb->connected) {
return 0;
}
+ for (mdb->db=NULL; !mdb->db && retry++ < 10; ) {
#ifdef HAVE_SQLITE3
- int stat = sqlite3_open(db_name, &mdb->db);
- if (stat != SQLITE_OK) {
- mdb->sqlite_errmsg = (char *)sqlite3_errmsg(mdb->db);
- sqlite3_close(mdb->db);
- mdb->db = NULL;
- } else {
- mdb->sqlite_errmsg = NULL;
- }
-#ifdef SQLITE3_INIT_QUERY
- db_sql_query(mdb, SQLITE3_INIT_QUERY, NULL, NULL);
-#endif
-
+ int stat = sqlite3_open(db_name, &mdb->db);
+ if (stat != SQLITE_OK) {
+ mdb->sqlite_errmsg = (char *)sqlite3_errmsg(mdb->db);
+ sqlite3_close(mdb->db);
+ mdb->db = NULL;
+ } else {
+ mdb->sqlite_errmsg = NULL;
+ }
#else
- mdb->db = sqlite_open(
- db_name, /* database name */
- 644, /* mode */
- &mdb->sqlite_errmsg); /* error message */
+ mdb->db = sqlite_open(
+ db_name, /* database name */
+ 644, /* mode */
+ &mdb->sqlite_errmsg); /* error message */
#endif
- Dmsg0(300, "sqlite_open\n");
-
+ Dmsg0(300, "sqlite_open\n");
+ if (!mdb->db) {
+ bmicrosleep(1, 0);
+ }
+ }
if (mdb->db == NULL) {
Mmsg2(&mdb->errmsg, _("Unable to open Database=%s. ERR=%s\n"),
db_name, mdb->sqlite_errmsg ? mdb->sqlite_errmsg : _("unknown"));
}
mdb->connected = true;
free(db_name);
+
+#if defined(HAVE_SQLITE3) && defined(SQLITE3_INIT_QUERY)
+ db_sql_query(mdb, SQLITE3_INIT_QUERY, NULL, NULL);
+#endif
+
if (!check_tables_version(jcr, mdb)) {
V(mutex);
return 0;
General:
26Sep07
-kes Add retry for opening batch db if it fails.
+kes Add retry for SQLite opening db if it fails.
kes Suppress extra error messages during batch insert failure.
kes Add jcr to timer packets so if killed message can be sent to job.
kes Add JobId to all Dmsg() output.