Repository navigation
Open
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeport-to-2.25.xport-to-2.26.xpriority: P1Events lost or overwritten, hang, crash or leak; fix first
Milestone
Description
#4336 (fixing #4333) caps the payload of DatagramOutputStream at 65,507 bytes, the IPv4 UDP limit. When a datagram would exceed that limit, the whole datagram is dropped:
copy()appends nothing more as soon as the nextwritecall does not fit completely, and only counts the remaining length;flush()then discards everything that was buffered and logs aWARN.
UDP is mostly used to send RFC 5424 syslog messages, and RFC 5424 receivers must tolerate truncated messages. A layout that writes an event in several write calls loses all of them, even when most of the message fits.
Proposed fix
copy(): append as many bytes as still fit, i.e.min(length, MAX_DATAGRAM_LENGTH - data.size()), even if that cuts awritecall in the middle, and only count the bytes that do not fit.flush(): always send the buffered bytes; if anything was cut, log aWARNsuch asUDP datagram truncated from N to 65507 bytes.- Footer: it is appended last, so it is the first part to be cut.
Rfc5424Layoutdoes not use one, so no space is reserved for it.
Tests
- Replace the expectation that an oversized datagram is dropped with a check that exactly 65,507 bytes are sent and that they start with the beginning of the event.
- Add a case where the event is written in several
writecalls and the cut falls inside one of them.
Notes
- The cut can fall inside a multi-byte UTF-8 character. Receivers that truncate messages themselves face the same situation.
- Layouts producing JSON (e.g. GELF) will send a truncated document instead of nothing. Before Grow DatagramOutputStream buffer and drop oversized UDP payloads #4336 such an event was lost too, because
DatagramSocket.sendfailed withMessage too long.
Since #4336 is part of 2.26.2 (#4385), this should be fixed before that release.
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeport-to-2.25.xport-to-2.26.xpriority: P1Events lost or overwritten, hang, crash or leak; fix first
Activity
Revert "Grow DatagramOutputStream buffer and drop oversized UDP paylo…