{"action":"created","issue":{"url":"https://api.github.com/repos/sharneng/gm4java/issues/7","labels_url":"https://api.github.com/repos/sharneng/gm4java/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/sharneng/gm4java/issues/7/comments","events_url":"https://api.github.com/repos/sharneng/gm4java/issues/7/events","html_url":"https://github.com/sharneng/gm4java/issues/7","id":38222610,"number":7,"title":"Timeouts for Pooled Connections","user":{"login":"64BitChris","id":1381061,"avatar_url":"https://avatars.githubusercontent.com/u/1381061?v=3","gravatar_id":"","url":"https://api.github.com/users/64BitChris","html_url":"https://github.com/64BitChris","followers_url":"https://api.github.com/users/64BitChris/followers","following_url":"https://api.github.com/users/64BitChris/following{/other_user}","gists_url":"https://api.github.com/users/64BitChris/gists{/gist_id}","starred_url":"https://api.github.com/users/64BitChris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/64BitChris/subscriptions","organizations_url":"https://api.github.com/users/64BitChris/orgs","repos_url":"https://api.github.com/users/64BitChris/repos","events_url":"https://api.github.com/users/64BitChris/events{/privacy}","received_events_url":"https://api.github.com/users/64BitChris/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-07-19T00:50:55Z","updated_at":"2015-01-05T02:53:52Z","closed_at":null,"body":"I'm leveraging the PooledGMService class - my application has a timeout set at 10 seconds - sometimes GM operations take longer (up to several minutes).  \r\n\r\nWhen this happens my Java process times out as expected and returns the connection to the pool.  However, this does not cause the process to be destroyed and in fact the gm process can continue processing until it's complete.  Calls to ensureHealthy() on a connection in this state block until the previous command has finished.\r\n\r\nIf I detect a timeout on a non pooled connection, the close() operation will destroy the process which will stop it from taking up processing resources as soon as my application has decided it will no longer wait for the result.\r\n\r\nBasically I'd like the ability to flag a pooled connection as unhealthy.  This way it won't be reused and if I have testOnReturn enabled the process will be destroyed when it's returned to the pool.\r\n\r\nAre there any thoughts on how to approach this?  I'm willing to do make the changes but wanted to see if there were any ideas on how to best implement it.\r\n"},"comment":{"url":"https://api.github.com/repos/sharneng/gm4java/issues/comments/68662853","html_url":"https://github.com/sharneng/gm4java/issues/7#issuecomment-68662853","issue_url":"https://api.github.com/repos/sharneng/gm4java/issues/7","id":68662853,"user":{"login":"kennethxu","id":1189766,"avatar_url":"https://avatars.githubusercontent.com/u/1189766?v=3","gravatar_id":"","url":"https://api.github.com/users/kennethxu","html_url":"https://github.com/kennethxu","followers_url":"https://api.github.com/users/kennethxu/followers","following_url":"https://api.github.com/users/kennethxu/following{/other_user}","gists_url":"https://api.github.com/users/kennethxu/gists{/gist_id}","starred_url":"https://api.github.com/users/kennethxu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennethxu/subscriptions","organizations_url":"https://api.github.com/users/kennethxu/orgs","repos_url":"https://api.github.com/users/kennethxu/repos","events_url":"https://api.github.com/users/kennethxu/events{/privacy}","received_events_url":"https://api.github.com/users/kennethxu/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T02:53:52Z","updated_at":"2015-01-05T02:53:52Z","body":"Terribly sorry to respond late. Wondering how did you implemented the timeout here. If you used a 2nd thread with Future.get(timeout) or anything similar to this. The other thread is actually still running. In this case, what we can do is to add a little logic in the PooledGMService.ConnectionWrapper. \r\n1) introduce a volatile boolean field: isExecuting\r\n2) set isExecuting to true in the beginning of execute and false in finally.\r\n3) in the close, if isExecuting is true, close the real connection before return it back to pool, this will effectively kill the GM process.\r\n4) for the pool to dispose this connection, we'll also need to change ensureHealthy method to throw exception if the connection is also close. (this should probably have been done anyway)\r\n\r\nHTH"}}