mco_HA_attach_replica

This function is called by the master application (primary master process for shared memory application) to wait for a connection request from a replica.

For an overview see page HA Applications

Prototype

    mco_HA_attach_replica(mco_db_h db,
                          char* masterport,
                          timer_unit timeout);

Arguments

db
Database connection handle.
masterport
Transport-layer-dependent address of the master. For example, a port number for TCP and UDP (e.g., "10000") or a pipe name (e.g., "/tmp/test00").
timeout
Connection timeout period. If no replicas connect within this period, the function returns MCO_E_NW_TIMEOUT.

Description

This function is called by the master application (primary master process for shared memory application) to wait for a connection request from a replica. Upon receiving a connection request, it sets up a communication channel and performs initial replica synchronization if needed. Usually, this function is called in a separate thread.

The mco_HA_keep_alive and mco_HA_attach_replica() threads need to have their own separate database connections.

Return Codes

MCO_S_OK
The replica connected successfully.
MCO_E_HA_PROTOCOLERR
The protocol is incompatible.
MCO_E_HA_IOERROR
The master was unable to send or receive a message to or from the replica.
MCO_E_NW_KILLED_BY_REPLICA
The replica completed initial synchronization and sent the KILL_MASTER message to the master. See the mco_HA_replica_params_init() function and the MCO_HAMODE_FORCE_MASTER flag.
MCO_E_NW_TIMEOUT
No replicas connected within the specified timeout period.
other MCO_E_NW_* codes
Errors in the network transport layer.