[ 
https://issues.apache.org/jira/browse/MAPREDUCE-5330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13699755#comment-13699755
 ] 

Chris Nauroth commented on MAPREDUCE-5330:
------------------------------------------

I came across similar issues while working on the YARN nodemanager changes for 
Windows.  Bikas, I agree that this logic doesn't exactly match the meaning of 
SIGTERM.  To match SIGTERM, we really need a way for one process to signal 
another process with some "graceful shutdown" message, and a way for the other 
process to trigger custom code when it receives that message.  Unfortunately, 
I'm not aware of anything in the Windows API that provides an exact match.  
Therefore, the logic in this patch seems to be the closest approximation that's 
feasible right now.

To elaborate on this, {{TerminateProcess}} immediately kills the target 
process, and there is no way for that process to trap the call and run custom 
clean-up code.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686714(v=vs.85).aspx

This is much different from Unix signals, which allow the target process to 
install signal handlers to respond gracefully to things like SIGTERM.

There also seems to be some support for programmatically sending CTL-C to a 
process and installing a custom handler to respond to it.  This would be 
{{SetConsoleCtrlHandler}} and {{GenerateConsoleCtrlEvent}}.  I've heard 
anecdotally that this can be used to create a rough approximation of Unix 
signals, but I haven't tried it myself.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms686016(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683155(v=vs.85).aspx

Aside from that, the only other option seems to be for Windows applications to 
roll their own custom IPC protocol (i.e. one process sends another a custom 
graceful shutdown message over a named pipe).

It might be worth pursuing one of these solutions in the long term for absolute 
correctness, but these approaches will require a lot more coding and testing.

Xi, please let me know if I've missed anything regarding signaling capabilities 
in the Windows API.

                
> JVM manager should not forcefully kill the process on Signal.TERM on Windows
> ----------------------------------------------------------------------------
>
>                 Key: MAPREDUCE-5330
>                 URL: https://issues.apache.org/jira/browse/MAPREDUCE-5330
>             Project: Hadoop Map/Reduce
>          Issue Type: Bug
>    Affects Versions: 1-win
>         Environment: Windows
>            Reporter: Xi Fang
>            Assignee: Xi Fang
>             Fix For: 1-win
>
>         Attachments: MAPREDUCE-5330.patch
>
>
> In MapReduce, we sometimes kill a task's JVM before it naturally shuts down 
> if we want to launch other tasks (look in 
> JvmManager$JvmManagerForType.reapJvm). This behavior means that if the map 
> task process is in the middle of doing some cleanup/finalization after the 
> task is done, it might be interrupted/killed without giving it a chance. 
> In the Microsoft's Hadoop Service, after a Map/Reduce task is done and during 
> closing file systems in a special shutdown hook, we're typically uploading 
> storage (ASV in our context) usage metrics to Microsoft Azure Tables. So if 
> this kill happens these metrics get lost. The impact is that for many MR jobs 
> we don't see accurate metrics reported most of the time.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to