# HA_Params

> The eXtremeDB High Availability feature (HA) is configured by specifying the parameters and bit mask values described below.

> ### For an overview see page HA Applications

> ## HA Params

> ### Master Parameters

> The following structure is initialized and passed to function `mco_HA_set_master_params()`:

>         typedef struct
>         {
>             uint4 mode_flags; /* < HA modes & options flags */
>             uint2 max_number_of_replicas;
>             mco_device_t async_databuf; /* for MCO_HAMODE_ASYNC */
>             uint4 trans_log_length; /* for STATEFUL_REPLICATION */
>             timer_unit commit_timeout; /* to send transaction data to replica(s) */
>             timer_unit initial_timeout; /* attach_replica() timeout (initial synchronization) */
>             timer_unit synch_timeout;  /* to wait ACK from replica(s) */
>             timer_unit detach_timeout;  /* to detach replica(s) */
>             uint2 mcast_port; /* for multicast */
>             const char *mcast_addr;
>             mco_HA_ErrorHandler errhandler; /* detach replica callback */
>             void  *errhandler_ctx; /* detach replica callback context */
>             uint4  hotsync_msg_objects;
>             uint4  hotsync_msg_size;
>             uint8  initial_ha_sequencer;
>             void  *ssl_params;
>             mco_bool disable_writes_on_kill; /* To allow re-switching from master back to the
>                                  replica instance when the original master has been
>                                 restarted could result in lost transactions. */
>             uint2  quorum; /* initial value of quorum */

>             int    compression_level; /* the level of compression */
>         } mco_HA_master_params_t;

> ### Replica Parameters

> The following structure is initialized and passed to function `mco_HA_attach_master()`:

>         typedef struct
>         {
>             uint4 mode_flags;
>             timer_unit initial_timeout; /* < initial sync timeout */
>             timer_unit commit_timeout; /* read transaction data */
>             timer_unit wait_data_timeout; /* < amount of time replica waits for the next commit */
>             mco_ha_notifying notifying_callback; /* < pointer to notification callback routine */
>             void* notifying_context; /* < user-defined argument for notification callback routine */
>             uint2 repeat_counter; /* < counter of attempts to repeat the commit */
>             uint2 mcast_port;
>             const char *mcast_addr;
>             const char* cancelpoint_addr;
>             MCO_COMMIT_POLICY initial_commit_policy; /* disk commit policy during initial synchronization */
>             uint4             initial_objs_in_trans; /* number of objects per transaction during initial synchronization */
>             void *ssl_params;
>             mco_trans_iterator_callback_t iterator; /* Related to replica-side transactions iteration */
>             void                         *iterator_context; /* Related to replica-side transactions iteration */
>             uint4 batch_commit_length; /* in transactions */
>             uint4         batch_commit_bsize;   /* in bytes */
>             timer_unit    batch_commit_period; /* in milliseconds */
>             int           compression_level; /* the level of compression */

>         } mco_HA_replica_params_t;

> ### Note on Batch Commit Parameters

> If both `batch_commit_length` and `batch_commit_bsize` are 0, the batch commit is not used (regardless of `batch_commit_period` value). This is the default behaviour.

> Note that batch commit makes sense only for asynchronous replication mode or synchronous mode with transaction window size greater than 1. This is because the HA runtime always commits a batch transaction before replica ACKs to the master. This preserves the semantic of synchronous replication: if replica reports a successful commit with ACK, the transaction has already been commited on the replica.

> ### Examples

> Following are example settings for some different batch commit behaviors. In all these examples `batch_commit_period` has the default value 1000 (1 second).

> Merge up to 10 transactions, regardless size of transactions:

>         mco_HA_replica_params_t rpl_p;
>         mco_HA_replica_params_init( &rpl_p );
>         rpl_p.batch_commit_length = 10;

> Merge up to 10 transactions while the total size is less than 100Kb:

>         mco_HA_replica_params_t rpl_p;
>         mco_HA_replica_params_init( &rpl_p );
>         rpl_p.batch_commit_length = 10;
>         rpl_p.batch_commit_bsize = 100 * 1024;

> Merge transactions while the total size is less than 1Mb:

>         mco_HA_replica_params_t rpl_p;
>         mco_HA_replica_params_init( &rpl_p );
>         rpl_p.batch_commit_bsize = 1024 * 1024;

> ## HA Flags

> ### Master Mode Flags

> The `mode_flags` element in structure `mco_HA_master_params_t` is specified as a combination of one or more of the following bit mask values:

>         /* Master mode flags */
>         #define MCO_MASTER_MODE                  0x1
>         #define MCO_HAMODE_MULTIPROCESS_COMMIT   0x2
>         #define MCO_HAMODE_ASYNCH                0x4
>         #define MCO_HAMODE_MCAST                 0x8
>         #define MCO_HAMODE_MCAST_RELIABLE        0x10
>         #define MCO_HAMODE_HOTSYNCH              0x20
>         #define MCO_HAMODE_STATEFUL_REPLICATION  0x40
>         #define MCO_HAMODE_BINEVOLUTION          0x80

> ### Replica Mode Flags

> The `mode_flags` element in structure `mco_HA_replica_params_t` is specified as a combination of one or more of the following bit mask values:

>         /* Replica mode flags */
>         #define MCO_HAMODE_ALLOW_CANCEL           0x2000
>         #define MCO_HAMODE_FORCE_MASTER           0x4000
>         #define MCO_HAMODE_REPLICA_NOTIFICATION   0x8000
>         #define MCO_HAMODE_FORCE_SYNC             0x10000
>         #define MCO_HAMODE_SEND_RESTLIST          0x20000 /* Means that replica and master need to exchange
>                                     information about the registered REST interfaces
>                                     during the initial synchronization phase */
>         #define MCO_HAMODE_EXPLICIT_WRITE_ACCESS  0x40000