diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-29 14:42:45 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-29 14:42:45 +0300 |
| commit | 16702aee7c83ab772639e775e3b5852ad407a5ca (patch) | |
| tree | c38e43f2e39e558a3b0c703f406f73d7d8a98e46 /internal | |
| parent | 3ac8abd0e15e654f1eec0cc2c1fb7c8dd11dd5cb (diff) | |
fix: respect MaxLineLength in turbo boost mode for integration tests
The optimized line reader now properly handles the MaxLineLength configuration
which is set to 1024 bytes in integration test mode. This ensures that long
lines are split consistently between regular and turbo boost modes.
- Cache MaxLineLength value to avoid repeated config lookups
- Split lines that exceed MaxLineLength even when they contain newlines
- Handle EOF cases properly when lines exceed the limit
- Reset warning flag when normal lines are encountered
All dcat and dgrep integration tests now pass with DTAIL_TURBOBOOST_ENABLE=yes
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/io/fs/readfile_processor_optimized.go | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/internal/io/fs/readfile_processor_optimized.go b/internal/io/fs/readfile_processor_optimized.go index b3fdcf5..03bece8 100644 --- a/internal/io/fs/readfile_processor_optimized.go +++ b/internal/io/fs/readfile_processor_optimized.go @@ -97,19 +97,41 @@ func (f *readFile) scanLinesWithMaxLength(data []byte, atEOF bool) (advance int, return 0, nil, nil } + maxLineLen := config.Server.MaxLineLength + // Look for a newline if i := bytes.IndexByte(data, '\n'); i >= 0 { - // We have a full line + // Check if the line before the newline exceeds max length + if i > maxLineLen { + // Line is too long, split it at maxLineLen + if !f.warnedAboutLongLine { + f.serverMessages <- dlog.Common.Warn(f.filePath, + "Long log line, splitting into multiple lines") + "\n" + f.warnedAboutLongLine = true + } + return maxLineLen, data[0:maxLineLen], nil + } + // We have a full line within the limit + f.warnedAboutLongLine = false // Reset warning for next long line sequence return i + 1, data[0:i], nil } // If we're at EOF, we have a final, non-terminated line if atEOF { + if len(data) > maxLineLen { + // Even at EOF, respect max line length + if !f.warnedAboutLongLine { + f.serverMessages <- dlog.Common.Warn(f.filePath, + "Long log line, splitting into multiple lines") + "\n" + f.warnedAboutLongLine = true + } + return maxLineLen, data[0:maxLineLen], nil + } return len(data), data, nil } // If the line is too long, split it - if len(data) >= config.Server.MaxLineLength { + if len(data) >= maxLineLen { // Warn about long line (only once) if !f.warnedAboutLongLine { f.serverMessages <- dlog.Common.Warn(f.filePath, @@ -118,7 +140,7 @@ func (f *readFile) scanLinesWithMaxLength(data []byte, atEOF bool) (advance int, } // Return a chunk up to MaxLineLength - return config.Server.MaxLineLength, data[0:config.Server.MaxLineLength], nil + return maxLineLen, data[0:maxLineLen], nil } // Request more data |
