Misleading log messages about opening connections
See original GitHub issueDescribe the bug
When dbt is parsing, it assigns a “connection name” for each model it’s parsing, just in case it’s needed. This goes through set_connection_name, which logs that it is Acquiring new postgres connection ... and Opening a new connection, .... This behavior was very reasonable before dbt lazy-loaded connections, because it’s the last centralized place before we end up in the adapter-specific open classmethod, so it’s a nice place to send that message.
Since dbt doesn’t generally need to access adapter connections during parsing, this log message is extremely misleading, and leads users who inspect the debug logs to believe that what’s taking a long time is opening a ton of connections. What’s actually (probably) taking a long time is parsing jinja. It would be good to know either way!
We should move the message about Opening a new connection into the part of LazyHandle that calls open.
I would like Acquiring to stay (though I’m very open to rewording it) as it’s a very useful message in the event of weird threading-related connection issues. We haven’t had any of those in a while, but I assume that as soon as we remove the message we’ll introduce a slew of connection management problems somehow…
Steps To Reproduce
- install dbt
- make a few simple models like
select 1 as id - run
dbt ls - watch dbt claim to acquire a bunch of connections
Expected behavior
At the end of the day, I don’t expect dbt to log that it’s “Opening” a connection unless we’re opening a socket (or at least trying to).
Screenshots and log output
$ dbt ls
...
2020-06-03 16:46:16.243448 (MainThread): Opening a new connection, currently in state init
2020-06-03 16:46:16.253313 (MainThread): Acquiring new snowflake connection "test.project.some_test".
System information
Any database, any supported python version, any OS, dbt >= 0.15.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
I’d like to take this issue if it hasn’t been assigned yet.
@jtalmi You asked if we had any more good first issues - I think this is a great one! I know that was a month ago, but let me know if you’re interested in picking this up.