Skip to content
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

Give each redshift client their own boto session #2766

Merged

Conversation

jweibel22
Copy link
Contributor

@jweibel22 jweibel22 commented Sep 17, 2020

resolves #2756

Description

Since the boto session is not thread-safe, using the default session in a multi-threaded scenario will result in concurrency errors.
This change ensures that a fresh session is instantiated before creating the client. This is similar to what is happening in the else branch. Thus, this change should not cause any unexpected issues (e.g. exceeding service quotas)

Checklist

  • I have signed the CLA
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot cla-bot bot added the cla:yes label Sep 17, 2020
@jweibel22 jweibel22 changed the base branch from dev/kiyoshi-kuromiya to dev/0.18.1 September 17, 2020 09:08
@jtcohen6
Copy link
Contributor

@jweibel22 Nice! I'd love to get this in for v0.18.1. Does this change work for you locally when you run with multiple threads?

Also, could you:

  • pull changes from dev/0.18.1 (which should include fixes to the failing Redshift integration tests)
  • add a changelog entry under v0.18.1

@jweibel22 jweibel22 force-pushed the fix/redshift-iam-concurrency-issue branch from 079bd67 to 34388a6 Compare September 18, 2020 07:45
@cla-bot
Copy link

cla-bot bot commented Sep 18, 2020

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Github Build Bot.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https:/settings/emails

@cla-bot cla-bot bot removed the cla:yes label Sep 18, 2020
since the boto session is not thread-safe, using the default session in a multi-threaded scenario will result in concurrency errors
@jweibel22 jweibel22 force-pushed the fix/redshift-iam-concurrency-issue branch from 34388a6 to 863d8e6 Compare September 18, 2020 08:30
@cla-bot cla-bot bot added the cla:yes label Sep 18, 2020
@jweibel22
Copy link
Contributor Author

@jweibel22 Nice! I'd love to get this in for v0.18.1. Does this change work for you locally when you run with multiple threads?

Yes, I have verified that is does resolve the issue when I run dbt compile locally.

Copy link
Contributor

@beckjake beckjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice!

Could you add a test to the redshift unit tests in tests/unit/test_redshift_adapter.py that makes sure we call boto3.Session().client() instead of boto3.client() directly in both the iam_profile cases (none and not none)? I would hate to regress on this.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@beckjake beckjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks great to me

Copy link
Contributor

@jtcohen6 jtcohen6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @jweibel22! I'll try to resolve the changelog conflict and get this in.

@jtcohen6 jtcohen6 merged commit f918fd6 into dbt-labs:dev/0.18.1 Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dbt compile fails against redshift when using multi-threading
3 participants