зеркало из https://github.com/microsoft/docker.git
Merge pull request #17537 from mountkin/fix-logger-race
fix a race in json logger reader
This commit is contained in:
Коммит
ed6e3cf704
|
@ -357,6 +357,17 @@ func followLogs(f *os.File, logWatcher *logger.LogWatcher, notifyRotate chan int
|
|||
retries++
|
||||
continue
|
||||
}
|
||||
|
||||
// io.ErrUnexpectedEOF is returned from json.Decoder when there is
|
||||
// remaining data in the parser's buffer while an io.EOF occurs.
|
||||
// If the json logger writes a partial json log entry to the disk
|
||||
// while at the same time the decoder tries to decode it, the race codition happens.
|
||||
if err == io.ErrUnexpectedEOF && retries <= maxJSONDecodeRetry {
|
||||
reader := io.MultiReader(dec.Buffered(), f)
|
||||
dec = json.NewDecoder(reader)
|
||||
retries++
|
||||
continue
|
||||
}
|
||||
logWatcher.Err <- err
|
||||
return
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче