SAM_INITIALIZE(3)
π SAM_INITIALIZE(3) π
okay bestie, welcome to the Corosync Cluster Engine Programmer's Manual β¨ this is the page for sam_initialize, and it's literally the origin story of your process's health checking journey. buckle up π
πΈ NAME πΈ
sam_initialize β Initialize health checking π
β¨ SYNOPSIS β¨
#include <corosync/sam.h>
cs_error_t sam_initialize (int time_interval, sam_recovery_policy_t
recovery_policy);
π¦ DESCRIPTION π¦
so the sam_initialize function is the one that initializes health checking of a process. it's giving "first day of school" energy β this is where it all begins π«Ά
okay important, no cap: an application can have only one instance of SAM. one. singular. this function must be called before any other of the SAM functions, like, before anything else. and it's recommended to initialize before the process begins any process initialization. yes we said initialize before initializing. iykyk π
the time_interval parameter is a timeout in milliseconds before taking recovery action after having not received a healthcheck. so it's the "how long do we wait before we panic" number π
if time_interval is zero, there is no time limit and no healthcheck must be sent by the process. in this operational mode, a process failure will continue to execute the recovery policy. lowkey unhinged but okay π
the recovery_policy is defined as type:
typedef enum {
SAM_RECOVERY_POLICY_QUIT = 1,
SAM_RECOVERY_POLICY_RESTART = 2,
SAM_RECOVERY_POLICY_QUORUM = 0x08,
SAM_RECOVERY_POLICY_QUORUM_QUIT = SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_QUIT,
SAM_RECOVERY_POLICY_QUORUM_RESTART = SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_RESTART,
SAM_RECOVERY_POLICY_CMAP = 0x10,
SAM_RECOVERY_POLICY_CONFDB = 0x10,
} sam_recovery_policy_t;
where, and here's the tea β
SAM_RECOVERY_POLICY_QUITβ on failure, the process will terminate. bye bestie πSAM_RECOVERY_POLICY_RESTARTβ on failure, the process will restart. main character resurrection arc π«SAM_RECOVERY_POLICY_QUORUMβ is not policy. it's used only as a flag meaning quorum integration. just a flag, don't treat it like a whole vibe.SAM_RECOVERY_POLICY_QUORUM_QUITβ same asSAM_RECOVERY_POLICY_QUITbutsam_start(3) will block until corosync becomes quorate and the process will be terminated if quorum is lost.SAM_RECOVERY_POLICY_QUORUM_RESTARTβ same asSAM_RECOVERY_POLICY_RESTARTbutsam_start(3) will block until corosync becomes quorate and the process will be restarted if quorum is lost.SAM_RECOVERY_POLICY_CMAPβ is not policy either. used only as a flag meaning cmap integration. it can be used with all previous policies, so mix and match bestie π¨ for backward compatibility,SAM_RECOVERY_POLICY_CONFDBwith the same meaning asSAM_RECOVERY_POLICY_CMAPis also provided.
to perform event driven healthchecking, sam_register(3) and sam_start(3) functions must called. event driven healthchecking causes the duplicate standby process running the SAM server to periodically request healthchecks from the active process. obsessed with this whole arrangement fr fr π
β RETURN VALUE β
this call returns the CS_OK value if successful, otherwise an error is returned. simple as that π
π ERRORS π
CS_ERR_BAD_HANDLEβ can happened in case of double initialization. like, you already initialized, bestie, calm down πCS_ERR_INVALID_PARAMβrecovery_policyhas an invalid value. that flag is not flagging, hun π©
π SEE ALSO π
sam_register(3)sam_start(3)sam_hc_callback_register(3)CS_ERR_TRY_AGAINβ Resource temporarily unavailableCS_ERR_INVALID_PARAMβ Invalid argumentCS_ERR_ACCESSβ Permission deniedCS_ERR_LIBRARYβ The connection failedCS_ERR_INTERRUPTβ System call interrupted by a signalCS_ERR_NOT_SUPPORTEDβ The requested protocol/functionality not supportedCS_ERR_MESSAGE_ERRORβ Incorrect auth message receivedCS_ERR_NO_MEMORYβ Not enough memory to complete the requested task
and that's the whole page, bestie π«Ά this was the corosync Man Page, dated 21/05/2010, SAM_INITIALIZE(3) β go forth and health-check responsibly β¨ππΈ
π¦ where this page comes from
- debian bookworm: libsam-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libsam-dev 3.1.9-2+deb13u1 Β· BSD-3-Clause
- epel 9: corosynclib-devel 3.1.10-0.2.el9.1 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- nixos 26.05: corosync 3.1.9
- nixpkgs unstable: corosync 3.1.9
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- ubuntu jammy: libsam-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libsam-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libsam-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libsam-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libsam-dev 3.1.9-2ubuntu1
- ubuntu questing: libsam-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libsam-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libsam-dev 3.1.10-3ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2009-2010 Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms