-
Notifications
You must be signed in to change notification settings - Fork 103
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
fix: multi-thread issues by removing global boto3 session #45
fix: multi-thread issues by removing global boto3 session #45
Conversation
d213f24
to
e51c4d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @Jrmyy could you have a look too. I think that using boto3 sessions should fix the original issue why a global session was introduced.
I have to test it. Last time I try that solution, with MFA, it was an horror, a code was asked for every request, and since we can only use a code one time and a code is issued every 30 seconds it can be very annoying. |
@Jrmyy with MFA did you try to use aws-vault? it should keep the session for some time, I think more than 15 minutes. |
I did not know about that. Thanks for the heads up ! I test it today. |
So I tested without aws-vault and he is indeed asking me at each operation the MFA code, which is definitely not great from a developer perspective ... I will take a look at aws-vault. |
I use AWS control tower and AWS SSO to assume a role ( |
@Jrmyy aws-vault have |
I think I am struggling with getting aws-vault to work with my AWS Configuration / MFA and aws_profile_name from the adapter ... Do you put any aws_profile_name in the adapter conf ? |
I'm not using any AWS profile on dbt profile in athena. When you cann easy way to see if aws-vault works is to run this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with leapp, works like a charm
I run a dbt project usually with
threads: 4
orthreads: 8
. When I switched my projects away from theTomme/dbt-athena
to this adapter, I received:I did some investigation in #43 and found that the global session we use (singleton) is probably the culprit. Each thread needs its own session. Re-using a session is not thread-safe.
This is nicely mentioned on the documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html#multithreading-or-multiprocessing-with-resources
Therefore, let's remove the global session and then each thread will make a new
AthenaConnection
(with a new session)?Fixes #43