-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CT-854] Cache authentication (token) for subsequent connections #201
Comments
Thanks @joshuataylor! I left a fuller response over in dbt-labs/dbt-core#5489 (comment) I'm going to close this issue, for now, in favor of centralizing the conversation over there |
Reopening as there might be a
|
It shouldn't be a security risk, as the connection details are passed in anyway when doing an open. So it should be fine. My proof of concept was this, where we can check that:
if connection.state == "closed" and connection.handle and connection.handle.rest.token:
return connection However this throws a RecursionError as we're trying to access the handle via the open. I think if we could alter the credentials with a token, that would work, but I'm unsure if that's threadsafe? |
This is a legitimate concern. We'd need some way to detect that the token is invalid — probably by trying to open a connection with it, catching the error, and falling back to re-authenticate.
It does seem like there'd be a risk around thread safety. The only object not reused / shared between threads is the connection itself. Could we use the Connection Manager's |
I've got a PR here which should solve the issue safely, as it won't release it: #203 This doesn't change open/close logic so you shouldn't see any problems around that. |
I ran into the same problem when I install dbt via brew. I uninstall dbt via brew then pip install from scratch , the problem is gone. |
Describe the bug
With Snowflake, logging in is slow (as it should be, given password hashing etc), so it should be avoided.
Every query that is executed causes a new login, as the connection is marked as closed. This should not happen, the connection should be marked as open so you're not forced to login again.
Steps To Reproduce
Expected behavior
A single login happens, maybe by thread?
System information
Happens on MacOS/Linux, pretty sure it's not a OS issue..
Python 3.10.4, dbt 1.1.1
The text was updated successfully, but these errors were encountered: