英文:
HikariPool-1 - Interrupted during connection acquisition
问题
所以我正在尝试建立连接,但连接不起作用,并且给我了这个看起来很棒的异常(我似乎无法理解):
11:17:07 [严重] java.sql.SQLException: HikariPool-1 - 在获取连接过程中被中断
> 11:17:07 [严重] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:200)
> 11:17:07 [严重] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:161)
> 11:17:07 [严重] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100)
> 11:17:07 [严重] at net.bungeencoin.mcn.sql.DatabaseConnecter.getConnection(DatabaseConnecter.java:48)
> 11:17:07 [严重] at net.bungeencoin.mcn.sql.Database.getCoins(Database.java:31)
> 11:17:07 [严重] at net.bungeencoin.mcn.listeners.CacheListener.lambda$onJoin$0(CacheListener.java:27)
> 11:17:07 [严重] at net.md_5.bungee.scheduler.BungeeTask.run(BungeeTask.java:63)
> 11:17:07 [严重] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> 11:17:07 [严重] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> 11:17:07 [严重] at java.lang.Thread.run(Thread.java:748)
> 11:17:07 [严重] 原因是:java.lang.InterruptedException
> 11:17:07 [严重] at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:944)
> 11:17:07 [严重] at com.zaxxer.hikari.util.ConcurrentBag.borrow(ConcurrentBag.java:157)
> 11:17:07 [严重] at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:179)
> 11:17:07 [严重] ... 9 more
英文:
So I'm trying to get a connection and it doesn't work and gives me this nice exception (which I don't semm to understand):
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$0(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
Any idea why?
答案1
得分: 6
这个错误意味着你的应用中有一个或多个长时间运行的SQL语句,它们占用了Hikari连接池中的所有连接,在此期间,有其他内容调用了你的应用中的“中断(Interrupt)”操作,在这些阻塞线程阻塞的位置抛出了中断异常。
Hikari连接池使用阻塞构造来保证线程安全,因此出现了这个堆栈跟踪。
相关的GitHub问题链接:
https://github.com/brettwooldridge/HikariCP/issues/976
这是一个关于InterruptedException的经典博文:
https://www.ibm.com/developerworks/library/j-jtp05236/index.html
英文:
This error means that you had one or more long-running SQL statements that were holding onto all the connections in your Hikari connection pool, and during that period something else called "Interrupt" on your application, calling all blocking threads to throw an interrupt exception at the point where they were blocking.
Hikari CP uses blocking constructs for thread safety, hence this stack trace occurred.
Relevant GitHub issue
https://github.com/brettwooldridge/HikariCP/issues/976
Here is a classic blog post on the subject if InterruptedException:
https://www.ibm.com/developerworks/library/j-jtp05236/index.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论