{"action":"created","issue":{"url":"https://api.github.com/repos/istreamdata/orientgo/issues/51","labels_url":"https://api.github.com/repos/istreamdata/orientgo/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/istreamdata/orientgo/issues/51/comments","events_url":"https://api.github.com/repos/istreamdata/orientgo/issues/51/events","html_url":"https://github.com/istreamdata/orientgo/issues/51","id":125237000,"number":51,"title":"TCP Connection leak","user":{"login":"ernestas-poskus","id":4499780,"avatar_url":"https://avatars.githubusercontent.com/u/4499780?v=3","gravatar_id":"","url":"https://api.github.com/users/ernestas-poskus","html_url":"https://github.com/ernestas-poskus","followers_url":"https://api.github.com/users/ernestas-poskus/followers","following_url":"https://api.github.com/users/ernestas-poskus/following{/other_user}","gists_url":"https://api.github.com/users/ernestas-poskus/gists{/gist_id}","starred_url":"https://api.github.com/users/ernestas-poskus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernestas-poskus/subscriptions","organizations_url":"https://api.github.com/users/ernestas-poskus/orgs","repos_url":"https://api.github.com/users/ernestas-poskus/repos","events_url":"https://api.github.com/users/ernestas-poskus/events{/privacy}","received_events_url":"https://api.github.com/users/ernestas-poskus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-06T18:47:10Z","updated_at":"2016-01-06T19:18:08Z","closed_at":null,"body":"@dennwc \r\n\r\nHey, happy new year.\r\n\r\nEvening ago I was collecting metrics from go app and found out constantly increasing file descriptors. After further investigation I have found out that 'connection pool' leaks connections. \r\n\r\nHere is gist to reproduce: https://gist.github.com/ernestas-poskus/acb78d48ea0324eab095\r\n\r\nAfter running this:\r\n\r\n```bash\r\nINFO[0004] 24339                                        \r\nINFO[0004] Calling Leak                                 \r\nINFO[0008] 24339                                        \r\nINFO[0008] Calling Leak                                 \r\nINFO[0012] 24339                                        \r\nINFO[0012] Calling Leak                                 \r\nINFO[0016] 24339                                        \r\nINFO[0016] Calling Leak                                 \r\nINFO[0020] 24339                                        \r\nINFO[0020] Calling Leak \r\n```\r\n\r\n24339 is number of PID\r\n\r\nRunning:\r\n\r\n> lsof -a -p 24339\r\n\r\nOutput:\r\n\r\n```bash\r\n$ lsof -a -p 26083\r\nlsof: WARNING: can't stat() tracefs file system /sys/kernel/debug/tracing\r\n      Output information may be incomplete.\r\nCOMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME\r\nmain    26083   ow  cwd    DIR   0,44     4096 399822 \r\nmain    26083   ow  rtd    DIR    8,4     4096      2 /\r\nmain    26083   ow  txt    REG    8,4  4459779 934505 /tmp/ow/go-build249407479/command-line-arguments/_obj/exe/main\r\nmain    26083   ow  mem    REG    8,4  1869392 276942 /lib/x86_64-linux-gnu/libc-2.21.so\r\nmain    26083   ow  mem    REG    8,4   142080 275271 /lib/x86_64-linux-gnu/libpthread-2.21.so\r\nmain    26083   ow  mem    REG    8,4   154376 275269 /lib/x86_64-linux-gnu/ld-2.21.so\r\nmain    26083   ow    0u   CHR  136,1      0t0      4 /dev/pts/1\r\nmain    26083   ow    1u   CHR  136,1      0t0      4 /dev/pts/1\r\nmain    26083   ow    2u   CHR  136,1      0t0      4 /dev/pts/1\r\nmain    26083   ow    4u  0000   0,11        0   6962 anon_inode\r\nmain    26083   ow    5u  IPv4 143455      0t0    TCP localhost:57070->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow    6u  IPv4 142403      0t0    TCP localhost:57078->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow    7u  IPv4 142404      0t0    TCP localhost:57086->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow    8u  IPv4 135894      0t0    TCP localhost:57094->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow    9u  IPv4 143459      0t0    TCP localhost:57102->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   10u  IPv4 143460      0t0    TCP localhost:57110->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   11u  IPv4 139726      0t0    TCP localhost:57118->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   12u  IPv4 135901      0t0    TCP localhost:57126->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   13u  IPv4 140532      0t0    TCP localhost:57134->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   14u  IPv4 143468      0t0    TCP localhost:57142->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   15u  IPv4 138932      0t0    TCP localhost:57150->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   16u  IPv4 142431      0t0    TCP localhost:57158->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   17u  IPv4 143472      0t0    TCP localhost:57166->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   18u  IPv4 135908      0t0    TCP localhost:57174->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   19u  IPv4 140539      0t0    TCP localhost:57182->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   20u  IPv4 142439      0t0    TCP localhost:57190->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   21u  IPv4 142446      0t0    TCP localhost:57198->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   22u  IPv4 139752      0t0    TCP localhost:57206->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   23u  IPv4 142483      0t0    TCP localhost:57214->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   24u  IPv4 143494      0t0    TCP localhost:57222->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   25u  IPv4 143495      0t0    TCP localhost:57230->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   26u  IPv4 139753      0t0    TCP localhost:57238->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   27u  IPv4 138142      0t0    TCP localhost:57246->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   28u  IPv4 135953      0t0    TCP localhost:57254->localhost:2424 (ESTABLISHED)\r\nmain    26083   ow   29u  IPv4 138158      0t0    TCP localhost:57262->localhost:2424 (ESTABLISHED)\r\n```\r\n\r\nThis is concerning because as soon as app will reach file descriptors limit it will crash.."},"comment":{"url":"https://api.github.com/repos/istreamdata/orientgo/issues/comments/169425829","html_url":"https://github.com/istreamdata/orientgo/issues/51#issuecomment-169425829","issue_url":"https://api.github.com/repos/istreamdata/orientgo/issues/51","id":169425829,"user":{"login":"dennwc","id":676724,"avatar_url":"https://avatars.githubusercontent.com/u/676724?v=3","gravatar_id":"","url":"https://api.github.com/users/dennwc","html_url":"https://github.com/dennwc","followers_url":"https://api.github.com/users/dennwc/followers","following_url":"https://api.github.com/users/dennwc/following{/other_user}","gists_url":"https://api.github.com/users/dennwc/gists{/gist_id}","starred_url":"https://api.github.com/users/dennwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dennwc/subscriptions","organizations_url":"https://api.github.com/users/dennwc/orgs","repos_url":"https://api.github.com/users/dennwc/repos","events_url":"https://api.github.com/users/dennwc/events{/privacy}","received_events_url":"https://api.github.com/users/dennwc/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T19:18:08Z","updated_at":"2016-01-06T19:18:08Z","body":"Happy New Year, @ernestas-poskus !\r\n\r\nThank you for the report. It seems strange to me, that we haven't seen the leak in our cases. In any case, connection pool implementation is not so good as it might be.\r\n\r\nAnswering your question, this design is caused by state-full connections to OrientDB. It would be nice if they were state-less, allowing easy pooling, but it's not the case for now.\r\n\r\nI'm working on gRPC/protobuf integration for OrientDB server, so networking layer may be replaced some day.\r\n\r\nIn the mean time feel free to file PR for the issue or some changes to pooling mechanisms."}}