X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=include%2Fctdb_private.h;h=4dcf9a5bf9736d9f4b25b7fc24a07a97f7fa8049;hb=8a143a97a313a2e50fb409f6382c759dbd14cdcd;hp=142bbd5c716b79159d5e64b17d50c6d97e5ead93;hpb=af6656f2844d8fd72204a70358c9d589dbe1bd34;p=sahlberg%2Fctdb.git diff --git a/include/ctdb_private.h b/include/ctdb_private.h index 142bbd5c..4dcf9a5b 100644 --- a/include/ctdb_private.h +++ b/include/ctdb_private.h @@ -20,23 +20,9 @@ #ifndef _CTDB_PRIVATE_H #define _CTDB_PRIVATE_H -#include "ctdb.h" +#include "ctdb_client.h" #include -/* 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 */ @@ -60,6 +46,7 @@ extern pid_t ctdbd_pid; /* a tcp connection description + also used by tcp_add and tcp_remove controls */ struct ctdb_tcp_connection { ctdb_sock_addr src_addr; @@ -95,7 +82,6 @@ struct ctdb_tunable { 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; @@ -103,8 +89,8 @@ struct ctdb_tunable { 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; @@ -112,9 +98,9 @@ struct ctdb_tunable { 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; @@ -130,6 +116,8 @@ struct ctdb_tunable { 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; }; /* @@ -181,12 +169,14 @@ struct ctdb_client { 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; @@ -216,14 +206,6 @@ struct ctdb_node { 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 */ @@ -244,7 +226,8 @@ struct ctdb_node { 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; }; @@ -283,7 +266,7 @@ struct ctdb_message_list { 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; }; @@ -294,56 +277,86 @@ struct ctdb_daemon_data { 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 @@ -390,7 +403,7 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN #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; @@ -406,6 +419,11 @@ struct ctdb_context { 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; @@ -415,10 +433,11 @@ struct ctdb_context { 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 */ @@ -427,15 +446,17 @@ struct ctdb_context { 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; @@ -448,6 +469,7 @@ struct ctdb_context { 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 */ @@ -459,8 +481,13 @@ struct ctdb_context { 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; }; struct ctdb_db_context { @@ -474,10 +501,14 @@ 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; }; @@ -501,132 +532,6 @@ struct ctdb_db_context { 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_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 */ @@ -666,14 +571,6 @@ struct ctdb_control_gratious_arp { 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 */ @@ -731,133 +628,6 @@ struct ctdb_fetch_handle { 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 */ -}; - /* 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); @@ -882,6 +652,7 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db, 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); @@ -928,7 +699,8 @@ struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb, 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 @@ -979,10 +751,6 @@ struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db, */ 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); @@ -1007,8 +775,8 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd 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__) @@ -1016,9 +784,7 @@ void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length); 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); @@ -1074,24 +840,6 @@ int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA 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; @@ -1138,20 +886,6 @@ struct ctdb_control_list_tunable { }; -/* 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; @@ -1244,6 +978,7 @@ void ctdb_node_connected(struct ctdb_node *node); 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, @@ -1272,10 +1007,6 @@ struct ctdb_public_ipv4 { 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, @@ -1286,19 +1017,70 @@ struct ctdb_all_public_ipsv4 { 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); @@ -1309,6 +1091,9 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, 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); @@ -1316,7 +1101,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap); 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); @@ -1414,7 +1199,7 @@ int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb, 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, @@ -1426,10 +1211,18 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb, 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); + 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); @@ -1439,7 +1232,7 @@ void ctdb_block_signal(int signum); 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); @@ -1488,6 +1281,7 @@ int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb); 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; int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, uint32_t call_type, @@ -1499,6 +1293,7 @@ int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval 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); @@ -1522,8 +1317,12 @@ struct ctdb_get_log_addr { 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 *), @@ -1532,4 +1331,35 @@ struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx, 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); + #endif