Deferred attach : at early startup, defer any db attach calls until we are out of...
[sahlberg/ctdb.git] / include / ctdb_private.h
index 953552a78654557db4789af4526447fee9be1ca4..c1499b46385837afbfecbea2500d23e932401385 100644 (file)
 #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
  */
@@ -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;
@@ -114,6 +100,7 @@ struct ctdb_tunable {
        uint32_t deterministic_public_ips;
        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 +117,8 @@ struct ctdb_tunable {
        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;
 };
 
 /*
@@ -218,14 +207,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 */
@@ -286,7 +267,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;
 };
 
@@ -297,56 +278,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
@@ -393,7 +404,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;
@@ -423,7 +434,7 @@ 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 */
@@ -436,13 +447,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;
-       bool do_checkpublicip;
-       struct _trbt_tree_t *server_ids;        
+       struct trbt_tree *server_ids; 
+       bool do_setsched;
+       void *saved_scheduler_param;
        const char *event_script_dir;
        const char *notification_script;
        const char *default_public_interface;
@@ -467,8 +482,16 @@ 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;
+
+       /* Used to defer db attach requests while in recovery mode */
+       struct ctdb_deferred_attach_context *deferred_attach;
 };
 
 struct ctdb_db_context {
@@ -487,6 +510,9 @@ struct ctdb_db_context {
        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;
 };
 
 
@@ -510,139 +536,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,
-                   CTDB_CONTROL_TRANS3_COMMIT           = 119,
-                   CTDB_CONTROL_GET_DB_SEQNUM           = 120,
-                   CTDB_CONTROL_DB_SET_HEALTHY          = 121,
-                   CTDB_CONTROL_DB_GET_HEALTH           = 122,
-                   CTDB_CONTROL_GET_PUBLIC_IP_INFO      = 123,
-                   CTDB_CONTROL_GET_IFACES              = 124,
-                   CTDB_CONTROL_SET_IFACE_LINK_STATE    = 125,
-};     
-
 /*
   structure passed in set_call control
  */
@@ -682,14 +575,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
  */
@@ -747,134 +632,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
-#define CTDB_CTRL_FLAG_OPCODE_SPECIFIC   0xFFFF0000
-       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);
@@ -899,6 +656,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);
@@ -945,7 +703,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
@@ -996,10 +755,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);
 
@@ -1024,8 +779,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__)
 
@@ -1033,9 +788,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);
@@ -1050,7 +803,10 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
                             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);
@@ -1091,24 +847,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;
@@ -1155,20 +893,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;
@@ -1259,7 +983,9 @@ void ctdb_call_resend_all(struct ctdb_context *ctdb);
 void ctdb_node_dead(struct ctdb_node *node);
 void ctdb_node_connected(struct ctdb_node *node);
 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
-void ctdb_high_priority(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, 
@@ -1288,10 +1014,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, 
@@ -1302,10 +1024,6 @@ 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, 
@@ -1390,7 +1108,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);
@@ -1570,6 +1288,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,
@@ -1581,6 +1300,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);
@@ -1633,4 +1353,22 @@ 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