Repository navigation
fix(logging): keep short-write progress for protobuf TCP access logs - #1835
Merged
Merged
Conversation
The protobuf `Tcp` arm of `InnerLogger::log_access` called `TcpStream::write` once and mapped any byte count to success. A stream may accept only a prefix, so a short write truncated the record and the decoder read the next record's bytes as its remainder. Send the record through `write_stream_record`, which uses `write_all` like the ASCII `Tcp` arm. Move the unchanged framing into `encode_protobuf_access_log` so a test can drive framing and writing through a short-writing sink and decode consecutive records. Fixes #1830 Signed-off-by: Florentin Dubois <[email protected]>
This was referenced Oct 3, 2026
Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1830
Cause
CAUSE:
command/src/logging/logs.rsprotobuf arm ofInnerLogger::log_access(LoggerBackend::Tcp(socket) => socket.write(bytes)atbd19a78e) -> the count of a singleTcpStream::writeis discarded by.map(|_| ()), so a prefix-only write is reported as success and nothing retries the remainder -> SYMPTOM: thetcp://access-log stream carries a truncated record, and the decoder reads the next record's length-delimited bytes as the first one's remainder (decode_length_delimited->BufferUnderflow).Change
Tcparm now sends the record throughwrite_stream_record, which useswrite_all, as the ASCIITcparm inlog_argumentsalready did. An I/O error still returns tolog_access, which reports it and revives the backend.encode_protobuf_access_log, so a test can drive framing and writing through a substitutable sink.LoggerBackend::Tcpholds a concreteTcpStream, so the stream write is a small generic helper.doc/observability.mddescribes the protobuf framing and whytcp://useswrite_all; CHANGELOG entry under Unreleased / Fixed.Regression test
short_writes_keep_consecutive_protobuf_records_framedframes two distinctProtobufAccessLogrecords, writes them through aShortWriteSinkthat accepts at most 7 bytes per call, then decodes both in order and checks each one's two zero bytes and that nothing trails.write_stream_recordset to the pre-fix arm semantics (stream.write(bytes).map(|_| ())). The helper does not exist onorigin/main, so this follows the module's documented "restore the pre-fix arm" convention instead of a literalorigin/mainrun:every record decodes from the stream, in order: DecodeError { description: BufferUnderflow, stack: [] }->test result: FAILED. 5 passed; 1 failedwrite_all:test result: ok. 6 passed; 0 faileda_stream_record_error_is_propagatedchecks that a sink error keeps its kind (BrokenPipe).Validation (on 1e7abca)
cargo +nightly fmt --check-> exit 0cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings-> exit 0RUSTDOCFLAGS="-D warnings" cargo +1.93.1 doc --no-deps --locked -p sozu-lib -p sozu-command-lib -p sozu-> exit 0cargo +1.93.1 test -p sozu-command-lib --locked --all-features->test result: ok. 237 passed; 0 failed(lib) plus doc/integration targets okpython3 .github/scripts/check_doc_citations.py --root . --base origin/main-> exit 0Not changed here
The protobuf
Filearm has the same single-writeshape:MultiLineWriter::writehands a record at least as large as its buffer straight toFile::write. The issue covers the TCP arm only, soFile(andStdout, whose result is ignored) are left for a follow-up.