enum vacuum_child_status { VACUUM_RUNNING, VACUUM_OK, VACUUM_ERROR, VACUUM_TIMEOUT};
struct ctdb_vacuum_child_context {
+ struct ctdb_vacuum_child_context *next, *prev;
struct ctdb_vacuum_handle *vacuum_handle;
+ /* fd child writes status to */
int fd[2];
pid_t child_pid;
enum vacuum_child_status status;
vdata->vacuum_limit = vacuum_limit;
vdata->repack_limit = repack_limit;
vdata->delete_tree = trbt_create(vdata, 0);
+ vdata->ctdb_db = ctdb_db;
if (vdata->delete_tree == NULL) {
DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
talloc_free(vdata);
kill(child_ctx->child_pid, SIGKILL);
}
+ DLIST_REMOVE(ctdb->vacuumers, child_ctx);
+
event_add_timed(ctdb->ev, child_ctx->vacuum_handle,
timeval_current_ofs(get_vacuum_interval(ctdb_db), 0),
ctdb_vacuum_event, child_ctx->vacuum_handle);
struct tevent_fd *fde;
int ret;
- /* we dont vacuum if we are in recovery mode */
- if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE) {
+ /* we dont vacuum if we are in recovery mode, or db frozen */
+ if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE ||
+ ctdb->freeze_mode[ctdb_db->priority] != CTDB_FREEZE_NONE) {
+ DEBUG(DEBUG_INFO, ("Not vacuuming %s (%s)\n", ctdb_db->db_name,
+ ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE ? "in recovery"
+ : ctdb->freeze_mode[ctdb_db->priority] == CTDB_FREEZE_PENDING
+ ? "freeze pending"
+ : "frozen"));
event_add_timed(ctdb->ev, vacuum_handle, timeval_current_ofs(ctdb->tunable.vacuum_default_interval, 0), ctdb_vacuum_event, vacuum_handle);
return;
}
child_ctx->status = VACUUM_RUNNING;
child_ctx->start_time = timeval_current();
+ DLIST_ADD(ctdb->vacuumers, child_ctx);
talloc_set_destructor(child_ctx, vacuum_child_destructor);
event_add_timed(ctdb->ev, child_ctx,
child_ctx->vacuum_handle = vacuum_handle;
}
+void ctdb_stop_vacuuming(struct ctdb_context *ctdb)
+{
+ /* Simply free them all. */
+ while (ctdb->vacuumers) {
+ DEBUG(DEBUG_INFO, ("Aborting vacuuming for %s (%i)\n",
+ ctdb->vacuumers->vacuum_handle->ctdb_db->db_name,
+ (int)ctdb->vacuumers->child_pid));
+ /* vacuum_child_destructor kills it, removes from list */
+ talloc_free(ctdb->vacuumers);
+ }
+}
/* this function initializes the vacuuming context for a database
* starts the vacuuming events