When connection fails, a hanging anonymous inode is left open in the system.
How to reproduce:
Run Rails console - take note of the process pid.
On a separate terminal run: lsof -p _PIDHERE | grep eventfd - nothing should appear
In Rails console run TinyTds::Client.new(host: "localhost") or anything that would fail
On a separate terminal run: lsof -p _PIDHERE | grep eventfd - you'll see an inode entry.
Keep running step 3 and 4 and you'll see inode entries will keep appearing, never closing.
Close the terminal - all inodes are now freed.
If on step 3 you run a TinyTds::Client.new that succeeds the inode entry only remains until you close the connection. If the connection fails, there's no way to free the resource since TinyTds::Client.new returns an exception.
On a production environment TinyTds ran in a sidekiq job - some times it would fail to connect, and eventually that left so many open inodes that sidekiq would fail most jobs with a "too many open files error".
Environment
Tested on: Ubuntu 18.04 with freetds v.1.00.110 / TDS Version: 7.4 Ubuntu 20.04 with freetds v.1.2.12 / TDS Version: auto
Affected Gem Versions: all? (tested with 0.1.0, 0.7.0, 1.3.0, 2.1.2, 2.1.5)
Description
When connection fails, a hanging anonymous inode is left open in the system.
How to reproduce:
On a production environment TinyTds ran in a sidekiq job - some times it would fail to connect, and eventually that left so many open inodes that sidekiq would fail most jobs with a "too many open files error".