elastic/elasticsearch · warning · RuntimeException

Not all bytes of message (READY=1) sent to systemd socket

Error message

Not all bytes of message (READY=1) sent to systemd socket (sent {})

What it means

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.

Solutions

  1. Check that no other code closes file descriptors that might alias the systemd socket fd.
  2. Keep notification messages short (READY=1 is only 7 bytes; this error is very rare for it).
  3. Wrap notify_ready() in try-catch as partial sends are unrecoverable.
  4. If using a custom notification state string, ensure it does not exceed the socket buffer.

Example fix

// before
systemd.notify_ready();

// after
try {
    systemd.notify_ready();
} catch (RuntimeException e) {
    logger.warn("Partial sd_notify send; systemd may not have received READY=1", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Partial sends on SOCK_DGRAM are not predictable; use try-catch.
// Verify the service unit Type=notify and keep messages short.

Try / catch

try {
    systemd.notify_ready();
} catch (RuntimeException e) {
    logger.warn("systemd READY=1 partial send; continuing startup", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/0cc1b605610db7ba. Report an issue: GitHub.

Appendix: source

Thrown at libs/native/src/main/java/org/elasticsearch/nativeaccess/Systemd.java:114

                    if (error != null) {
                        error.addSuppressed(e);
                        throw error;
                    } else {
                        throw e;
                    }
                }
            } else if (error != null) {
                throw error;
            }
        }
    }

    private void throwOrLog(String message, boolean warnOnError) {
        if (warnOnError) {
            logger.warn(message);
        } else {
            logger.error(message);
            throw new RuntimeException(message);
        }
    }
}

View on GitHub (pinned to db6a809a66)