Skip to content

Conversation

@hermanschaaf
Copy link
Member

This fixes an issue where the CLI would hang indefinitely when it encountered a log line from a plugin that was longer than the buffer size allowed for by bufio.Scanner. The fix uses a wrapper around bufio.NewReader to skip lines that are too long to be parsed, printing an error in the log with the first 1000 characters to help with identification.

line, err := lr.NextLine()
if errors.Is(err, io.EOF) {
break
} else if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we somehow distinguish between line-to-long to some other errors where we actually want to exit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, should be handled better now 👍

@yevgenypats
Copy link
Contributor

yevgenypats commented Oct 7, 2022

Is it possible to do some benchmarks vs the regular scanner just to see that we are not eating cpu/memory in comparison to the built-in scanner (given it can be quite intensive)?

@hermanschaaf
Copy link
Member Author

@yevgenypats I added some benchmarks:

Benchmark_BufferedScanner-8   	261038530	         4.488 ns/op	       0 B/op	       0 allocs/op
Benchmark_LogReader-8         	79254348	        14.98 ns/op	       0 B/op	       0 allocs/op

A tiny bit slower than BufferedScanner in this test (but we're talking nanoseconds here) and no additional allocs.

@kodiakhq kodiakhq bot merged commit f8ca238 into main Oct 9, 2022
@kodiakhq kodiakhq bot deleted the fix-hang-for-long-log-lines branch October 9, 2022 10:59
shimonp21 pushed a commit that referenced this pull request Oct 10, 2022
🤖 I have created a release *beep* *boop*
---


##
[0.13.0](v0.12.10...v0.13.0)
(2022-10-10)


### ⚠ BREAKING CHANGES

* Support table_concurrency and resource_concurrency (#268)

### Features

* Support table_concurrency and resource_concurrency
([#268](#268))
([7717d6f](7717d6f))


### Bug Fixes

* Add custom log reader implementation to fix hang on long log lines
([#263](#263))
([f8ca238](f8ca238))
* DeleteStale feature
([#269](#269))
([837c5f3](837c5f3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants