logging: give a unique logging name to each forked child.
[metze/ctdb/wip.git] / server / ctdb_vacuum.c
index 0ab52801d62caf2f31e366167d8fc54ddad66c80..2f751b326d1eb5180b7de605334c9d45ba87076b 100644 (file)
@@ -516,19 +516,22 @@ static int update_tuning_db(struct ctdb_db_context *ctdb_db, struct vacuum_data
        struct vacuum_tuning_data tdata;
        struct vacuum_tuning_data *tptr;
        char *vac_dbname;
+       int flags;
 
        vac_dbname = talloc_asprintf(tmp_ctx, "%s/%s.%u",
-                                       ctdb_db->ctdb->db_directory, 
-                                       TUNINGDBNAME, ctdb_db->ctdb->pnn);
+                                    ctdb_db->ctdb->db_directory_state,
+                                    TUNINGDBNAME, ctdb_db->ctdb->pnn);
        if (vac_dbname == NULL) {
                DEBUG(DEBUG_CRIT,(__location__ " Out of memory error while allocating '%s'\n", vac_dbname));
                talloc_free(tmp_ctx);
                return -1;
        }
 
+       flags  = ctdb_db->ctdb->valgrinding ? TDB_NOMMAP : 0;
+       flags |= TDB_DISALLOW_NESTING;
        tune_tdb = tdb_open(vac_dbname, 0,
-                           TDB_DISALLOW_NESTING,
-                           O_RDWR|O_CREAT, 0644);
+                           flags,
+                           O_RDWR|O_CREAT, 0600);
        if (tune_tdb == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " Failed to create/open %s\n", TUNINGDBNAME));
                talloc_free(tmp_ctx);
@@ -568,7 +571,7 @@ static int update_tuning_db(struct ctdb_db_context *ctdb_db, struct vacuum_data
                                tdata.new_interval > ctdb_db->ctdb->tunable.vacuum_max_interval) {
                                tdata.new_interval = ctdb_db->ctdb->tunable.vacuum_min_interval;
                        }               
-                       DEBUG(DEBUG_ERR,("Decreasing vacuum interval %u -> %u for %s\n", 
+                       DEBUG(DEBUG_INFO,("Decreasing vacuum interval %u -> %u for %s\n", 
                                         tdata.last_interval, tdata.new_interval, ctdb_db->db_name));
                }
                tdata.last_interval = tdata.new_interval;
@@ -681,6 +684,7 @@ static int get_vacuum_interval(struct ctdb_db_context *ctdb_db)
        char *vac_dbname;
        uint interval = ctdb_db->ctdb->tunable.vacuum_default_interval;
        struct ctdb_context *ctdb = ctdb_db->ctdb;
+       int flags;
 
        vac_dbname = talloc_asprintf(tmp_ctx, "%s/%s.%u", ctdb->db_directory, TUNINGDBNAME, ctdb->pnn);
        if (vac_dbname == NULL) {
@@ -689,9 +693,11 @@ static int get_vacuum_interval(struct ctdb_db_context *ctdb_db)
                return interval;
        }
 
+       flags  = ctdb_db->ctdb->valgrinding ? TDB_NOMMAP : 0;
+       flags |= TDB_DISALLOW_NESTING;
        tdb = tdb_open(vac_dbname, 0,
-                      TDB_DISALLOW_NESTING,
-                      O_RDWR|O_CREAT, 0644);
+                      flags,
+                      O_RDWR|O_CREAT, 0600);
        if (!tdb) {
                DEBUG(DEBUG_ERR,("Unable to open/create database %s using default interval\n", vac_dbname));
                talloc_free(tmp_ctx);
@@ -835,7 +841,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 
                DEBUG(DEBUG_INFO,("Vacuuming child process %d for db %s started\n", getpid(), ctdb_db->db_name));
        
-               if (switch_from_server_to_client(ctdb) != 0) {
+               if (switch_from_server_to_client(ctdb, "vacuum-%s", ctdb_db->db_name) != 0) {
                        DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch vacuum daemon into client mode. Shutting down.\n"));
                        _exit(1);
                }
@@ -861,7 +867,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
                timeval_current_ofs(ctdb->tunable.vacuum_max_run_time, 0),
                vacuum_child_timeout, child_ctx);
 
-       DEBUG(DEBUG_INFO, (__location__ " Created PIPE FD:%d to child vacuum process\n", child_ctx->fd[0]));
+       DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d to child vacuum process\n", child_ctx->fd[0]));
 
        event_add_fd(ctdb->ev, child_ctx, child_ctx->fd[0],
                EVENT_FD_READ|EVENT_FD_AUTOCLOSE,