-
Notifications
You must be signed in to change notification settings - Fork 717
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
appender: fix WorkerGuard not waiting for writer destruction #1713
Changes from 1 commit
a6ae3e3
ac42497
fb1f941
1e1741f
13fec12
45da512
f004b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,16 +74,13 @@ impl<T: Write + Send + Sync + 'static> Worker<T> { | |
Ok(WorkerState::Continue) | Ok(WorkerState::Empty) => {} | ||
Ok(WorkerState::Shutdown) | Ok(WorkerState::Disconnected) => { | ||
let _ = self.shutdown.recv(); | ||
break; | ||
return; | ||
} | ||
Err(_) => { | ||
// TODO: Expose a metric for IO Errors, or print to stderr | ||
} | ||
} | ||
} | ||
if let Err(e) = self.writer.flush() { | ||
eprintln!("Failed to flush. Error: {}", e); | ||
} | ||
Comment on lines
-84
to
-86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm assuming the flush here was removed because we will already always flush on shutdown in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that's why I felt safe to remove it but the actual reason was that it could block (or introduce undefined delay)(#1125 (comment)) when joining the worker. To be honest, I would've just joined the thread, but the IO argument does make sense and I just followed with it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realised that within this logic it might be a good idea to drop writer as well: 45da512. There could be some IO there in destructor. |
||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we get the
Disconnected
error, this means that theReceiver
side of the channel has already been dropped...but that doesn't necessarily mean that the worker thread has terminated yet. should we still calljoin
on theJoinHandle
in this case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, this can be racy also
If
Disconnected
can occur only during worker thread (which ownsReceiver
) destruction, I think it is safe to usejoin
here.Went ahead and merged
Disconnected
withOk
case.