Bacula director crashes if it reaches the max number connections to
MySQL server. (Or any other database) as it tries to store the
failure to connect to the database in the database over a non
connected database connection. Things like mysql_real_escape_string
which is used in that code path depend on a connected database
connection which we don't have.
switch (d->dest_code) {
case MD_CATALOG:
char ed1[50];
- if (!jcr || !jcr->db) {
+ if (!jcr || !jcr->db || !jcr->db->is_connected()) {
break;
}
if (p_sql_query && p_sql_escape) {
POOLMEM *esc_msg = get_pool_memory(PM_MESSAGE);
int len = strlen(msg) + 1;
- esc_msg = check_pool_memory_size(esc_msg, len*2+1);
+ esc_msg = check_pool_memory_size(esc_msg, len * 2 + 1);
p_sql_escape(jcr, jcr->db, esc_msg, msg, len);
bstrutime(dt, sizeof(dt), mtime);