#ifndef _CTDB_PRIVATE_H
#define _CTDB_PRIVATE_H
-#include "ctdb.h"
+#include "ctdb_client.h"
#include <sys/socket.h>
-/* location of daemon socket */
-#define CTDB_PATH "/tmp/ctdb.socket"
-
-/* default ctdb port number */
-#define CTDB_PORT 4379
-
-/* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
-#define CTDB_DS_ALIGNMENT 8
-
-
-#define CTDB_NULL_FUNC 0xFF000001
-#define CTDB_FETCH_FUNC 0xFF000002
-
-
/*
recovery daemon memdump reply address
*/
/*
a tcp connection description
+ also used by tcp_add and tcp_remove controls
*/
struct ctdb_tcp_connection {
ctdb_sock_addr src_addr;
uint32_t traverse_timeout;
uint32_t keepalive_interval;
uint32_t keepalive_limit;
- uint32_t max_lacount;
uint32_t recover_timeout;
uint32_t recover_interval;
uint32_t election_timeout;
uint32_t monitor_interval;
uint32_t tickle_update_interval;
uint32_t script_timeout;
- uint32_t script_ban_count; /* ban after this many consec timeouts*/
- uint32_t script_unhealthy_on_timeout; /* don't ban on timeout; set node unhealthy */
+ uint32_t script_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
+ uint32_t script_unhealthy_on_timeout; /* obsolete */
uint32_t recovery_grace_period;
uint32_t recovery_ban_period;
uint32_t database_hash_size;
uint32_t rerecovery_timeout;
uint32_t enable_bans;
uint32_t deterministic_public_ips;
- uint32_t disable_when_unhealthy;
uint32_t reclock_ping_period;
uint32_t no_ip_failback;
+ uint32_t disable_ip_failover;
uint32_t verbose_memory_names;
uint32_t recd_ping_timeout;
uint32_t recd_ping_failcount;
uint32_t vacuum_max_interval;
uint32_t max_queue_depth_drop_msg;
uint32_t use_status_events_for_monitoring;
+ uint32_t allow_unhealthy_db_read;
+ uint32_t stat_history_interval;
+ uint32_t deferred_attach_timeout;
};
/*
struct ctdb_client_notify_list *notify;
};
+struct ctdb_iface;
/* state associated with a public ip address */
struct ctdb_vnn {
struct ctdb_vnn *prev, *next;
- const char *iface;
+ struct ctdb_iface *iface;
+ const char **ifaces;
ctdb_sock_addr public_address;
uint8_t public_netmask_bits;
const char *name; /* for debug messages */
void *private_data; /* private to transport */
uint32_t pnn;
-#define NODE_FLAGS_DISCONNECTED 0x00000001 /* node isn't connected */
-#define NODE_FLAGS_UNHEALTHY 0x00000002 /* monitoring says node is unhealthy */
-#define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 /* administrator has disabled node */
-#define NODE_FLAGS_BANNED 0x00000008 /* recovery daemon has banned the node */
-#define NODE_FLAGS_DELETED 0x00000010 /* this node has been deleted */
-#define NODE_FLAGS_STOPPED 0x00000020 /* this node has been stopped */
-#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
-#define NODE_FLAGS_INACTIVE (NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
uint32_t flags;
/* used by the dead node monitoring */
across the nodes. it needs to know which public ip's can be handled
by each node.
*/
- struct ctdb_all_public_ips *public_ips;
+ struct ctdb_all_public_ips *known_public_ips;
+ struct ctdb_all_public_ips *available_public_ips;
/* used by the recovery dameon to track when a node should be banned */
struct ctdb_banning_state *ban_state;
};
struct ctdb_context *ctdb;
struct ctdb_message_list *next, *prev;
uint64_t srvid;
- ctdb_message_fn_t message_handler;
+ ctdb_msg_fn_t message_handler;
void *message_private;
};
struct ctdb_queue *queue;
};
-/*
- ctdb status information
- */
-struct ctdb_statistics {
- uint32_t num_clients;
- uint32_t frozen;
- uint32_t recovering;
- uint32_t client_packets_sent;
- uint32_t client_packets_recv;
- uint32_t node_packets_sent;
- uint32_t node_packets_recv;
- uint32_t keepalive_packets_sent;
- uint32_t keepalive_packets_recv;
- struct {
- uint32_t req_call;
- uint32_t reply_call;
- uint32_t req_dmaster;
- uint32_t reply_dmaster;
- uint32_t reply_error;
- uint32_t req_message;
- uint32_t req_control;
- uint32_t reply_control;
- } node;
- struct {
- uint32_t req_call;
- uint32_t req_message;
- uint32_t req_control;
- } client;
- struct {
- uint32_t call;
- uint32_t control;
- uint32_t traverse;
- } timeouts;
- struct {
- double ctdbd;
- double recd;
- } reclock;
- uint32_t total_calls;
- uint32_t pending_calls;
- uint32_t lockwait_calls;
- uint32_t pending_lockwait_calls;
- uint32_t childwrite_calls;
- uint32_t pending_childwrite_calls;
- uint32_t memory_used;
- uint32_t __last_counter; /* hack for control_statistics_all */
- uint32_t max_hop_count;
- double max_call_latency;
- double max_lockwait_latency;
- double max_childwrite_latency;
-};
+
+#define CTDB_UPDATE_STAT(ctdb, counter, value) \
+ { \
+ if (value > ctdb->statistics.counter) { \
+ ctdb->statistics.counter = c->hopcount; \
+ } \
+ if (value > ctdb->statistics_current.counter) { \
+ ctdb->statistics_current.counter = c->hopcount; \
+ } \
+ }
+
+#define CTDB_INCREMENT_STAT(ctdb, counter) \
+ { \
+ ctdb->statistics.counter++; \
+ ctdb->statistics_current.counter++; \
+ }
+
+#define CTDB_DECREMENT_STAT(ctdb, counter) \
+ { \
+ if (ctdb->statistics.counter > 0) \
+ ctdb->statistics.counter--; \
+ if (ctdb->statistics_current.counter > 0) \
+ ctdb->statistics_current.counter--; \
+ }
+
+#define CTDB_UPDATE_RECLOCK_LATENCY(ctdb, name, counter, value) \
+ { \
+ if (value > ctdb->statistics.counter.max) \
+ ctdb->statistics.counter.max = value; \
+ if (value > ctdb->statistics_current.counter.max) \
+ ctdb->statistics_current.counter.max = value; \
+ \
+ if (ctdb->statistics.counter.num == 0 || value < ctdb->statistics.counter.min) \
+ ctdb->statistics.counter.min = value; \
+ if (ctdb->statistics_current.counter.num == 0 || value < ctdb->statistics_current.counter.min) \
+ ctdb->statistics_current.counter.min = value; \
+ \
+ ctdb->statistics.counter.total += value; \
+ ctdb->statistics_current.counter.total += value; \
+ \
+ ctdb->statistics.counter.num++; \
+ ctdb->statistics_current.counter.num++; \
+ \
+ if (ctdb->tunable.reclock_latency_ms != 0) { \
+ if (value*1000 > ctdb->tunable.reclock_latency_ms) { \
+ DEBUG(DEBUG_ERR, ("High RECLOCK latency %fs for operation %s\n", value, name)); \
+ } \
+ } \
+ }
+
+
+#define CTDB_UPDATE_LATENCY(ctdb, db, operation, counter, t) \
+ { \
+ double l = timeval_elapsed(&t); \
+ \
+ if (l > ctdb->statistics.counter.max) \
+ ctdb->statistics.counter.max = l; \
+ if (l > ctdb->statistics_current.counter.max) \
+ ctdb->statistics_current.counter.max = l; \
+ \
+ if (ctdb->statistics.counter.num == 0 || l < ctdb->statistics.counter.min) \
+ ctdb->statistics.counter.min = l; \
+ if (ctdb->statistics_current.counter.num == 0 || l < ctdb->statistics_current.counter.min) \
+ ctdb->statistics_current.counter.min = l; \
+ \
+ ctdb->statistics.counter.total += l; \
+ ctdb->statistics_current.counter.total += l; \
+ \
+ ctdb->statistics.counter.num++; \
+ ctdb->statistics_current.counter.num++; \
+ \
+ if (ctdb->tunable.log_latency_ms !=0) { \
+ if (l*1000 > ctdb->tunable.log_latency_ms) { \
+ DEBUG(DEBUG_WARNING, ("High latency %.6fs for operation %s on database %s\n", l, operation, db->db_name));\
+ } \
+ } \
+ }
+
+
+
#define INVALID_GENERATION 1
#define NUM_DB_PRIORITIES 3
/* main state of the ctdb daemon */
struct ctdb_context {
- struct event_context *ev;
+ struct tevent_context *ev;
struct timeval ctdbd_start_time;
struct timeval last_recovery_started;
struct timeval last_recovery_finished;
const char *name;
const char *db_directory;
const char *db_directory_persistent;
+ const char *db_directory_state;
+ struct tdb_wrap *db_persistent_health;
+ uint32_t db_persistent_startup_generation;
+ uint64_t db_persistent_check_errors;
+ uint64_t max_persistent_check_errors;
const char *transport;
char *recovery_lock_file;
int recovery_lock_fd;
unsigned flags;
uint32_t capabilities;
struct idr_context *idr;
- uint16_t idr_cnt;
+ int lastid;
struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
+ struct ctdb_iface *ifaces; /* list of local interfaces */
char *err_msg;
const struct ctdb_methods *methods; /* transport methods */
const struct ctdb_upcalls *upcalls; /* transport upcalls */
struct ctdb_message_list *message_list;
struct ctdb_daemon_data daemon;
struct ctdb_statistics statistics;
+ struct ctdb_statistics statistics_current;
+#define MAX_STAT_HISTORY 100
+ struct ctdb_statistics statistics_history[MAX_STAT_HISTORY];
struct ctdb_vnn_map *vnn_map;
uint32_t num_clients;
uint32_t recovery_master;
struct ctdb_call_state *pending_calls;
struct ctdb_client_ip *client_ip_list;
+ struct trbt_tree *server_ids;
bool do_setsched;
- bool do_checkpublicip;
void *saved_scheduler_param;
- struct _trbt_tree_t *server_ids;
const char *event_script_dir;
const char *notification_script;
const char *default_public_interface;
struct ctdb_log_state *log;
int start_as_disabled;
int start_as_stopped;
+ bool valgrinding;
uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
uint32_t *recd_ping_count;
TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
TALLOC_CTX *event_script_ctx;
- struct ctdb_monitor_script_status_ctx *current_monitor_status_ctx;
- struct ctdb_monitoring_wire *last_status;
+ struct ctdb_event_script_state *current_monitor;
+ struct ctdb_scripts_wire *last_status[CTDB_EVENT_MAX];
TALLOC_CTX *banning_ctx;
+ struct ctdb_vacuum_child_context *vacuumers;
+
/* mapping from pid to ctdb_client * */
struct ctdb_client_pid_list *client_pids;
+
+ /* used in the recovery daemon to remember the ip allocation */
+ struct trbt_tree *ip_tree;
+
+ /* Used to defer db attach requests while in recovery mode */
+ struct ctdb_deferred_attach_context *deferred_attach;
};
struct ctdb_db_context {
struct tdb_wrap *ltdb;
struct ctdb_registered_call *calls; /* list of registered calls */
uint32_t seqnum;
- struct timed_event *te;
+ struct timed_event *seqnum_update;
struct ctdb_traverse_local_handle *traverse;
bool transaction_active;
struct ctdb_vacuum_handle *vacuum_handle;
+ char *unhealthy_reason;
+ int pending_requests;
+ struct lockwait_handle *lockwait_active;
+ struct lockwait_handle *lockwait_overflow;
+ struct ctdb_persistent_state *persistent_state;
};
ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
}} while (0)
-/*
- the extended header for records in the ltdb
-*/
-struct ctdb_ltdb_header {
- uint64_t rsn;
- uint32_t dmaster;
- uint32_t laccessor;
- uint32_t lacount;
-};
-
-enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
- CTDB_CONTROL_STATISTICS = 1,
- /* #2 removed */
- CTDB_CONTROL_PING = 3,
- CTDB_CONTROL_GETDBPATH = 4,
- CTDB_CONTROL_GETVNNMAP = 5,
- CTDB_CONTROL_SETVNNMAP = 6,
- CTDB_CONTROL_GET_DEBUG = 7,
- CTDB_CONTROL_SET_DEBUG = 8,
- CTDB_CONTROL_GET_DBMAP = 9,
- CTDB_CONTROL_GET_NODEMAPv4 = 10, /* obsolete */
- CTDB_CONTROL_SET_DMASTER = 11,
- /* #12 removed */
- CTDB_CONTROL_PULL_DB = 13,
- CTDB_CONTROL_PUSH_DB = 14,
- CTDB_CONTROL_GET_RECMODE = 15,
- CTDB_CONTROL_SET_RECMODE = 16,
- CTDB_CONTROL_STATISTICS_RESET = 17,
- CTDB_CONTROL_DB_ATTACH = 18,
- CTDB_CONTROL_SET_CALL = 19,
- CTDB_CONTROL_TRAVERSE_START = 20,
- CTDB_CONTROL_TRAVERSE_ALL = 21,
- CTDB_CONTROL_TRAVERSE_DATA = 22,
- CTDB_CONTROL_REGISTER_SRVID = 23,
- CTDB_CONTROL_DEREGISTER_SRVID = 24,
- CTDB_CONTROL_GET_DBNAME = 25,
- CTDB_CONTROL_ENABLE_SEQNUM = 26,
- CTDB_CONTROL_UPDATE_SEQNUM = 27,
- /* #28 removed */
- CTDB_CONTROL_DUMP_MEMORY = 29,
- CTDB_CONTROL_GET_PID = 30,
- CTDB_CONTROL_GET_RECMASTER = 31,
- CTDB_CONTROL_SET_RECMASTER = 32,
- CTDB_CONTROL_FREEZE = 33,
- CTDB_CONTROL_THAW = 34,
- CTDB_CONTROL_GET_PNN = 35,
- CTDB_CONTROL_SHUTDOWN = 36,
- CTDB_CONTROL_GET_MONMODE = 37,
- /* #38 removed */
- /* #39 removed */
- /* #40 removed */
- /* #41 removed */
- CTDB_CONTROL_TAKEOVER_IPv4 = 42, /* obsolete */
- CTDB_CONTROL_RELEASE_IPv4 = 43, /* obsolete */
- CTDB_CONTROL_TCP_CLIENT = 44,
- CTDB_CONTROL_TCP_ADD = 45,
- CTDB_CONTROL_TCP_REMOVE = 46,
- CTDB_CONTROL_STARTUP = 47,
- CTDB_CONTROL_SET_TUNABLE = 48,
- CTDB_CONTROL_GET_TUNABLE = 49,
- CTDB_CONTROL_LIST_TUNABLES = 50,
- CTDB_CONTROL_GET_PUBLIC_IPSv4 = 51, /* obsolete */
- CTDB_CONTROL_MODIFY_FLAGS = 52,
- CTDB_CONTROL_GET_ALL_TUNABLES = 53,
- CTDB_CONTROL_KILL_TCP = 54,
- CTDB_CONTROL_GET_TCP_TICKLE_LIST = 55,
- CTDB_CONTROL_SET_TCP_TICKLE_LIST = 56,
- CTDB_CONTROL_REGISTER_SERVER_ID = 57,
- CTDB_CONTROL_UNREGISTER_SERVER_ID = 58,
- CTDB_CONTROL_CHECK_SERVER_ID = 59,
- CTDB_CONTROL_GET_SERVER_ID_LIST = 60,
- CTDB_CONTROL_DB_ATTACH_PERSISTENT = 61,
- CTDB_CONTROL_PERSISTENT_STORE = 62,
- CTDB_CONTROL_UPDATE_RECORD = 63,
- CTDB_CONTROL_SEND_GRATIOUS_ARP = 64,
- CTDB_CONTROL_TRANSACTION_START = 65,
- CTDB_CONTROL_TRANSACTION_COMMIT = 66,
- CTDB_CONTROL_WIPE_DATABASE = 67,
- /* #68 removed */
- CTDB_CONTROL_UPTIME = 69,
- CTDB_CONTROL_START_RECOVERY = 70,
- CTDB_CONTROL_END_RECOVERY = 71,
- CTDB_CONTROL_RELOAD_NODES_FILE = 72,
- /* #73 removed */
- CTDB_CONTROL_TRY_DELETE_RECORDS = 74,
- CTDB_CONTROL_ENABLE_MONITOR = 75,
- CTDB_CONTROL_DISABLE_MONITOR = 76,
- CTDB_CONTROL_ADD_PUBLIC_IP = 77,
- CTDB_CONTROL_DEL_PUBLIC_IP = 78,
- CTDB_CONTROL_RUN_EVENTSCRIPTS = 79,
- CTDB_CONTROL_GET_CAPABILITIES = 80,
- CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
- CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
- CTDB_CONTROL_TRANS2_COMMIT = 83,
- CTDB_CONTROL_TRANS2_FINISHED = 84,
- CTDB_CONTROL_TRANS2_ERROR = 85,
- CTDB_CONTROL_TRANS2_COMMIT_RETRY = 86,
- CTDB_CONTROL_RECD_PING = 87,
- CTDB_CONTROL_RELEASE_IP = 88,
- CTDB_CONTROL_TAKEOVER_IP = 89,
- CTDB_CONTROL_GET_PUBLIC_IPS = 90,
- CTDB_CONTROL_GET_NODEMAP = 91,
- CTDB_CONTROL_EVENT_SCRIPT_INIT = 92,
- CTDB_CONTROL_EVENT_SCRIPT_START = 93,
- CTDB_CONTROL_EVENT_SCRIPT_STOP = 94,
- CTDB_CONTROL_EVENT_SCRIPT_FINISHED = 95,
- CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
- CTDB_CONTROL_TRAVERSE_KILL = 97,
- CTDB_CONTROL_RECD_RECLOCK_LATENCY = 98,
- CTDB_CONTROL_GET_RECLOCK_FILE = 99,
- CTDB_CONTROL_SET_RECLOCK_FILE = 100,
- CTDB_CONTROL_STOP_NODE = 101,
- CTDB_CONTROL_CONTINUE_NODE = 102,
- CTDB_CONTROL_SET_NATGWSTATE = 103,
- CTDB_CONTROL_SET_LMASTERROLE = 104,
- CTDB_CONTROL_SET_RECMASTERROLE = 105,
- CTDB_CONTROL_ENABLE_SCRIPT = 107,
- CTDB_CONTROL_DISABLE_SCRIPT = 108,
- CTDB_CONTROL_SET_BAN_STATE = 109,
- CTDB_CONTROL_GET_BAN_STATE = 110,
- CTDB_CONTROL_SET_DB_PRIORITY = 111,
- CTDB_CONTROL_GET_DB_PRIORITY = 112,
- CTDB_CONTROL_TRANSACTION_CANCEL = 113,
- CTDB_CONTROL_REGISTER_NOTIFY = 114,
- CTDB_CONTROL_DEREGISTER_NOTIFY = 115,
- CTDB_CONTROL_TRANS2_ACTIVE = 116,
- CTDB_CONTROL_GET_LOG = 117,
- CTDB_CONTROL_CLEAR_LOG = 118,
-};
-
/*
structure passed in set_call control
*/
char iface[1];
};
-/*
- struct for tcp_add and tcp_remove controls
- */
-struct ctdb_control_tcp_vnn {
- ctdb_sock_addr src;
- ctdb_sock_addr dest;
-};
-
/*
persistent store control - update this record on all other nodes
*/
struct ctdb_ltdb_header header;
};
-/*
- operation IDs
-*/
-enum ctdb_operation {
- CTDB_REQ_CALL = 0,
- CTDB_REPLY_CALL = 1,
- CTDB_REQ_DMASTER = 2,
- CTDB_REPLY_DMASTER = 3,
- CTDB_REPLY_ERROR = 4,
- CTDB_REQ_MESSAGE = 5,
- /* #6 removed */
- CTDB_REQ_CONTROL = 7,
- CTDB_REPLY_CONTROL = 8,
- CTDB_REQ_KEEPALIVE = 9,
-};
-
-#define CTDB_MAGIC 0x43544442 /* CTDB */
-#define CTDB_VERSION 1
-
-/*
- packet structures
-*/
-struct ctdb_req_header {
- uint32_t length;
- uint32_t ctdb_magic;
- uint32_t ctdb_version;
- uint32_t generation;
- uint32_t operation;
- uint32_t destnode;
- uint32_t srcnode;
- uint32_t reqid;
-};
-
-struct ctdb_req_call {
- struct ctdb_req_header hdr;
- uint32_t flags;
- uint32_t db_id;
- uint32_t callid;
- uint32_t hopcount;
- uint32_t keylen;
- uint32_t calldatalen;
- uint8_t data[1]; /* key[] followed by calldata[] */
-};
-
-struct ctdb_reply_call {
- struct ctdb_req_header hdr;
- uint32_t status;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-struct ctdb_reply_error {
- struct ctdb_req_header hdr;
- uint32_t status;
- uint32_t msglen;
- uint8_t msg[1];
-};
-
-struct ctdb_req_dmaster {
- struct ctdb_req_header hdr;
- uint32_t db_id;
- uint64_t rsn;
- uint32_t dmaster;
- uint32_t keylen;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-struct ctdb_reply_dmaster {
- struct ctdb_req_header hdr;
- uint32_t db_id;
- uint64_t rsn;
- uint32_t keylen;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-struct ctdb_req_message {
- struct ctdb_req_header hdr;
- uint64_t srvid;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-struct ctdb_req_getdbpath {
- struct ctdb_req_header hdr;
- uint32_t db_id;
-};
-
-struct ctdb_reply_getdbpath {
- struct ctdb_req_header hdr;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-struct ctdb_req_control {
- struct ctdb_req_header hdr;
- uint32_t opcode;
- uint64_t srvid;
- uint32_t client_id;
-#define CTDB_CTRL_FLAG_NOREPLY 1
- uint32_t flags;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-struct ctdb_reply_control {
- struct ctdb_req_header hdr;
- int32_t status;
- uint32_t datalen;
- uint32_t errorlen;
- uint8_t data[1];
-};
-
-struct ctdb_req_keepalive {
- struct ctdb_req_header hdr;
-};
-
-
-/* types of failures possible from TRANS2_COMMIT */
-enum ctdb_trans2_commit_error {
- CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
- CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
- CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
- CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
-};
-
-/* different calls to event scripts. */
-enum ctdb_eventscript_call {
- CTDB_EVENT_STARTUP, /* CTDB starting up: no args. */
- CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
- CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
- CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
- CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
- CTDB_EVENT_STOPPED, /* This node is stopped: no args. */
- CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
- CTDB_EVENT_STATUS, /* Report service status: no args. */
- CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
- CTDB_EVENT_RELOAD /* magic */
-};
-
/* internal prototypes */
void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
TALLOC_CTX *mem_ctx, TDB_DATA *data);
int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
struct ctdb_ltdb_header *header, TDB_DATA data);
+int ctdb_ltdb_delete(struct ctdb_db_context *ctdb_db, TDB_DATA key);
int32_t ctdb_control_start_persistent_update(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
TDB_DATA recdata);
TALLOC_CTX *mem_ctx, int fd, int alignment,
ctdb_queue_cb_fn_t callback,
- void *private_data);
+ void *private_data, const char *fmt, ...)
+ PRINTF_ATTRIBUTE(7,8);
/*
allocate a packet for use in client<->daemon communication
*/
int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
-int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid,
- ctdb_message_fn_t handler,
- void *private_data);
-
int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
uint64_t srvid, TDB_DATA data);
struct ctdb_ltdb_header *header);
int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
- struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx, TDB_DATA *data,
- uint32_t caller);
+ struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
+ TDB_DATA *data);
#define ctdb_reqid_find(ctdb, reqid, type) (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
int ctdb_socket_connect(struct ctdb_context *ctdb);
-void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
-void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l);
-
+#define CTDB_BAD_REQID ((uint32_t)-1)
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
void *private_data);
int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
- TDB_DATA *outdata, uint64_t tdb_flags, bool persistent);
+ TDB_DATA *outdata, uint64_t tdb_flags,
+ bool persistent, uint32_t client_id,
+ struct ctdb_req_control *c,
+ bool *async_reply);
int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
ctdb_fn_t fn, int id);
int ctdb_control_writerecord(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata);
-struct ctdb_traverse_start {
- uint32_t db_id;
- uint32_t reqid;
- uint64_t srvid;
-};
-
-/*
- structure used to pass record data between the child and parent
- */
-struct ctdb_rec_data {
- uint32_t length;
- uint32_t reqid;
- uint32_t keylen;
- uint32_t datalen;
- uint8_t data[1];
-};
-
-
/* structure used for pulldb control */
struct ctdb_control_pulldb {
uint32_t db_id;
};
-/* table that contains a list of all nodes a ctdb knows about and their
- status
- */
-struct ctdb_node_and_flags {
- uint32_t pnn;
- uint32_t flags;
- ctdb_sock_addr addr;
-};
-
-struct ctdb_node_map {
- uint32_t num;
- struct ctdb_node_and_flags nodes[1];
-};
-
struct ctdb_node_and_flagsv4 {
uint32_t pnn;
uint32_t flags;
bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
void ctdb_set_scheduler(struct ctdb_context *ctdb);
void ctdb_restore_scheduler(struct ctdb_context *ctdb);
+pid_t ctdb_fork(struct ctdb_context *ctdb);
int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
TDB_DATA indata,
struct sockaddr_in sin;
};
-struct ctdb_public_ip {
- uint32_t pnn;
- ctdb_sock_addr addr;
-};
int ctdb_ctrl_takeover_ip(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, struct ctdb_public_ip *ip);
int ctdb_ctrl_release_ip(struct ctdb_context *ctdb, struct timeval timeout,
struct ctdb_public_ipv4 ips[1];
};
-struct ctdb_all_public_ips {
- uint32_t num;
- struct ctdb_public_ip ips[1];
-};
int32_t ctdb_control_get_public_ipsv4(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
- struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
+ struct timeval timeout,
+ uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_all_public_ips **ips);
+#define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
+int ctdb_ctrl_get_public_ips_flags(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ struct ctdb_all_public_ips **ips);
int ctdb_ctrl_get_public_ipsv4(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
+#ifdef IFNAMSIZ
+#define CTDB_IFACE_SIZE IFNAMSIZ
+#else
+#define CTDB_IFACE_SIZE 16
+#endif
+
+struct ctdb_control_iface_info {
+ char name[CTDB_IFACE_SIZE+2];
+ uint16_t link_state;
+ uint32_t references;
+};
+
+struct ctdb_control_public_ip_info {
+ struct ctdb_public_ip ip;
+ uint32_t active_idx;
+ uint32_t num;
+ struct ctdb_control_iface_info ifaces[1];
+};
+
+struct ctdb_control_get_ifaces {
+ uint32_t num;
+ struct ctdb_control_iface_info ifaces[1];
+};
+
+int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
+ struct ctdb_req_control *c,
+ TDB_DATA indata,
+ TDB_DATA *outdata);
+int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
+ struct ctdb_req_control *c,
+ TDB_DATA *outdata);
+int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
+ struct ctdb_req_control *c,
+ TDB_DATA indata);
+int ctdb_ctrl_get_public_ip_info(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ const ctdb_sock_addr *addr,
+ struct ctdb_control_public_ip_info **info);
+int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_control_get_ifaces **ifaces);
+int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ const struct ctdb_control_iface_info *info);
/* from takeover/system.c */
uint32_t uint16_checksum(uint16_t *data, size_t n);
uint32_t seq, uint32_t ack, int rst);
int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
+int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
+ const char *iface,
+ const char *ip);
int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
TDB_DATA indata);
-int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata, bool tcp_update_needed);
int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t ctdb_control_uptime(struct ctdb_context *ctdb,
TDB_DATA *outdata);
-int ctdb_attach_persistent(struct ctdb_context *ctdb);
+int ctdb_attach_databases(struct ctdb_context *ctdb);
int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
struct ctdb_req_control *c,
TDB_DATA recdata, bool *async_reply);
+int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
+ struct ctdb_req_control *c,
+ TDB_DATA recdata, bool *async_reply);
+
+void ctdb_persistent_finish_trans3_commits(struct ctdb_context *ctdb);
+
int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
int32_t ctdb_control_transaction_cancel(struct ctdb_context *ctdb);
int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
+ TDB_DATA indata,
+ TDB_DATA *outdata);
int ctdb_vacuum(struct ctdb_context *ctdb, int argc, const char **argv);
void ctdb_unblock_signal(int signum);
int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
int ctdb_set_child_logging(struct ctdb_context *ctdb);
-
+void ctdb_lockdown_memory(struct ctdb_context *ctdb);
typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata);
extern int script_log_level;
+extern bool fast_start;
-int ctdb_ctrl_event_script_init(struct ctdb_context *ctdb);
-int ctdb_ctrl_event_script_start(struct ctdb_context *ctdb, const char *name);
-int ctdb_ctrl_event_script_stop(struct ctdb_context *ctdb, int32_t res);
-int ctdb_ctrl_event_script_finished(struct ctdb_context *ctdb);
-
-int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb);
-int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA indata);
-int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indata);
-int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb);
-
-
-int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata);
+int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb,
+ uint32_t call_type,
+ TDB_DATA *outdata);
int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len);
int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval timeout, double latency);
int32_t ctdb_control_stop_node(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
+void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
int32_t level;
};
+extern int log_ringbuf_size;
+
int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr);
int32_t ctdb_control_clear_log(struct ctdb_context *ctdb);
+
+struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx,
+ struct ctdb_context *ctdb,
+ void (*logfn)(const char *, uint16_t, void *),
+ void *logfn_private, pid_t *pid);
+
int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb, pid_t pid);
+int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
+ TDB_DATA indata,
+ TDB_DATA *outdata);
+
+int ctdb_load_persistent_health(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db);
+int ctdb_update_persistent_health(struct ctdb_context *ctdb,
+ struct ctdb_db_context *ctdb_db,
+ const char *reason,/* NULL means healthy */
+ int num_healthy_nodes);
+int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
+
+void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
+
+void ctdb_fault_setup(void);
+
+int verify_remote_ip_allocation(struct ctdb_context *ctdb,
+ struct ctdb_all_public_ips *ips);
+int update_ip_assignment_tree(struct ctdb_context *ctdb,
+ struct ctdb_public_ip *ip);
+
+int ctdb_init_tevent_logging(struct ctdb_context *ctdb);
+
+int ctdb_statistics_init(struct ctdb_context *ctdb);
+
+int32_t ctdb_control_get_stat_history(struct ctdb_context *ctdb,
+ struct ctdb_req_control *c,
+ TDB_DATA *outdata);
+
+int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
+
+int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
+
#endif