Some unhandled exceptions in odbc.erl ... how best do we post such feedback to erlang/OTP?

Hi, i have been getting this recurring error on a project using Erlaang ODBC for SQL Server.

Started when I updated the connection string from:

"DRIVER={ODBC Driver 17 for SQL Server};Server=..." to
"DRIVER={SQL Server};Server=..."

The second version is the only one i’ve got to work correctly with queries involving VARCHAR(MAX) like SELECT 'Bob' [name], 50 [age] FOR JSON PATH; for example.

Everything seems to work fine for several hours, then begins to fail after a while with:

     term: {:error,
      {{:badmatch, {:error, :system_limit}},
         {:odbc, :init, 1, [file: 'odbc.erl', line: 445]},
         {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 417]},
         {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 385]},
         {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}

My calling code is:

def connect() do

    {server, port, db, uid, pwd} = {host_instance(), @opt[:port], @opt[:database], @opt[:username], @opt[:password]}

    conn = "DRIVER={SQL Server};Server=#{server};PORT=#{port};DATABASE=#{db};UID=#{uid};PWD=#{pwd};"

    {:ok, pid} =
        timeout: 30_000,
        # auto_commit: true,
        binary_strings: :on,
        tuple_row: :off,
        # scrollable_cursors: :off,
        extended_errors: :on


The line that’s returning {:error, :system_limit} in odbc.erl is opening a TCP socket; the timing and the message suggests that something’s leaking these connections (leaving them open but unused) until the VM runs out of resources to open more.


@al2o3cr thanks. How would you advise a work around?

I have been thinking of how to make an ODBC pool layer, to avoid this, not so easy as ODBC connections cannot be shared, as such.

Also, could the change of driver in the connection string result in this?

You were right.

Explicitly closing connections has helped … over 24 hours running without issues now.