-
Notifications
You must be signed in to change notification settings - Fork 429
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
Throw exception on first connection instead of retry for incorrect password #483
Comments
The customer brought this concern to Andrea and I, after the customer read the following documentation article: |
Hi Sandeep Chinnari, I tried to replicate your issue while trying to attempt connecting to SQL Server with incorrect password. I tested with driver versions 3.0 and latest 6.3.2 preview version, I was not able to replicate the issue. Driver does not seem to re-attempt establishing connection, if wrong credentials are provided. Neither does it make retry attempts, nor does it wait till timeout occurs to throw the Exception. I would like to help you resolve this issue, if you can provide us repro code which can be helpful to reproduce the issue on our end. Also provide details on SQL Server version, connection properties, application configurations (e.g. connection pooling) which may be helpful to trace the issue. |
SQL Server versions tried - SQL 2012 Enterprise edition ,SQL 2008 R2 Enterprise edition |
Our app is a spring boot app running on Tomcat and using Hikari CP. |
Thanks @sandeepchinnari, do you potentially have some code you could share with us to reproduce your issue? |
@sandeepchinnari, we're following up on this investigation. Do you have any code you could share to reproduce the issue? |
Sorry for the delayed response, we’ve had some trouble reproducing this as well. Below is the output of what it looks like when it happens, followed by the code run against a locked account to achieve it. Specifically, look for the messages “ConnectionID:1 This attempt No: ” 2017-09-22 13:45:16.702 DEBUG 2633 --- [ main] com.zaxxer.hikari.HikariConfig : HikariPool-1 - configuration: ** Password retrieved: [xxx] ... 2017-09-22 13:45:45.800 DEBUG 2633 --- [ main] c.m.s.jdbc.internals.SQLServerException : *** SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user '[removed]' because the account is currently locked out. The system administrator can unlock it. Msg 18486, Level 14, State 1, Login failed for user '[removed]' because the account is currently locked out. The system administrator can unlock it. And the code that we used is as follows:
|
Any update on this Andrea? |
Hi @sandeepchinnari Thanks for detailed logs.. We are on it - will update you soon ! |
Hi @sandeepchinnari I used exactly same settings for Hikari Pool as above, but unfortunately I am not able to reproduce the issue. I created a simple Maven Application and Looking at the logs, I think reconnect is related to the below message:
Would like to know more to help you resolve issue:
|
Also, I would like to know does this issue occur in any kind of exception, eg invalid user, incorrect password or just locked user account. |
sandeepchinnari commented 21 days ago
|
Hi @sandeepchinnari I think this issue is occurring only on older SQL Server versions (2008 and 2012), due to error code '18486' on 'Locked User Account'. It seems like this error code does not get returned in later versions of SQL Server. I've created a PR #522 to fix the issue, can you test your code with changes from this PR to make sure this fix works for you? |
Hi @sandeepchinnari the PR is merged and changes are reflected in the latest preview release v6.3.5. Request you to test them and let us know if your issue is resolved. |
Filing on behalf of a comment left on JDBC docs
Driver version or jar name
JDBC Driver 3.0
SQL Server version
N/A
Client operating system
N/A
Java/JVM version
N/A
Table schema
N/A
Problem description
The issue is that when the SQLServerConnection class fails to make a connection on an incorrect password, we would require the SQL Server driver to throw an exception and abort the connection attempt instead of a looping retry on the same credentials. This will allow the Hikari pool to create a new connection with a new password.
Is there a way that we can SQL Server driver to throw an exception on the first connection exception instead of retrying for the duration of the set timeout? This would allow the connection pool to manage retrying connections. We were unable to find any settings for the jdbc connection string to achieve this.
We checked the latest version but there isn't a solution to this problem yet. https://github.com/Microsoft/mssql-jdbc/blob/master/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
The text was updated successfully, but these errors were encountered: