SSH tunnels not closed after creating them to test DW connections. We should use with-open
in SSH tunnel code.
#24445
Labels
with-open
in SSH tunnel code.
#24445
https://github.com/metabase/metabase/blob/master/src/metabase/driver/sql_jdbc/connection.clj#L252-L259
details->connection-spec-for-testing-connection
callsdriver/incorporate-ssh-tunnel-details
which creates a new SSH tunnel:https://github.com/metabase/metabase/blob/master/src/metabase/util/ssh.clj#L105-L115
However it never calls
metabase.util.ssh/close-tunnel!
.I'm guessing this is not causing huge problems IRL since we only test connections when adding new DWs in the admin panel, but it's still bad form to have leaky code like this. So we should fix it.
The SSH session returned by the sshd lib already implements
AutoCloseable
, so we can usewith-open
with it -- I think we need to rework our code so we're usingwith-open
when we have an SSH tunnel to make sure we're not accidentally leaking them. That would be easy enough to do indetails->connection-spec-for-testing-connection
... for the connection pool we'd have to hold it open in some other manner, maybe by having it live in the atom like the c3p0 connection pool. Maybe what we need is aSSHTunnelConnectionPool
class that wraps both an SSH tunnel and a c3p0 connection pool so that can live in the same atom as the other thingsThe text was updated successfully, but these errors were encountered: