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

Updating of properties not recognized #1114

Closed
du-it opened this issue Mar 15, 2018 · 3 comments
Closed

Updating of properties not recognized #1114

du-it opened this issue Mar 15, 2018 · 3 comments

Comments

@du-it
Copy link

du-it commented Mar 15, 2018

Environment

HikariCP version: 2.7.8
JDK version     : 1.8.0_161
Database        : PostgreSQL
Driver version  : 42.2.1

Have you searched the CLOSED issues already? How about checking stackoverflow?
--> Yes!

I tried to modify the connectionTimeout property. I am allowed to set this value and I checked that using the appropriate getter for this property.
I changed it from the default of 30 seconds to 10 second.
According to https://github.com/brettwooldridge/HikariCP/blob/dev/src/main/java/com/zaxxer/hikari/HikariConfig.java#L64 this property IS changeable.

I tried to set the property via HikariPoolMXBean and via HikariConfiogMXBean but the value stays at 30 seconds.

I tested that by obtaining all connections from the pool and then getting one further.
Some test output...

Initial connectionTimeout: 30000
New connectionTimeout:10000
Now get a further connection although no connection is available anymore.
initial timeout: 30000
new timteout: 10000
duration: 30003

Here's the exception:

java.sql.SQLTransientConnectionException: myCP - Connection is not available, request timed out after 30001ms.
	at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:667)
	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:183)
	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:148)
	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100)
	at de.etc.cpm.HikariMonitoringCapabilitiesTest.testConnectionTimeoutEffectivelyModified(HikariMonitoringCapabilitiesTest.java:136)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:19)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

So, how can i modify Hikari properties at runtime...effectively?

@brettwooldridge
Copy link
Owner

@du-it You're doing it right, however, the new value will not be picked up until the housekeeper thread runs. The housekeeper thread runs every 30 seconds. So, in the best case your change will be picked up immediately, on average your change will be picked up in 15 seconds, and at worst your change will be picked up in 30 seconds (if the housekeeper ran just before your change).

I have added an additional MBean test to verify that changing the connectionTimeout works as designed.

@du-it
Copy link
Author

du-it commented Mar 29, 2018

The lines

conn1.close();
conn2.close();

are unreachable, aren't they!? ;-)

@brettwooldridge
Copy link
Owner

You are correct, those lines are unreachable; left over from a refactor.

kollstrom pushed a commit to kollstrom/HikariCP that referenced this issue Feb 4, 2021
kollstrom pushed a commit to kollstrom/HikariCP that referenced this issue Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants