HikariPool-1 - 在连接获取期间中断

HikariPool-1 - Interrupted during connection acquisition

所以我正在尝试建立连接,但它不起作用,并给了我这个很好的异常(我不太理解):

11:17:07 [SEVERE] java.sql.SQLException: HikariPool-1 - Interrupted during connection acquisition
> 11:17:07 [SEVERE] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:200)
> 11:17:07 [SEVERE] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:161)
> 11:17:07 [SEVERE] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100)
> 11:17:07 [SEVERE] at net.bungeencoin.mcn.sql.DatabaseConnecter.getConnection(DatabaseConnecter.java:48)
> 11:17:07 [SEVERE] at net.bungeencoin.mcn.sql.Database.getCoins(Database.java:31)
> 11:17:07 [SEVERE] at net.bungeencoin.mcn.listeners.CacheListener.lambda$onJoin[=10=](CacheListener.java:27)
> 11:17:07 [SEVERE] at net.md_5.bungee.scheduler.BungeeTask.run(BungeeTask.java:63)
> 11:17:07 [SEVERE] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> 11:17:07 [SEVERE] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> 11:17:07 [SEVERE] at java.lang.Thread.run(Thread.java:748)
> 11:17:07 [SEVERE] Caused by: java.lang.InterruptedException
> 11:17:07 [SEVERE] at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:944)
> 11:17:07 [SEVERE] at com.zaxxer.hikari.util.ConcurrentBag.borrow(ConcurrentBag.java:157)
> 11:17:07 [SEVERE] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:179)
> 11:17:07 [SEVERE] ... 9 more

知道为什么吗?

这个错误意味着你有一个或多个 long-运行 SQL 语句持有你的 Hikari 连接池中的所有连接,在此期间还有一个叫做“中断”的东西在您的应用程序中,调用所有阻塞线程以在它们阻塞的地方抛出中断异常。

Hikari CP 使用阻塞结构来保证线程安全,因此出现了这个堆栈跟踪。

相关 GitHub 问题 https://github.com/brettwooldridge/HikariCP/issues/976

这是关于 InterruptedException 主题的经典博客 post: https://www.ibm.com/developerworks/library/j-jtp05236/index.html