You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2008/05/16 22:35:55 UTC
[jira] Created: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
TThreadPoolServer won't shut down gracefully
--------------------------------------------
Key: THRIFT-11
URL: https://issues.apache.org/jira/browse/THRIFT-11
Project: Thrift
Issue Type: Bug
Components: Library (Java)
Reporter: Bryan Duxbury
The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "Johan Stuyts (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597630#action_12597630 ]
Johan Stuyts commented on THRIFT-11:
------------------------------------
IMHO your first patch was fine. {{AtomicBoolean}} is nothing more than an object wrapper around a volatile {{int}}. So basically it is the same as using a volatile {{boolean}}.
Using {{AtomicBoolean}} also creates a dependency on Java 1.6 which might not be desirable.
I do not know why {{AtomicBoolean}} was introduced in 1.6, but by looking at the code I think it allows you to atomically get and set, and compare and set a boolean (without using synchronization?). Both these functions are not used by your second patch.
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Attachments: graceful_shutdown-v2.patch, graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury updated THRIFT-11:
--------------------------------
Attachment: graceful_shutdown.patch
Here's a patch that should fix this problem.
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Attachments: graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12597632#action_12597632 ]
Bryan Duxbury commented on THRIFT-11:
-------------------------------------
I don't object to using the first patch, then.
Otherwise, does this look like something that should be committed to TRUNK?
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Attachments: graceful_shutdown-v2.patch, graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "David Reiss (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Reiss resolved THRIFT-11.
-------------------------------
Resolution: Fixed
Assignee: Bryan Duxbury
Committed patch v3.
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Assignee: Bryan Duxbury
> Attachments: graceful_shutdown-v2.patch, graceful_shutdown-v3.patch, graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bryan Duxbury updated THRIFT-11:
--------------------------------
Attachment: graceful_shutdown-v2.patch
Here's a slightly better version. The stopped_ variable is changed from a boolean to an AtomicBoolean.
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Attachments: graceful_shutdown-v2.patch, graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12600820#action_12600820 ]
Bryan Duxbury commented on THRIFT-11:
-------------------------------------
Makes sense.
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Attachments: graceful_shutdown-v2.patch, graceful_shutdown-v3.patch, graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-11) TThreadPoolServer won't shut down
gracefully
Posted by "David Reiss (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-11?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
David Reiss updated THRIFT-11:
------------------------------
Attachment: graceful_shutdown-v3.patch
This is definitely something that belongs in the trunk. What do you think of this version that also keeps (approximate) track of the elapsed time so that we don't block forever if we keep getting interrupted.
> TThreadPoolServer won't shut down gracefully
> --------------------------------------------
>
> Key: THRIFT-11
> URL: https://issues.apache.org/jira/browse/THRIFT-11
> Project: Thrift
> Issue Type: Bug
> Components: Library (Java)
> Reporter: Bryan Duxbury
> Attachments: graceful_shutdown-v2.patch, graceful_shutdown-v3.patch, graceful_shutdown.patch
>
>
> The way I'm reading TThreadPoolServer.java, it looks like the stop() method's intent is to let the server shut down gracefully. However, because of the way that the WorkerProcess work loop is structured, if the clients are consistently making requests, the requests will keep getting served until the ThreadPoolExecutor's shutdown timeout expires, at which point the client threads will be forcibly aborted. This is because the innermost while loop around processor.process does not check the server's shutdown_ flag.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.