{"record":{"id":"ac7a45688ffa805b","repo":"elastic/elasticsearch","slug":"failed-to-send-message-ready-1-to-systemd-socket","errorCode":null,"errorMessage":"Failed to send message (READY=1) to systemd socket: {}","messagePattern":"Failed to send message \\(READY=1\\) to systemd socket: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"libs/native/src/main/java/org/elasticsearch/nativeaccess/Systemd.java","lineNumber":114,"sourceCode":"                    if (error != null) {\n                        error.addSuppressed(e);\n                        throw error;\n                    } else {\n                        throw e;\n                    }\n                }\n            } else if (error != null) {\n                throw error;\n            }\n        }\n    }\n\n    private void throwOrLog(String message, boolean warnOnError) {\n        if (warnOnError) {\n            logger.warn(message);\n        } else {\n            logger.error(message);\n            throw new RuntimeException(message);\n        }\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":118,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/native/src/main/java/org/elasticsearch/nativeaccess/Systemd.java#L96-L118","documentation":"Thrown as a RuntimeException (notify_ready uses warnOnError=false) when libc.send() returns -1 after successfully connecting to the systemd NOTIFY_SOCKET. The error includes the strerror(errno) detail. This means the socket was opened and connected but the datagram could not be written, typically due to the socket buffer being full or the socket being closed by systemd.","triggerScenarios":"Calling systemd.notify_ready() when the NOTIFY_SOCKET datagram socket rejects the send() call. Common when systemd has closed the socket (service already stopped) or when the kernel message buffer for the socket is exhausted.","commonSituations":"Service stopped by systemd while the JVM was still initializing. Race between shutdown and READY=1 notification. Socket buffer exhaustion under heavy notification load. systemd version mismatch with the socket protocol.","solutions":["Check if the systemd service is still active: 'systemctl status <service>'.","If the service was stopped during startup, this is expected; ensure startup completes before shutdown can intervene.","Increase the socket buffer size if sending large notifications.","Wrap notify_ready() in try-catch so startup is not blocked by a failed sd_notify."],"exampleFix":"// before\nsystemd.notify_ready(); // throws RuntimeException on send failure\n\n// after\ntry {\n    systemd.notify_ready();\n} catch (RuntimeException e) {\n    logger.warn(\"sd_notify READY=1 failed, continuing startup\", e);\n}","handlingStrategy":"try-catch","validationCode":"// No pure pre-check for send() failure; guard with try-catch instead.\n// Ensure NOTIFY_SOCKET is set and the service is active before calling.","typeGuard":null,"tryCatchPattern":"try {\n    systemd.notify_ready();\n} catch (RuntimeException e) {\n    logger.warn(\"Failed to send READY=1 to systemd; process will continue without notification\", e);\n}","preventionTips":["Always wrap notify_ready() in try-catch since systemd availability is not guaranteed.","Ensure the service unit type is 'notify' so systemd expects the READY=1 signal.","Avoid calling notify_ready() during shutdown."],"tags":["systemd","linux","native","socket","send"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}