Inspects the state of all connections to an existing database and performs recovery if dead connections are detected.
MCO_RET mco_db_sniffer_ex(
mco_db_h db,
mco_sniffer_callback_ex_t callback,
void *user_context,
mco_sniffer_policy policy
);
db
callback
user_context
NULL.policy
This function iterates over database connections or transactions (depending on
policy) and invokes the providedcallbackfor each one. The callback should determine whether the connection is dead (e.g., using timeouts, watchdogs, or OS-specific mechanisms).If the callback returns
MCO_S_DEAD_CONNECTION, the sniffer initiates database recovery for that connection according to the specified policy. If the callback returns any other error code,mco_db_sniffer_exstops immediately and returns that code.The
policyparameter controls the inspection scope: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;The callback must not modify its input parameters. It should return:
MCO_S_OK— connection is alive,MCO_S_DEAD_CONNECTION— connection is dead (triggers recovery),- any other error code — aborts the sniffer and propagates the error.
MCO_S_OK
MCO_E_ILLEGAL_PARAM
policy value was specified.MCO_S_DEAD_CONNECTION).