FEAT: Built-in configurable connection and transient-fault retry logic
Los mantenedores suelen responder en 1 día
@Om-singhaI ya está trabajando en esto.
Desde el 2/9/2026.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Summary
Add first-class, configurable retry logic to mssql-python so applications get transient-fault resiliency without hand-rolling their own retry loops. Today the only retry surface is the ODBC-level ConnectRetryCount/ConnectRetryInterval keywords, which only silently reconnect a dropped idle connection. They do not retry a connect() that fails transiently, nor a query that fails with a recoverable error (deadlock victim, lock/query timeout, or Azure SQL throttling such as 40197/40501/49918). Every app has to reimplement this, and most get the backoff, jitter, and "which errors are retriable" classification subtly wrong.
Motivation
- Parity with the .NET Microsoft.Data.SqlClient configurable retry providers (
SqlRetryLogicBaseProvider,SqlConnection.RetryLogicProvider/SqlCommand.RetryLogicProvider) and the Azure SDK retry-policy conventions. - Azure SQL Database and SQL Managed Instance routinely surface transient errors during failover, scaling, and throttling; robust handling is effectively required for production.
- Reduces copy-pasted, error-prone retry loops and centralizes the transient-error taxonomy in the driver where it can be maintained authoritatively.
Proposed API (for discussion)
A retry policy object, attachable at the connection level and overridable per cursor/execute:
from mssql_python import RetryPolicy, connect
policy = RetryPolicy(
max_attempts=3, # total tries, not extra retries
backoff="exponential", # "exponential" | "fixed" | "none"
base_delay=1.0, # seconds
max_delay=30.0, # cap per wait
jitter=True, # full jitter to avoid thundering herd
# Retriable classification, defaulted by the driver but overridable:
# connect-scope errors -> fresh connection; query-scope -> same connection
)
conn = connect(conn_str, retry_policy=policy) # applies to connect() + queries
cursor = conn.cursor(retry_policy=policy) # optional override
cursor.execute(sql, *params, retry_policy=policy) # optional per-call override
Key behaviors:
- Two scopes, because recovery differs: connection-establishment/connection-loss errors need a fresh connection; connection-surviving errors (deadlock, query timeout, throttling) retry on the same connection.
- Driver-maintained default retriable set (transient SQLSTATEs / native error numbers), overridable by the caller.
- Idempotency guardrail: by default only retry statements the caller marks safe, or document clearly that writes must be wrapped in an explicit transaction. Never silently replay a non-idempotent write.
- Observability: emit standard
loggingrecords on each retry (attempt count, error, delay) and on final give-up. - No behavior change by default (opt-in), so existing code is unaffected.
Alternatives considered
- ODBC
ConnectRetryCount/ConnectRetryInterval— only covers idle-connection reconnect, notconnect()or query retries. - Application-level helper loops — what everyone does now; duplicative and easy to get wrong (backoff, jitter, error classification, connect-vs-query scope).
Additional context
Docs currently ship a sample connect_with_retry / execute_with_retry pattern that demonstrates exactly this behavior and would map cleanly onto a built-in RetryPolicy.
- Lenguaje dominante
- Python
- Estrellas
- 478
- Forks
- 62
- Merge medio
- 3 d 1 h
- PR fusionados (30 d)
- 27
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/mssql-python
-
area: bulk-copy
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
microsoft/mssql-python#843 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
macOS: encrypted connections fail after Homebrew moved the `openssl` alias to `openssl@4`Posiblemente ocupada @bewithgaurav la tomó hace 14 días. Abiertoarea: packaging-platform bug triage needed
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
microsoft/mssql-python#826 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
bulkcopy PyCore login is closed by SQL Server 2019 while ODBC and Go clients succeed (1.14.0)Quizá libre de nuevo @bewithgaurav la tomó hace 34 días y no hay ningún pull request abierto. Abiertoarea: bulk-copy bug triage done
microsoft/mssql-python#750 · 4 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Announcement: mssql-python is coming to Django through mssql-django 2.0Quizá libre de nuevo @bewithgaurav la tomó hace 41 días y no hay ningún pull request abierto. Abiertoannouncement
microsoft/mssql-python#748 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Connection pool can briefly exceed max_size when pooling is disabled under loadPosiblemente ocupada @bewithgaurav la tomó hace 23 días. Abiertoarea: connectivity-auth bug triage done under development
Dificultad 4/5 3-5 días Aptitud para principiantes 62/100
microsoft/mssql-python#746 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/mssql-python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Deltares/imod-python#1940 ·
Los mantenedores suelen responder en 1 día
-
effort: low prio: low ready
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
digitalfabrik/integreat-cms#4621 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
ioos/compliance-checker#1375 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
netbox status: backlog topic: testing type: housekeeping
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
netbox-community/netbox#23395 ·
Los mantenedores suelen responder en 1 día