{"action":"created","issue":{"url":"https://api.github.com/repos/netty/netty/issues/4029","labels_url":"https://api.github.com/repos/netty/netty/issues/4029/labels{/name}","comments_url":"https://api.github.com/repos/netty/netty/issues/4029/comments","events_url":"https://api.github.com/repos/netty/netty/issues/4029/events","html_url":"https://github.com/netty/netty/pull/4029","id":97524885,"number":4029,"title":"FixedChannelPool acquired connection counter bug fixed","user":{"login":"ioanbsu","id":1421809,"avatar_url":"https://avatars.githubusercontent.com/u/1421809?v=3","gravatar_id":"","url":"https://api.github.com/users/ioanbsu","html_url":"https://github.com/ioanbsu","followers_url":"https://api.github.com/users/ioanbsu/followers","following_url":"https://api.github.com/users/ioanbsu/following{/other_user}","gists_url":"https://api.github.com/users/ioanbsu/gists{/gist_id}","starred_url":"https://api.github.com/users/ioanbsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioanbsu/subscriptions","organizations_url":"https://api.github.com/users/ioanbsu/orgs","repos_url":"https://api.github.com/users/ioanbsu/repos","events_url":"https://api.github.com/users/ioanbsu/events{/privacy}","received_events_url":"https://api.github.com/users/ioanbsu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-07-27T18:26:30Z","updated_at":"2015-08-01T05:48:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/4029","html_url":"https://github.com/netty/netty/pull/4029","diff_url":"https://github.com/netty/netty/pull/4029.diff","patch_url":"https://github.com/netty/netty/pull/4029.patch"},"body":"Motivation:\r\nThe FixedChannelPool once requested for a channel from the pool that is unhealthy will:\r\na) close this channel\r\nb) will try to acquire new channel if acquiredChannelCount < maxConnections.\r\nc) If acquiredChannelCount >= maxConnections it will add task for the queue.\r\nNow for the case with maxConnections==1 this will cause infinite grow of pendingAcquireQueue in FixedChannelPool because acquire is not decremented after step a) when SimpleChannelPool realised that channel is unhealthy.\r\nFor mode details see: #4023\r\n\r\nModifications:\r\nAdded promises to notifyHealthCheck function so that when unhealthy channel closing routine is done it will call unAcquireChannel function that is overridden in FixedChannelPool and inside thins function it will call decrementAndRunTaskQueue(). This way we will make sure that when unhealthy channel pulled from queue after it closed we decrement the acquiredChannelCount as well as we force to check if there any tasks in queue that may be executed.\r\n\r\nResult:\r\nThe bug where acquiredChannelsCount calculated incorrectly had been fixed. Now when pulled channel from queue turned out to be unhealthy the acquired channels count is decremented.\r\n\r\nP.S. this is copy of https://github.com/netty/netty/pull/4027. Sorry for the confusion. I thought I was suppose to squash all my commits, but that seemed to just close my original pull request."},"comment":{"url":"https://api.github.com/repos/netty/netty/issues/comments/126867851","html_url":"https://github.com/netty/netty/pull/4029#issuecomment-126867851","issue_url":"https://api.github.com/repos/netty/netty/issues/4029","id":126867851,"user":{"login":"fratboy","id":349984,"avatar_url":"https://avatars.githubusercontent.com/u/349984?v=3","gravatar_id":"","url":"https://api.github.com/users/fratboy","html_url":"https://github.com/fratboy","followers_url":"https://api.github.com/users/fratboy/followers","following_url":"https://api.github.com/users/fratboy/following{/other_user}","gists_url":"https://api.github.com/users/fratboy/gists{/gist_id}","starred_url":"https://api.github.com/users/fratboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fratboy/subscriptions","organizations_url":"https://api.github.com/users/fratboy/orgs","repos_url":"https://api.github.com/users/fratboy/repos","events_url":"https://api.github.com/users/fratboy/events{/privacy}","received_events_url":"https://api.github.com/users/fratboy/received_events","type":"User","site_admin":false},"created_at":"2015-08-01T05:48:10Z","updated_at":"2015-08-01T05:48:10Z","body":"@ioanbsu Doesn't it?\r\n```java\r\n//first try\r\n            Promise<Channel> p = executor.newPromise(); //p is promise1\r\n            p.addListener(new AcquireListener(promise)); //promise is original promise user passed\r\n            super.acquire(p); //p is promise1\r\n//second time\r\n            Promise<Channel> p = executor.newPromise(); //p is promise2\r\n            p.addListener(new AcquireListener(promise)); //promise is promise1\r\n            super.acquire(p); //p is promise2\r\n```\r\n[FixedChannelPool.java#L364](https://github.com/ioanbsu/netty/blob/fixed_channel_pool_counter_fix/transport/src/main/java/io/netty/channel/pool/FixedChannelPool.java#L364)"}}