{"record":{"id":"0cc1b605610db7ba","repo":"elastic/elasticsearch","slug":"not-all-bytes-of-message-ready-1-sent-to-systemd","errorCode":null,"errorMessage":"Not all bytes of message (READY=1) sent to systemd socket (sent {})","messagePattern":"Not all bytes of message \\(READY=1\\) sent to systemd socket \\(sent (.+?)\\)","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 when libc.send() returns a byte count less than the message length. For Unix datagram sockets this is unusual (datagrams are atomic), but it can occur if the socket was closed mid-send or if the kernel truncated the datagram. The error includes the number of bytes actually sent.","triggerScenarios":"Calling systemd.notify_ready() where send() returns a partial write. This is rare for SOCK_DGRAM but can happen if the socket fd is invalidated between connect and send, or if the message exceeds the maximum datagram size.","commonSituations":"Concurrent close of the socket fd by another thread. Extremely long notification strings exceeding SO_SNDBUF. Kernel or driver bug truncating datagrams. Unlikely but possible under heavy signal load interrupting the syscall.","solutions":["Check that no other code closes file descriptors that might alias the systemd socket fd.","Keep notification messages short (READY=1 is only 7 bytes; this error is very rare for it).","Wrap notify_ready() in try-catch as partial sends are unrecoverable.","If using a custom notification state string, ensure it does not exceed the socket buffer."],"exampleFix":"// before\nsystemd.notify_ready();\n\n// after\ntry {\n    systemd.notify_ready();\n} catch (RuntimeException e) {\n    logger.warn(\"Partial sd_notify send; systemd may not have received READY=1\", e);\n}","handlingStrategy":"try-catch","validationCode":"// Partial sends on SOCK_DGRAM are not predictable; use try-catch.\n// Verify the service unit Type=notify and keep messages short.","typeGuard":null,"tryCatchPattern":"try {\n    systemd.notify_ready();\n} catch (RuntimeException e) {\n    logger.warn(\"systemd READY=1 partial send; continuing startup\", e);\n}","preventionTips":["Do not share or close file descriptors that may alias the internal systemd socket fd.","Keep notification state strings minimal.","Treat sd_notify as best-effort; never let it block startup."],"tags":["systemd","linux","native","socket","partial-send"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}