Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing race issues in log rotator #1047

Merged
merged 3 commits into from
Apr 7, 2016
Merged

Fixing race issues in log rotator #1047

merged 3 commits into from
Apr 7, 2016

Conversation

diptanu
Copy link
Contributor

@diptanu diptanu commented Apr 7, 2016

Fixed #1042

@@ -88,12 +91,10 @@ func (f *FileRotator) Write(p []byte) (n int, err error) {
if remainingSize < int64(len(p[n:])) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should scan backwards through the buffer for a \n and write/flush everything before that. Whatever comes after that last \n should be moved to the beginning of the buffer and written out on the next write (as long as the line length is less than the buffer length, in which case you need to truncate). This only needs to happen on file rotation, not on write. I'll open an issue re: this in a sec.

@sean-
Copy link
Contributor

sean- commented Apr 7, 2016

Opening an issue for the remaining item, but LGTM otherwise.

@diptanu diptanu merged commit dd70628 into master Apr 7, 2016
@diptanu diptanu deleted the b-log-rotator branch April 7, 2016 02:26
@camerondavison
Copy link
Contributor

Just curious. Was the race in this just between the flushPeriodically and the Write? Y'all are assuming that Write is only called in sequence because it is reading the channel from syslog correct?

@dadgar
Copy link
Contributor

dadgar commented Jun 8, 2016

@a86c6f7964 correct!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants