Repository navigation
Conversation
7426914 to
651523c
Compare
|
Fixed failed tests. |
|
@unclejack , can you take a look ? |
|
@chenchun I'll have to test to confirm it helps. |
There was a problem hiding this comment.
@chenchun we might as well not do bufio.NewReader(src), and simply call src.Read(p) with a specified buffer size for p. WDYT?
There was a problem hiding this comment.
Seems we have to handle '\n' or '\r\n' and do things like cuting of the line in buffer p ourselves manually if using src.Read(p). What is your concerns of using bufio.NewReader(src)?
a147870 to
6610089
Compare
|
Failed tests are not related. |
There was a problem hiding this comment.
@chenchun comment here is out of date, should be ReadLine.
There was a problem hiding this comment.
Sorry for missing that. Removed the comment here and || len(line) > 0 since "ReadLine either returns a non-nil line or it returns an error, never both."
…y huge lines Signed-off-by: Chun Chen <[email protected]>
|
@tiborvass , thanks for reviewing, rebased. |
|
@chenchun sorry again but I thought again about this PR and I'm not 100% sure this is the right solution. Let me explain. The |
There was a problem hiding this comment.
Should we not check isPrefix and do something about it? Silently corrupting the log message is probably not the right solution.
|
I'm worried this will cause log messages to get silently corrupted when they are over 4096 bytes in size. This is problematic in certain cases where log messages actually have structure, which is becoming more and more common. If it helps, Is there any reason container logs aren't treated as an opaque stream or am I missing something? |
|
@stevvooe, #13564 changed I think this needs to be fixed in case of some evil behavior which can crash down the daemon by printing logs without a I propose to increase the size from 4096 bytes to some big enough size like 1MB and add a option to docker daemon for users to config the size or add an isPrefix field in |
This will make things extremely bad when it comes to memory, so I'm NOT OK with such a change. |
But currently |
|
@chenchun enix's issue in #9139 is a degenerate case. The problem has been solved for the general case and I really think we need something smarter than just giving up and allocating 1 MB of memory for this. What happens when I have 100 containers? Do I need n megabytes of RAM for this, where n is the number of containers? Allocating chunks of 1 MB for this is unreasonable. What happens when someone says "I'm seeing this problem with 1.02 MB of data, increase the size of the chunk to 2 MB"? Do they have to keep bumping that config option to handle this? What happens when someone attempts to run containers which require less than 1 MB of RAM, but the daemon eats up 1 MB per container for this? I've done some tests in the past to fix other issues in Docker which required buffers. I can tell you raising buffers to such huge sizes isn't a good solution. |
|
Given the resistance to this particular fix for the issue, maybe we can work on some other ideas to resolve this issue? |
|
@cpuguy83 I really think it should be closed because fixing this issue is going to require a more complex solution which doesn't involve allocating a lot of memory and doesn't require daemon options. |
|
@chenchun wdyt? Maybe we can discuss on IRC a good solution for this? |
|
@chenchun Looks like #13564 might not have been the correct fix. It probably should have just restarted on the copy on the "too long" error, rather than allocating all of memory. When it comes right down to it, this data should not be line buffered. Even if it has to be, there should be a way to partition it across log records. While running out of memory is not ideal, silently corrupting logs and configurable line buffering sizes are not ideal solutions, if even pathological (buffer creep, per @unclejack). For example, if I pipe /dev/urandom to my terminal, while saving all history, does my terminal corrupt the output? No, it tries to allocate what the application asked of it and crashes if it can't do it. The crash protects our data. The real issue here is isolation. Can we find a way to catch the out of memory error and recover? Perhaps, a recover for the out of memory panic would be sufficient. On recovery, we could kill the ill-behaved container, saving the daemon. @cpuguy83 Thoughts? |
|
Thanks for the patient and detailed review. closed the PR. |
Signed-off-by: Chun Chen [email protected]
If a single line is huge, see #9139 (comment), it costs so much to buffer the whole line in the memory. We could use
ReadLineinstead ofReadBytesto fix such case. The default buf size is 4096 bytes inbufiowhich I think is enough for most cases. If you think it's necessary to add an option for users to config the size, I can update the patch.