This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Let the PVF host kill the worker on timeout #6381
Merged
+25
−15
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,7 +233,11 @@ pub async fn cpu_time_monitor_loop( | |
timeout.as_millis(), | ||
); | ||
|
||
// Send back a TimedOut error on timeout. | ||
// Send back a `TimedOut` error. | ||
// | ||
// NOTE: This will cause the worker, whether preparation or execution, to be killed by | ||
// the host. We do not kill the process here because it would interfere with the proper | ||
// handling of this error. | ||
let encoded_result = match job_kind { | ||
JobKind::Prepare => { | ||
let result: Result<(), PrepareError> = Err(PrepareError::TimedOut); | ||
|
@@ -244,8 +248,8 @@ pub async fn cpu_time_monitor_loop( | |
result.encode() | ||
}, | ||
}; | ||
// If we error there is nothing else we can do here, and we are killing the process, | ||
// anyway. The receiving side will just have to time out. | ||
// If we error here there is nothing we can do apart from log it. The receiving side | ||
// will just have to time out. | ||
if let Err(err) = framed_send(&mut stream, encoded_result.as_slice()).await { | ||
gum::warn!( | ||
target: LOG_TARGET, | ||
|
@@ -255,8 +259,7 @@ pub async fn cpu_time_monitor_loop( | |
); | ||
} | ||
|
||
// Kill the process. | ||
std::process::exit(1); | ||
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. What will happen in case of the timeout is that you will go onto the next iteration of 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. Good catch! |
||
return | ||
} | ||
|
||
// Sleep for the remaining CPU time, plus a bit to account for overhead. Note that the sleep | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I added some comments about the error handling flow. Having too many comments is
not ideal, as they may not hold true in the future if the code changes. But it
is not obvious just from reading this code in isolation what the consequences of
these errors are, and I feel like something as significant as killing the worker
should be called out.
These comments would have helped me understand the error flow earlier, but if it
is too much, let me know.