-
Notifications
You must be signed in to change notification settings - Fork 426
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
Retry when DatabaseName is wrong #2188
Comments
Hi @Takuya-Soda,
So, based on your settings, the driver will attempt to connect, attempt to reconnect once, and then, after 30 seconds, time out. You said "If you try to connect to SQL Server with the following URL, it will retry for 30 seconds.". There should only be a single retry, the driver should not be continually retrying for the entire 30 seconds. If you enable driver tracing, you should see a single connection and a single reconnection attempt. The reason it takes 30 seconds to return an error is because of the default 30 seconds for You said "Expected behavior - Do not retry if DatabaseName is wrong.". You can disable retry by setting For the moment, I don't see an issue with how retry and loginTimeout is set up, but please let us know if we missed something regarding your issue. |
hi @Takuya-Soda The reason the driver retries on an invalid database name is because that is considered a transient fault error. There is no way for the driver to know that the database name is invalid it could simply be busy or other valid reasons and therefore resolvable. As Jeff mentioned if you do not want any retries at all then you can set |
I thought the SQL Server error code 4060 only happened when the DatabaseName was wrong. Does this error occur even when SQL Server is busy?
I tried it and it didn't work. I tried the following URL, but it will retry for 30 seconds.
|
I think this is a bug. The reason is that only the following comments remain and the actual code has been deleted.
|
Looking at the link below, it seems to return a different error code if it's busy. |
I would have liked that to be the case, but there are actually 31 retries.
This bug entered between 9.4.1 and 10.2.3. And in 11.2.3, the initial value of loginTimeout has changed, and I think it has increased further.
Hmmm, sure. If anything, it might be more of a problem that the retry is repeated uselessly. |
Hi @Takuya-Soda, The results from the SQL Server log are interesting. I tried reproducing this on my end after your initial post, and found the driver was doing retries that were consistent with the value of I see you tried In the meantime, can you provide us the trace logs I mentioned above? These will really help in narrowing down the issue. You can either attach them to this thread or email us at [email protected]. |
Hi @Takuya-Soda, I've reproduced the issue you are seeing. For a single connection attempt, you will see multiple login attempts, about 1 per second, which gives you the 17 or 31 you were seeing this. This is because for transient errors we continually retry login until
Let us know if these steps work for you, and whether you have any further questions. |
I tried a pattern with no value in connectRetryCount and a pattern with 0 and 1, about 5 times each, but all 30 retries were performed.
I'll have a chat with the team. However, today is a public holiday in Japan, so I don't think I can provide the log right away. |
Thanks @Jeffery-Wasty I am very happy that the issue has been reproduced.
Certainly we can avoid this problem by reducing the loginTimeout. I created this issue because a JDBC update suddenly changed the behavior, and it was due to a weird code fix. |
Sorry, @Jeffery-Wasty Do you still need the logs? If you can reproduce it, I don't think you need it. |
Yes, thank you for bringing this to our attention, and yes we will eventually have a way to avoid this behavior. No need to provide further logs. Can I close this issue? I'll update the issue again when the above mentioned feature is released. |
Okay, thank you for confirming such a small issue. Please close this issue. |
We're currently looking into making changes to retry logic so that |
PR #2212 will make the above change. |
Retry logic was rewritten in PR 2247, which will be available in driver release 12.5. |
Driver version
12.4.0
SQL Server version
Microsoft SQL Server 2022 (RTM-GDR) (KB5021522) - 16.0.1050.5 (X64) Jan 23 2023 17:02:42 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2022 Standard 10.0 (Build 20348: ) (Hypervisor)
Client Operating System
Windows 10 22H2
JAVA/JVM version
AdoptOpenJDK jdk-8.0.292.10-hotspot
Table schema
(no schema)
Problem description
If you try to connect to SQL Server with the following URL, it will retry for 30 seconds.
(
invalid_database_name
is DatabaseName that does not exist)Expected behavior
Do not retry if DatabaseName is wrong.
(like mssql-jdbc-8.4.1.jre8.jar)
Actual behavior
If DatabaseName is wrong, retry until loginTimeout.
Error message/stack trace
Any other details that can be helpful
This problem appears to have occurred in #1669.
Specifically, I suspect this code deletion is the culprit. ac78f50#diff-5a8fd0ea202eb55761d2a24d0619f2f2bd602ebbfe8e005bf4d112cc7768d840L2722
The text was updated successfully, but these errors were encountered: