Skip to content

fix: stop calling GetSession per query inside the Glue session - #693

Open
meniluca wants to merge 2 commits into
aws-samples:mainfrom
meniluca:fix/in-session-getsession-throttling
Open

fix: stop calling GetSession per query inside the Glue session#693
meniluca wants to merge 2 commits into
aws-samples:mainfrom
meniluca:fix/in-session-getsession-throttling

Conversation

@meniluca

@meniluca meniluca commented Sep 1, 2026

Copy link
Copy Markdown

resolves: #692

Description

The use_arrow result path resolved the session's SecurityConfiguration on every query, building a fresh boto3 client each time and calling GetSession under botocore's legacy retry policy (4 attempts, no backoff). On busy runs that exhausted the Glue API rate limit:

ThrottlingException: An error occurred (ThrottlingException) when calling the GetSession operation (reached max retries: 4): Rate exceeded

SecurityConfiguration is fixed for a session's lifetime, so it is now resolved once per session rather than once per query, and the in-session clients are cached and built with the adapter's boto_retry_mode / boto_retry_max_attempts. Because cursor() re-sends SQLPROXY before every query into the same interpreter, the cache sentinels are initialised only when unset; assigning them unconditionally would drop the cache before each query and leave the call rate unchanged.

Measured on Glue 5.0, 2 x G.1X, eu-central-1, HEAD vs this change:

  GetSession       1 per query -> 1 per session
  1 row            351ms -> 259ms  (-26%)
  1k rows x 1KB    396ms -> 270ms  (-32%)
  15k rows x 1KB   733ms -> 658ms  (-10%)

Affects use_arrow: true only; the stdout path is unchanged.

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-glue next" section.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The use_arrow result path resolved the session's SecurityConfiguration on
every query, building a fresh boto3 client each time and calling GetSession
under botocore's legacy retry policy (4 attempts, no backoff). On busy runs
that exhausted the Glue API rate limit:

  ThrottlingException: An error occurred (ThrottlingException) when calling
  the GetSession operation (reached max retries: 4): Rate exceeded

SecurityConfiguration is fixed for a session's lifetime, so it is now
resolved once per session rather than once per query, and the in-session
clients are cached and built with the adapter's boto_retry_mode /
boto_retry_max_attempts. Because cursor() re-sends SQLPROXY before every
query into the same interpreter, the cache sentinels are initialised only
when unset; assigning them unconditionally would drop the cache before
each query and leave the call rate unchanged.

Measured on Glue 5.0, 2 x G.1X, eu-central-1, HEAD vs this change:

  GetSession       1 per query -> 1 per session
  1 row            351ms -> 259ms  (-26%)
  1k rows x 1KB    396ms -> 270ms  (-32%)
  15k rows x 1KB   733ms -> 658ms  (-10%)

Affects use_arrow: true only; the stdout path is unchanged.
Comment thread README.md
@rumeshkrish

Copy link
Copy Markdown
Member

/test glue 7c4aa44

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ Python model tests triggered by @rumeshkrish for 7c4aa44ff077ebbce0821c3738123dc134628d45. View run

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ S3 Tables tests triggered by @rumeshkrish for 7c4aa44ff077ebbce0821c3738123dc134628d45. View run

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ Integration tests triggered by @rumeshkrish for 7c4aa44ff077ebbce0821c3738123dc134628d45. View run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ThrottlingException on GetSession: in-session code calls it once per query with use_arrow

2 participants