Environment
- Branch:
main
- Commit:
118bb865d037c0c11113786db98999284945d1c4
- OS: macOS arm64
Description
The TN and TAE logtail configuration validators accept any positive rpc-max-message-size, but NewLogtailServer requires the value to be larger than the encoded LogtailResponseSegment header. A small positive value therefore passes configuration validation and later panics while a TN replica creates its TAE/logtail storage.
For example, rpc-max-message-size = 1 passes both validation paths and deterministically reaches:
if s.maxChunkSize <= 0 {
panic("rpc max message size isn't enough")
}
White-box reproduction
func TestValidatedSmallRPCMessageSizePanics(t *testing.T) {
cfg := &options.LogtailServerCfg{RpcMaxMessageSize: 1}
cfg.Validate()
require.Equal(t, int64(1), cfg.RpcMaxMessageSize)
require.PanicsWithValue(t, "rpc max message size isn't enough", func() {
_, _ = NewLogtailServer("127.0.0.1:0", cfg, nil, mockRuntime(), nil)
})
}
Run:
go test ./pkg/vm/engine/tae/logtail/service \
-run '^TestCodexValidatedSmallRPCMessageSizePanics$' -count=3 -v
Result: reproduced 3/3 on the latest main.
Production path
TN Config.Validate
-> accepts every RpcMaxMessageSize > 0
TN create replica
-> taestorage.NewTAEStorage
-> service.NewLogtailServer
-> NewLogtailServerSegmentPool(configured size)
-> LeastEffectiveCapacity() <= 0
-> panic("rpc max message size isn't enough")
The relevant validators only replace values <= 0; they do not enforce the minimum protocol-header size.
Expected behavior
Invalid positive values should be rejected by configuration validation with a descriptive error, or NewLogtailServer should return an error. User configuration must not cause a TN process panic during replica creation.
Actual behavior
The configuration is accepted and the TN panics later when the logtail server is constructed.
Suggested direction
- Define and validate a minimum
RpcMaxMessageSize that can hold the maximum segment header plus at least one payload byte.
- Replace the constructor panic with a returned error as defense in depth.
Environment
main118bb865d037c0c11113786db98999284945d1c4Description
The TN and TAE logtail configuration validators accept any positive
rpc-max-message-size, butNewLogtailServerrequires the value to be larger than the encodedLogtailResponseSegmentheader. A small positive value therefore passes configuration validation and later panics while a TN replica creates its TAE/logtail storage.For example,
rpc-max-message-size = 1passes both validation paths and deterministically reaches:White-box reproduction
Run:
Result: reproduced 3/3 on the latest
main.Production path
The relevant validators only replace values
<= 0; they do not enforce the minimum protocol-header size.Expected behavior
Invalid positive values should be rejected by configuration validation with a descriptive error, or
NewLogtailServershould return an error. User configuration must not cause a TN process panic during replica creation.Actual behavior
The configuration is accepted and the TN panics later when the logtail server is constructed.
Suggested direction
RpcMaxMessageSizethat can hold the maximum segment header plus at least one payload byte.