This would be helpful to avoid restarting the JVM when we have a broken connection. For example, handling open Jedis issues like https://github.com/xetorthio/jedis/issues/916. I tried mBean route and the underlying GenericObjectPool doesn't expose any API to reset pool. Hard or soft pool reset will be super useful feature, something like what c3p0 connection pool offers.
Related
I'm building an advanced RoR application with several instances of database connections running concurrently. However I'm still looking for answers for the following,
Does the connection handler automatically add a connection into the pool once its established? Like the following way,
ActiveRecord::Base.establish_connection(spec)
When would it disconnect the active connection if there's no activity for a while? Or should it be manually disconnected.
Are there any other alternatives to disconnecting the database connection like the following,
ActiveRecord::Base.remove_connection(connection_object)
How can I increase the pool size which could be for different database adapters.
Looking forward to some tips.
Can some tell me how to use connection pooling with MonetDb? Do I just append these args to the URL "poolminimum=1;poolmaximum=5;"?
No, by itself, the driver does not pool connections. You could use c3p0 (http://www.mchange.com/projects/c3p0/) to create a connection pool for MonetDB JDBC connections. However, please be aware that MonetDB uses optimistic concurrency control and table-level locking, so firing updates at a single table from multiple connections will have an increasing risk of transaction aborts. For reading however, this should be fine.
We have our application deployed to WAS 6 cluster. And recently it is throring following exception.
javax.resource.ResourceException: The back-end resource is currently unavailable. Stuck connections have been detected.
......
Can somebody explain me why db connection was not released by the app and came back to free pool? How can I detect what is blocking connection to be released? I am planning to take thread dump every fee secs.
Everything was working fine and all of a sudden we started getting this exception, which is causing an issue with new user who is trying to login into the app.
Any input will be greatly appreciated. I have very little knowledge about WAS admin.
Thanks
Try using the PMI within the WAS console under Monitoring and Tuning, this will allow you to trace both the JDBC and thread pool usage in real time, I would definitely pay close attention to the WebContainer pool and see if the size of the pool tracks with the JDBC connection.
If the pools themselves are becoming exhausted you can increase the size to provide some legroom by upping the Maximum Connection Settings for the JDBC connection under Resources -> Data Sources -> $NAME -> Connection Pool, and the other connection pool settings under Server -> $SERVERNAME -> Additional Properties -> Thread Pool
Ensuring that the database your connecting to also has sufficent free connections would also be an idea! :)
If you are leaking pool connections, then its likely the code is missing a close connection somewhere.
So I have a connection pool setup. Which is great and all since I have an application that really needs it. However what I would like to know is if it is possible to share this connection pool with other J2SE apps? Would this even be worth it, as opposed to creating a connection pool based on each apps needs? If it would be prudent, how can I accomplish this?
It is not hard having connection pools in a single JVM doing multiple things - that is what applications servers do everyday (using JNDI to throw objects across classloaders)
The interesting part is when you have the connection pool in a separate JVM from the client code needing it, as this does not immediately allow simply asking for and getting a connection from the pool and returning it afterwards.
Basically you have two options:
Doing remote requests for all your JDBC commands over the network. This will most likely mean that the data will travel over the network twice, from the database to the connection pool, and then from the connection pool to your application. If the database connections are very expensive objects then this might be a viable solution.
Use RMI to get the connection object from the connection pool JVM to your own machine. This is a very expensive operation, but can as far as I know include the actual driver classes, allowing your connection pool to provide connections to databases not known to your application JVM. To me this would only make sense if the database connections were ridiculoulusly expensive or it was a requirement to be able to support additional databases after deployment without changing the original deployments.
Note that the primary reason for having connection pools at all is because connections are expensive to create, use shortly and then discard. Some databases more than others, e.g. MySQl is (or was when I tried) very cheap so it might be the simplest just to do that.
So. First of all: Measure what your connection pool buys you in time, and then consider if it is worth your while to centralize this further.
We notice something strange in our struts web application which was hosted on sun app server enterprise edition 8.1.
The NumConnUsed for Monitoring of JDBC resources stays at 100 over connections even though there was relatively very low user activities.
I try to do some research and found the following links
http://j2ee-performance.blogspot.com/
http://www.ibm.com/developerworks/websphere/library/techarticles/0506_johnsen/0506_johnsen.html
"When the application closes a shareable connection, the connection is not truly closed, nor is it returned to the free pool. Rather, it remains in the Shared connection pool, ready for another request within the same LTC for a connection to the same resource."
Base on the above comments, it is true that if my web.xml resource ref scope is set to shareable, when application side close conneciton, it remains in the shared conneciton pool thus the numconnused is always so high?
If I interpret the links in my own special way (;)), the shared vs. unshared connections is based on different connections in the same page.
java.sql.Connection connectionOne = DriverManager.getConnection(...);
...
java.sql.Connection connectionTwo = DriverManager.getConnection(...);
These two, at a glance, seem to be individual - but if your AS is set to shareable connections, the second one will be created with a pointer to the first connection instead of returning a new connection. When the page finishes the connection should be sent back to the pool.
The AS is probably keeping the pool filled with connections to enhance performance.
This is not fact, only my own iterpretation of the links.