You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Outlast metadata throttling with jittered retries and an existence fallback
Metadata API throttling episodes observed in CI and in a controlled probe last
tens of seconds, while the default retry policy waited about 15 seconds in
total and clients retried in lockstep.
- Add uniform jitter of up to one multiplier to retry_api_call waits and raise
the default RetryConfig attempts to seven, so the exponential waits sum to
63 seconds plus jitter.
- Expose is_retryable_error and reuse it in the dialect: when a table-metadata
request is still throttled after PyAthena's retries, has_table() determines
existence with information_schema.tables and logs a warning. The fallback
answers existence only; column, comment and table-option reflection still
propagate the throttling error, and nothing is cached from the fallback.
- Expose retry_config on the async connection adapter.
- Cover the fallback for direct and wrapped throttling codes on existing and
missing tables, keep the error-propagation regression for access denial and
unrecognized messages, and add wait-bound and jitter unit tests.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/sqlalchemy.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,13 +98,18 @@ A later listing preserves metadata already fetched for a table.
98
98
`clear_cache()` also discards this metadata; an absent entry in a listing is not cached as proof that a table does not exist.
99
99
100
100
Table-metadata lookups propagate throttling and permission errors rather than reporting missing tables.
101
-
`has_table()` propagates these failures, including access denied by Lake Formation, instead of returning or caching `False`.
101
+
`has_table()` propagates permission failures, including access denied by Lake Formation, instead of returning or caching `False`.
102
102
For failed metadata requests, only recognized `EntityNotFoundException` responses establish absence; unrecognized errors are propagated rather than guessed to mean a missing table.
103
+
When a table-metadata request is still throttled after PyAthena's retries, `has_table()` determines existence with a query on `information_schema.tables` and logs a warning.
104
+
This fallback answers only existence: it does not populate the metadata cache, and column, comment, and table-option reflection still propagate the throttling error.
105
+
Athena applies its metadata API rate limits per account; they are not listed in Service Quotas, and throttling episodes can last tens of seconds.
106
+
PyAthena's API retries use exponential backoff with uniform jitter; the default `RetryConfig` makes seven attempts whose waits sum to 63 seconds plus jitter.
103
107
PyAthena recognizes Glue error codes in Athena's `MetadataException` service-error envelope and applies `RetryConfig.exceptions` to those codes.
104
108
`RetryConfig` accepts one exception-name string or an iterable and captures the names as a tuple at construction.
105
109
Changes to the original input list or iterator no longer change the stored policy; construct a new `RetryConfig` when changing the retry policy.
106
110
SDK retries and PyAthena retries are separate layers, so increasing both attempt limits can multiply requests and waiting time.
107
111
Adaptive SDK retries regulate individual clients, not the aggregate traffic from independent CI runners.
112
+
For highly concurrent reflection or `checkfirst` DDL, bound the concurrency of metadata requests and consider `botocore.config.Config(retries={"mode": "adaptive"})` on the connection.
108
113
109
114
Use SQLAlchemy's identifier quoting for reserved words or names beginning with an underscore.
110
115
The dialect uses backticks for table DDL and double quotes for DML.
0 commit comments