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

timeout connection option #162

Closed
majidaldo opened this issue Sep 22, 2021 · 2 comments · Fixed by #395
Closed

timeout connection option #162

majidaldo opened this issue Sep 22, 2021 · 2 comments · Fixed by #395
Assignees
Labels
Milestone

Comments

@majidaldo
Copy link

On Azure SQL, you can have a db 'sleep'. It can take a few minutes to resume. In the meantime, connection attempts usually fail.

To solve this, I suggest a 'timeout' option, such that (an overall) connection attempt is considered to have failed if it exceeds this timeout. (in addition to 'n_tries' and 'time_bw_tries').

@sdebruyn
Copy link
Member

This might seem an easy one, but it isn't. The issue here is that from the side of the adapter, there is no way of knowing if the (serverless) database is in paused mode or not. The only way you can determine the paused state of the database is by looking at the Azure Portal.

When you try to connect to a paused database, you just get an error saying that your credentials are invalid. So if we get this error in the adapter, we cannot determine if you actually provided invalid credentials, or if the database is being resumed and we should try again.

There's even a second possible issue here: at the moment the Azure documentation doesn't state how the firewall behaves with paused databases. During some simple tests, I was able to resume a completely private database (so no public networking allowed) from a public network connection. The expected behaviour here is undefined in the documentation as of today.

To realise this in a trusted and stable way, Azure needs to return a specific error code for databases which are currently resuming and might become available after 1 to 3 minutes.

@sdebruyn
Copy link
Member

We could use the 2 timeout options in pyodbc (there is 1 for the connection and 1 for the queries).

@sdebruyn sdebruyn added good first issue Good for newcomers Size: Small and removed Size: Medium labels May 18, 2023
@sdebruyn sdebruyn added this to the v1.4.1 milestone May 19, 2023
@sdebruyn sdebruyn self-assigned this May 21, 2023
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 a pull request may close this issue.

3 participants