Inspect the state of all connections to an existing database.
MCO_RET mco_db_sniffer(/*IN*/ mco_db_h db,
/*IN*/ mco_sniffer_callback_t callback,
/*IN*/ mco_sniffer_policy policy);
db
callback
policy
This function inspects the state of all connections to the database using the provided user's callback function. It performs database recovery if dead connections were detected. The callback user-defined function must implement logic (using OS, timeout, watchdogs, etc.) to detect dead database connections. If this callback returns
MCO_S_DEAD_CONNECTION, then recovery of the database will be performed according to the sniffer policy specified.The following enum defines the sniffer policy (i.e. when sniffer should call the user-defined callback to check the status of the connection):
typedef enum mco_sniffer_policy {
MCO_SNIFFER_INSPECT_ACTIVE_CONNECTIONS, // Check all active connections
MCO_SNIFFER_INSPECT_ACTIVE_TRANSACTIONS, // Check all active transactions
MCO_SNIFFER_INSPECT_HUNG_TRANSACTIONS // Check only long-running/hung transactions
} mco_sniffer_policy;
Nothing should be done to affect the input parameters, and the function should return
MCO_S_DEAD_CONNECTIONto force database recovery orMCO_S_OKif the connection is OK; any other return code will causemco_db_sniffer()to interrupt and return this error code.
MCO_S_OK
MCO_E_ILLEGAL_PARAM
policy value was specified.MCO_S_DEAD_CONNECTION).The example code demonstrating how to use this function is too long to include here. Please refer to the SDK sample "samples/native/core/19-recovery/sniffer".