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

Hikari + MSSQL 7.2.1 having issues #1040

Closed
TheHydGuy opened this issue Apr 17, 2019 · 5 comments · Fixed by #1046
Closed

Hikari + MSSQL 7.2.1 having issues #1040

TheHydGuy opened this issue Apr 17, 2019 · 5 comments · Fixed by #1046
Labels
Question Used when a question is asked, as opposed to an issue being raised

Comments

@TheHydGuy
Copy link

Hello All,

We have an spring boot application that is using HikariCP and mssql 6.x libraries and everything seems working fine.

We started moving to the latest version of mssql, which is 7.2.1 and started observing issues connecting to the database, once in a while under load test.

On the initial research, we found that the SharedTimer thingy that got introduced is killing us.

2019-04-17_00:27:40.315 [42122f1e7f861f55:42122f1e7f861f55:0] [Root=1-5cb672fb-8a9936f01f1e83407ebf0024] [qtp1673605040-61] ERROR com.zaxxer.hikari.pool.HikariPool - HikariPool-278 - Exception during pool initialization. java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@746dc536 rejected from java.util.concurrent.ScheduledThreadPoolExecutor@7dd4eba[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830) at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326) at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533) at com.microsoft.sqlserver.jdbc.SharedTimer.schedule(SharedTimer.java:102)

Any help on how to fix is highly appreciated.

@TheHydGuy TheHydGuy added the Question Used when a question is asked, as opposed to an issue being raised label Apr 17, 2019
@peterbae
Copy link
Contributor

Hi @TheHydGuy, thanks for reporting this issue. The team is looking into this, and we'll let you know soon once we have an update.

@xhumanoid
Copy link

xhumanoid commented Apr 22, 2019

It is because you have not thread-safe implementation of SharedTimer introduced in #920

public static synchronized SharedTimer getTimer() use lock on class instance
public synchronized void removeRef() use lock on timer object instance

so possible situation when

  1. first thread start removeRef, shutdown executer and execute executor = null;
  2. second thread receive the same object over getTimer and execute schedule, but timer almost finished/shutdowned

refCount also updated in lines 63 and 84 without any memory barriers or synchronization, so nobody can guaranty what the final result will be =)

@TheHydGuy
Copy link
Author

Thanks for the response.

That means the HikariCP library we are using is not handling properly in this case? We do not directly deal with SharedTimer class in our code.

Thanks!

@xhumanoid
Copy link

HikariCP use SQLConnection and QueryExecutor, QueryExecutor use SharedTimer, SharedTimer contain bug.

It doesn't mean how you will use mssql-jdbc driver with HikariCP or directly without any pool, you always will have incorrect work of SharedTimer in the end.

@cheenamalhotra
Copy link
Member

Hi @TheHydGuy @xhumanoid

I've created PR #1046 to address thread safety issues as discussed here, please take a look and let me know if I missed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Used when a question is asked, as opposed to an issue being raised
Projects
None yet
4 participants