dbt-core
dbt-core copied to clipboard
[CT-858] [Enhancement] Connection is always closed after each query
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
Every time a query is executed, it is then closed. This occurs with 1->XX threads, tested up to 16.
When using dbt-snowflake this causes you to have to re-login every time you issue a query, which if you have hundreds of models this can cause a massive slowdown as authentication to Snowflake is slow, especially when you are a long distance away from the server (Perth, AU -> US East 1 is 250ms for example, so having to reconnect every query when you have hundreds of models is unpleasant).
I have logged an issue on Snowflake here - https://github.com/dbt-labs/dbt-snowflake/issues/201 , but I believe this is on the dbt-core level.
Expected Behavior
A single connection is made. It would be even better if a login request for SF was made in a single thread, then that's reused for all. That would also fix MFA as well, I think? But that is out of scope
Steps To Reproduce
- Run dbt-snowflake
- Set the threads to say 2
- Have 4 queries, execute them all
- Run this query:
select *
from table(information_schema.login_history_by_user())
order by event_timestamp desc;
You can see it in the logs as well:
10:24:59.898232 [debug] [ThreadPool]: Opening a new connection, currently in state closed
Relevant log output
10:24:59.898232 [debug] [ThreadPool]: Opening a new connection, currently in state closed
Environment
- OS: Linux, Mac
- Python: 3.10.4/3.9
- dbt: 1.1.1
What database are you using dbt with?
snowflake
Additional Context
No response