[Geoserver-users] Unable to obtain connection: Cannot get a connection

I often encounter the following error during which I cannot use geoserver anymore.
On the database side, I still can view my connections in INACTIVE status.
After few minutes, Geoserver come back to work correctly.

Thanks in advance, any help is appreciated
Mauro

my configuration is:
DB Server: Oracle 10.2.0.4
operating system: Red Hat Enterprise Linux Server release 5.3 (Tikanga) 64bit
java version: jdk1.6.0_32
Apache Tomcat 7.0.35
Geoserver Version

  • 2.2
  • f5b5c35076b52d02eb9cca3fa3232bc17b5f6d80
  • 19-Sep-2012 18:33
  • 8.2 (rev 704570474295e339c08d1ca140d884f23a8a03a3)

error log:

Caused by: java.lang.RuntimeException: Unable to obtain connection: Cannot get a connection, pool error Timeout waiting for idle object
at org.geotools.jdbc.JDBCDataStore.createConnection(JDBCDataStore.java:1666)
at org.geotools.jdbc.JDBCDataStore.getConnection(JDBCDataStore.java:1606)
at org.geotools.jdbc.JDBCDataStore.getConnection(JDBCDataStore.java:1636)
at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:557)
at org.geotools.jdbc.JDBCFeatureStore.getReaderInternal(JDBCFeatureStore.java:225)
at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:562)
at org.geotools.data.store.ContentFeatureCollection.iterator(ContentFeatureCollection.java:284)
at org.geoserver.security.decorators.SecuredFeatureCollection.iterator(SecuredFeatureCollection.java:52)
at org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2496)
at org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:2013)
at org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:814)
at org.geoserver.wms.map.RenderedImageMapOutputFormat.produceMap(RenderedImageMapOutputFormat.java:490)
… 101 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:114)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.geotools.data.jdbc.datasource.AbstractManageableDataSource.getConnection(AbstractManageableDataSource.java:46)
at org.geotools.jdbc.JDBCDataStore.createConnection(JDBCDataStore.java:1652)
… 112 more
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1134)
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:106)
… 115 more


Mauro Bagazzi
SardegnaIT srl
Viale Trieste 186, Cagliari
Telefono : +39-0706064365
E-mail: <mbagazzi@anonymised.com>
Skype: mauro.bagazzi

On Mon, Feb 4, 2013 at 12:45 PM, mbagazzi@anonymised.com <maurobagazzilavoro@anonymised.com> wrote:

I often encounter the following error during which I cannot use geoserver anymore.
On the database side, I still can view my connections in INACTIVE status.
After few minutes, Geoserver come back to work correctly.

Your Oracle database is closing connections that GeoSever is trying to pool, either
because it is set so, or because it has been restarted, or because it is configured to drop
them after a certain timeout.

The easiest fix is to enable the connection validation in your datastore configuration panel

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Hello Andrea,

the option “validate connections” is already checked.
I am sure the DB does not close connections because I verified that during this strange behaviour connections still were there.
No automatic process is scheduled on the database to kill sessions after a certain period of time and no firewall can also do it because the DB and the Geoserver are on the same subnet.

What can I do or check to avoid this?
Thanks

Mauro

2013/2/4 Andrea Aime <andrea.aime@anonymised.com…>

On Mon, Feb 4, 2013 at 12:45 PM, mbagazzi@anonymised.com.5407… <maurobagazzilavoro@anonymised.com> wrote:

I often encounter the following error during which I cannot use geoserver anymore.
On the database side, I still can view my connections in INACTIVE status.
After few minutes, Geoserver come back to work correctly.

Your Oracle database is closing connections that GeoSever is trying to pool, either
because it is set so, or because it has been restarted, or because it is configured to drop
them after a certain timeout.

The easiest fix is to enable the connection validation in your datastore configuration panel

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Mauro Bagazzi
SardegnaIT srl
Viale Trieste 186, Cagliari
Telefono : +39-0706064365
E-mail: <mbagazzi@anonymised.com>
Skype: mauro.bagazzi

How are you checking oracle’s connections?

Vince

Sent from my iPad

On Feb 4, 2013, at 8:49 AM, “mbagazzi@…5407…” <maurobagazzilavoro@…84…> wrote:

Hello Andrea,

the option “validate connections” is already checked.
I am sure the DB does not close connections because I verified that during this strange behaviour connections still were there.
No automatic process is scheduled on the database to kill sessions after a certain period of time and no firewall can also do it because the DB and the Geoserver are on the same subnet.

What can I do or check to avoid this?
Thanks

Mauro

2013/2/4 Andrea Aime <andrea.aime@…1107…>

On Mon, Feb 4, 2013 at 12:45 PM, mbagazzi@…5407… <maurobagazzilavoro@…84…> wrote:

I often encounter the following error during which I cannot use geoserver anymore.
On the database side, I still can view my connections in INACTIVE status.
After few minutes, Geoserver come back to work correctly.

Your Oracle database is closing connections that GeoSever is trying to pool, either
because it is set so, or because it has been restarted, or because it is configured to drop
them after a certain timeout.

The easiest fix is to enable the connection validation in your datastore configuration panel

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Mauro Bagazzi
SardegnaIT srl
Viale Trieste 186, Cagliari
Telefono : +39-0706064365
E-mail: <mbagazzi@…5407…>
Skype: mauro.bagazzi


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

I checked the sessions from v$session Oracle view. During the time geoserver was not working correctly I verified that the connections were opened and INACTIVE on Oracle DB.

Mauro

2013/2/4 Vince Lotito <vince@anonymised.com>

How are you checking oracle’s connections?

Vince

Sent from my iPad

On Feb 4, 2013, at 8:49 AM, “mbagazzi@anonymised.com” <maurobagazzilavoro@anonymised.com> wrote:

Hello Andrea,

the option “validate connections” is already checked.
I am sure the DB does not close connections because I verified that during this strange behaviour connections still were there.
No automatic process is scheduled on the database to kill sessions after a certain period of time and no firewall can also do it because the DB and the Geoserver are on the same subnet.

What can I do or check to avoid this?
Thanks

Mauro

2013/2/4 Andrea Aime <andrea.aime@anonymised.com…>

On Mon, Feb 4, 2013 at 12:45 PM, mbagazzi@anonymised.com <maurobagazzilavoro@anonymised.com> wrote:

I often encounter the following error during which I cannot use geoserver anymore.
On the database side, I still can view my connections in INACTIVE status.
After few minutes, Geoserver come back to work correctly.

Your Oracle database is closing connections that GeoSever is trying to pool, either
because it is set so, or because it has been restarted, or because it is configured to drop
them after a certain timeout.

The easiest fix is to enable the connection validation in your datastore configuration panel

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Mauro Bagazzi
SardegnaIT srl
Viale Trieste 186, Cagliari
Telefono : +39-0706064365
E-mail: <mbagazzi@anonymised.com>
Skype: mauro.bagazzi


Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan


Geoserver-users mailing list
Geoserver-users@anonymised.comurceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Mauro Bagazzi
SardegnaIT srl
Viale Trieste 186, Cagliari
Telefono : +39-0706064365
E-mail: <mbagazzi@anonymised.com>
Skype: mauro.bagazzi

On Mon, Feb 4, 2013 at 3:11 PM, Vince Lotito <vince@anonymised.com> wrote:

How are you checking oracle’s connections?

By sending a quick query, it’s the only cross-database way allowed by DBCP, the connection
pool we’re using.

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Mon, Feb 4, 2013 at 3:16 PM, mbagazzi@anonymised.com <maurobagazzilavoro@anonymised.com> wrote:

I checked the sessions from v$session Oracle view. During the time geoserver was not working correctly I verified that the connections were opened and INACTIVE on Oracle DB.

Ah, ok. Looked at the stack trace again, the issue is actually lost connections,
connections that are not getting closed by some code in GeoServer.

We had this issue in GetFeatureInfo, and it got fixed some time ago:
http://jira.codehaus.org/browse/GEOS-4857

Not sure if the fix actually made it into 2.2.1, since the ticket was closed
the same day as the release, but it should be in 2.2.2 onwards

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


Ok, troubleshooting jdbc connection pools can be tricky… Good catch Andrea…
V

Sent from my iPad

On Feb 4, 2013, at 9:22 AM, “Andrea Aime” <andrea.aime@…1107…> wrote:

On Mon, Feb 4, 2013 at 3:16 PM, mbagazzi@…5407… <maurobagazzilavoro@…84…> wrote:

I checked the sessions from v$session Oracle view. During the time geoserver was not working correctly I verified that the connections were opened and INACTIVE on Oracle DB.

Ah, ok. Looked at the stack trace again, the issue is actually lost connections,
connections that are not getting closed by some code in GeoServer.

We had this issue in GetFeatureInfo, and it got fixed some time ago:
http://jira.codehaus.org/browse/GEOS-4857

Not sure if the fix actually made it into 2.2.1, since the ticket was closed
the same day as the release, but it should be in 2.2.2 onwards

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


ok Andrea,
I’ll install the last stable release 2.2.4 and let you know if I’ll still encounter the same problem.
Many thanks

Mauro

2013/2/4 Andrea Aime <andrea.aime@anonymised.com>

On Mon, Feb 4, 2013 at 3:16 PM, mbagazzi@anonymised.com5407… <maurobagazzilavoro@anonymised.com> wrote:

I checked the sessions from v$session Oracle view. During the time geoserver was not working correctly I verified that the connections were opened and INACTIVE on Oracle DB.

Ah, ok. Looked at the stack trace again, the issue is actually lost connections,
connections that are not getting closed by some code in GeoServer.

We had this issue in GetFeatureInfo, and it got fixed some time ago:
http://jira.codehaus.org/browse/GEOS-4857

Not sure if the fix actually made it into 2.2.1, since the ticket was closed
the same day as the release, but it should be in 2.2.2 onwards

Cheers

Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it



Mauro Bagazzi
SardegnaIT srl
Viale Trieste 186, Cagliari
Telefono : +39-0706064365
E-mail: <mbagazzi@anonymised.com>
Skype: mauro.bagazzi