{"action":"created","issue":{"url":"https://api.github.com/repos/ktorio/ktor/issues/574","repository_url":"https://api.github.com/repos/ktorio/ktor","labels_url":"https://api.github.com/repos/ktorio/ktor/issues/574/labels{/name}","comments_url":"https://api.github.com/repos/ktorio/ktor/issues/574/comments","events_url":"https://api.github.com/repos/ktorio/ktor/issues/574/events","html_url":"https://github.com/ktorio/ktor/issues/574","id":358979136,"node_id":"MDU6SXNzdWUzNTg5NzkxMzY=","number":574,"title":"ktor-netty draws error from io.netty.util.ResourceLeakDetector","user":{"login":"carlomorelli","id":6968441,"node_id":"MDQ6VXNlcjY5Njg0NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/6968441?v=4","gravatar_id":"","url":"https://api.github.com/users/carlomorelli","html_url":"https://github.com/carlomorelli","followers_url":"https://api.github.com/users/carlomorelli/followers","following_url":"https://api.github.com/users/carlomorelli/following{/other_user}","gists_url":"https://api.github.com/users/carlomorelli/gists{/gist_id}","starred_url":"https://api.github.com/users/carlomorelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlomorelli/subscriptions","organizations_url":"https://api.github.com/users/carlomorelli/orgs","repos_url":"https://api.github.com/users/carlomorelli/repos","events_url":"https://api.github.com/users/carlomorelli/events{/privacy}","received_events_url":"https://api.github.com/users/carlomorelli/received_events","type":"User","site_admin":false},"labels":[{"id":243686453,"node_id":"MDU6TGFiZWwyNDM2ODY0NTM=","url":"https://api.github.com/repos/ktorio/ktor/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":{"login":"cy6erGn0m","id":762598,"node_id":"MDQ6VXNlcjc2MjU5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/762598?v=4","gravatar_id":"","url":"https://api.github.com/users/cy6erGn0m","html_url":"https://github.com/cy6erGn0m","followers_url":"https://api.github.com/users/cy6erGn0m/followers","following_url":"https://api.github.com/users/cy6erGn0m/following{/other_user}","gists_url":"https://api.github.com/users/cy6erGn0m/gists{/gist_id}","starred_url":"https://api.github.com/users/cy6erGn0m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cy6erGn0m/subscriptions","organizations_url":"https://api.github.com/users/cy6erGn0m/orgs","repos_url":"https://api.github.com/users/cy6erGn0m/repos","events_url":"https://api.github.com/users/cy6erGn0m/events{/privacy}","received_events_url":"https://api.github.com/users/cy6erGn0m/received_events","type":"User","site_admin":false},"assignees":[{"login":"cy6erGn0m","id":762598,"node_id":"MDQ6VXNlcjc2MjU5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/762598?v=4","gravatar_id":"","url":"https://api.github.com/users/cy6erGn0m","html_url":"https://github.com/cy6erGn0m","followers_url":"https://api.github.com/users/cy6erGn0m/followers","following_url":"https://api.github.com/users/cy6erGn0m/following{/other_user}","gists_url":"https://api.github.com/users/cy6erGn0m/gists{/gist_id}","starred_url":"https://api.github.com/users/cy6erGn0m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cy6erGn0m/subscriptions","organizations_url":"https://api.github.com/users/cy6erGn0m/orgs","repos_url":"https://api.github.com/users/cy6erGn0m/repos","events_url":"https://api.github.com/users/cy6erGn0m/events{/privacy}","received_events_url":"https://api.github.com/users/cy6erGn0m/received_events","type":"User","site_admin":false}],"milestone":null,"comments":8,"created_at":"2018-09-11T10:14:16Z","updated_at":"2018-09-27T09:28:15Z","closed_at":null,"author_association":"NONE","body":"Using ktor-server-netty 0.9.4\r\nkotlin 1.2.51 on jdk8\r\n\r\nWe wrote a little http stub in kotlin using ktor that helps us measuring the performances of some of our microservices.\r\nThe stub answers to POST and GET and returns the same body all the time.\r\n\r\nI've been hitting it right now with 100 concurrent cyclical requests (Jmeter) and I'm getting this error in the logs:\r\n```\r\n2018-09-11 09:49:45.146 [nettyWorkerPool-3-1] ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html for more information.\r\nRecent access records: \r\nCreated at:\r\n\tio.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:331)\r\n\tio.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:185)\r\n\tio.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:176)\r\n\tio.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:137)\r\n\tio.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:114)\r\n\tio.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:147)\r\n\tio.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)\r\n\tio.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)\r\n\tio.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)\r\n\tio.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)\r\n\tio.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)\r\n\tio.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\r\n\tjava.lang.Thread.run(Thread.java:748)\r\n2018-09-11 09:49:56.964 [nettyWorkerPool-3-3] ERROR io.netty.util.ResourceLeakDetector - LEAK: ByteBuf.release() was not called before it's garbage-collected. See http://netty.io/wiki/reference-counted-objects.html ffun run(stubArgs: StubArgs) {or more information.\r\nRecent access records: \r\nCreated at:\r\n\tio.netty.buffer.SimpleLeakAwareByteBuf.unwrappedDerived(SimpleLeakAwareByteBuf.java:143)\r\n\tio.netty.buffer.SimpleLeakAwareByteBuf.readRetainedSlice(SimpleLeakAwareByteBuf.java:67)\r\n\tio.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:305)\r\n\tio.netty.handler.codec.http.HttpServerCodec$HttpServerRequestDecoder.decode(HttpServerCodec.java:101)\r\n\tio.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489)\r\n\tio.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428)\r\n\tio.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)\r\n\tio.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253)\r\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\r\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\r\n\tio.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)\r\n\tio.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434)\r\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)\r\n\tio.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)\r\n\tio.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965)\r\n\tio.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)\r\n\tio.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)\r\n\tio.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)\r\n\tio.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)\r\n\tio.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)\r\n\tio.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)\r\n\tio.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\r\n\tjava.lang.Thread.run(Thread.java:748)\r\n```\r\n\r\nWhenever the error appears, after an unpredictable amount of time the stub is going to be choked and not respond to requests anymore (or intermittently)\r\n\r\nThis is the main stub code. As you can see we are using Kotlin's coroutines. Not sure if the problem is related to that :\r\n\r\n```\r\nprivate fun run() {\r\n     \r\n     ...\r\n     \r\n     val server = embeddedServer(Netty, 8080) {\r\n        install(CORS) { anyHost() }\r\n        install(CallLogging)\r\n        install(DefaultHeaders)\r\n        install(Routing) {\r\n            get() { call.respondedText(delayedResponse(call.response, returnDelay, returnBody)) }\r\n            post() { call.respondedText(delayedResponse(call.response, returnDelay, returnBody)) }\r\n        }\r\n    }\r\n    server.start()\r\n}\r\n\r\nprivate suspend fun delayedResponse(response, returnDelay, returnBody) {\r\n    delay(returnDelay)\r\n    return returnBody\r\n}\r\n\r\nfun main(args) {\r\n    runBlocking {\r\n        run()\r\n    }\r\n}\r\n```\r\n\r\nWorth mentioning that the problem is seen only when we send a POST request storm (body is about 8kilobytes of XML). It is not seen during GET request storm.\r\nAny advice on what is happening?\r\n"},"comment":{"url":"https://api.github.com/repos/ktorio/ktor/issues/comments/425023553","html_url":"https://github.com/ktorio/ktor/issues/574#issuecomment-425023553","issue_url":"https://api.github.com/repos/ktorio/ktor/issues/574","id":425023553,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTAyMzU1Mw==","user":{"login":"carlomorelli","id":6968441,"node_id":"MDQ6VXNlcjY5Njg0NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/6968441?v=4","gravatar_id":"","url":"https://api.github.com/users/carlomorelli","html_url":"https://github.com/carlomorelli","followers_url":"https://api.github.com/users/carlomorelli/followers","following_url":"https://api.github.com/users/carlomorelli/following{/other_user}","gists_url":"https://api.github.com/users/carlomorelli/gists{/gist_id}","starred_url":"https://api.github.com/users/carlomorelli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlomorelli/subscriptions","organizations_url":"https://api.github.com/users/carlomorelli/orgs","repos_url":"https://api.github.com/users/carlomorelli/repos","events_url":"https://api.github.com/users/carlomorelli/events{/privacy}","received_events_url":"https://api.github.com/users/carlomorelli/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T09:28:15Z","updated_at":"2018-09-27T09:28:15Z","author_association":"NONE","body":"A little update, unfortunately not very useful. I tried to consume with `call.receiveText()` instead of `call.receive<InputStream>()`, butd I get so many errors during the performances. As far as I remember this is also the reason why we were using InputStream receiver to begin with -- guess I'm doing something wrong somewhere.\r\n\r\n\r\n"}}
{"actor":{"display_login":"carlomorelli"}}