You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2016/03/07 11:46:25 UTC

Re: Reconnecting automatically after DB downtime

Hi all,
This is still happening, even after I added a validationQuery, our app is dying quite frequently :(.  I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?

https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0

Cheer,
- hugi

// Hugi Thordarson
// http://www.loftfar.is/
// s. 895-6688



> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
> 
>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>> What does validationQuery do?
> 
> Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.
> 
> Andrus
> 


Re: Reconnecting automatically after DB downtime

Posted by Lon Varscsak <lo...@gmail.com>.
This was a great thread (even though I tried to hijack it :P).  I’m now
using Hikari too. :D

-Lon

On Wed, Mar 9, 2016 at 12:40 PM, Andrus Adamchik <an...@objectstyle.org>
wrote:

>
> > On Mar 9, 2016, at 7:34 AM, Andrus Adamchik <an...@objectstyle.org>
> wrote:
> >
> >>
> >> On Mar 9, 2016, at 12:52 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> >>
> >> Nice, works like a charm :).
> >>
> >> On a side note, websites that I’ve switched to HikariCP have been up
> since the switch, so it does seem to have been a problem with Cayenne’s
> connection pool.
> >
> > Yeah, I'll jira that. Will need to investigate.
>
> The problem wasn't what I originally thought it was. Instead what happened
> is this: at the moments when the DB was down,
> UnmanagedPoolingDataSource.createUnchecked(..) would decrement a semaphore
> controlling max pool size without creating a connection. So any DB hiccup
> would result in permanent pool shrinkage.
>
> Just fixed it per https://issues.apache.org/jira/browse/CAY-2067 .
>
> (Lack of) fair scheduling limitation mentioned by John still exists. So
> when there is a contention, failure rate may be higher then it would be
> with fair scheduling (I observed this in my unit tests, even though I
> wasn't specifically testing this condition). Shouldn't be an issue if the
> pool has enough connections.
>
> Still a third party pool is probably a better choice for production. Like
> I said, our pool is intentionally basic.
>
> Andrus

Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Mar 9, 2016, at 7:34 AM, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
>> 
>> On Mar 9, 2016, at 12:52 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>> Nice, works like a charm :).
>> 
>> On a side note, websites that I’ve switched to HikariCP have been up since the switch, so it does seem to have been a problem with Cayenne’s connection pool.
> 
> Yeah, I'll jira that. Will need to investigate.

The problem wasn't what I originally thought it was. Instead what happened is this: at the moments when the DB was down, UnmanagedPoolingDataSource.createUnchecked(..) would decrement a semaphore controlling max pool size without creating a connection. So any DB hiccup would result in permanent pool shrinkage. 

Just fixed it per https://issues.apache.org/jira/browse/CAY-2067 .

(Lack of) fair scheduling limitation mentioned by John still exists. So when there is a contention, failure rate may be higher then it would be with fair scheduling (I observed this in my unit tests, even though I wasn't specifically testing this condition). Shouldn't be an issue if the pool has enough connections. 

Still a third party pool is probably a better choice for production. Like I said, our pool is intentionally basic.

Andrus

Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Mar 9, 2016, at 12:52 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
> Nice, works like a charm :).
> 
> On a side note, websites that I’ve switched to HikariCP have been up since the switch, so it does seem to have been a problem with Cayenne’s connection pool.

Yeah, I'll jira that. Will need to investigate.

> Also, the websites I’ve switched over feel like they’ve had a caffeine enema or something of the ilk. They feel vastly faster in many cases. But that may also have something to do with configuration (HikariCP has great pages about DB specific configuration for the most common DBs).
> 
> https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration

Nice. So perhaps their claims at http://brettwooldridge.github.io/HikariCP/ are true after all :) 

Andrus

Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Nice, works like a charm :).

On a side note, websites that I’ve switched to HikariCP have been up since the switch, so it does seem to have been a problem with Cayenne’s connection pool.

Also, the websites I’ve switched over feel like they’ve had a caffeine enema or something of the ilk. They feel vastly faster in many cases. But that may also have something to do with configuration (HikariCP has great pages about DB specific configuration for the most common DBs).

https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration

Cheers,
- hugi



> On 8. mar. 2016, at 14:37, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
> Also pretty easy - define a custom DataSourceFactory:
> 
> builder.addModule(b -> b.bind(DataSourceFactory.class).to(MyImpl.class));
> 
> Andrus
> 
>> On Mar 8, 2016, at 3:20 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>> Not quite done :).
>> 
>> I have a project that uses multiple Cayenne models connected to multiple databases. The connection information is currently stored in the models and I’m constructing the ServerRuntime like this:
>> 
>> ServerRuntimeBuilder b = new ServerRuntimeBuilder( "Netbokhald" );
>> b.addConfig( "cayenne-core/cayenne-project.xml" );
>> b.addConfig( "cayenne-reporting/cayenne-project.xml" );
>> 
>> How would I go about programmatically configuring separate DataSources for each model?
>> 
>> Cheers,
>> - hugi
>> 
>> 
>> 
>>> On 7. mar. 2016, at 21:03, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>> 
>>> Well, that was easy! Up and running in production.
>>> 
>>> HikariConfig config = new HikariConfig();
>>> config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
>>> config.setUsername( “myUsername" );
>>> config.setPassword( “myPassword" );
>>> 
>>> HikariDataSource dataSource = new HikariDataSource( config );
>>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
>>> 
>>> Thanks,
>>> - hugi
>>> 
>>> 
>>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org> wrote:
>>>> 
>>>> Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:
>>>> 
>>>> DataSource ds = // instantiate it via API specific to you DS provider
>>>> 
>>>> ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
>>>> // of course add any other things you need to add to the builder to get a working Cayenne stack.
>>>> 
>>>> Andrus
>>>> 
>>>> 
>>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>>> 
>>>>> Thanks John! I’m going to try my hand at HikariCP.
>>>>> 
>>>>> Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?
>>>>> 
>>>>> Cheers,
>>>>> - hugi
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>>>>> 
>>>>>> EOF can do JNDI, but that's not going to do anything to fix your problem.
>>>>>> 
>>>>>> The connection pool in cayenne had some changes somewhat recently so it's
>>>>>> entirely possible there are bugs.
>>>>>> 
>>>>>> In practice it turns out many people don't use the connection pool built-in
>>>>>> to Cayenne at all, and rather use a third-party connection pool, of which
>>>>>> there are several.  The cayenne one is decent, but it is very limited in
>>>>>> functionality and less robust due to having a smaller user base and being a
>>>>>> non-core feature.
>>>>>> 
>>>>>> You can use another pool like:
>>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
>>>>>> new project I'd use this
>>>>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
>>>>>> This is what I currently use
>>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>>>>> c3po <http://www.mchange.com/projects/c3p0/>
>>>>>> 
>>>>>> The main reason I turned to a third-party connection pool was to get
>>>>>> fair-scheduling which will provide connections to whoever has been waiting
>>>>>> the longest, which helps avoid unnecessary errors caused by serving
>>>>>> requests out of order.
>>>>>> 
>>>>>> John
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:
>>>>>> 
>>>>>>> Well, I'm not sure what you are using to run your web application, but
>>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
>>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>>>>>>> give it the JNDI name, then configure the container to provide the DB
>>>>>>> connection.
>>>>>>> 
>>>>>>> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
>>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>>>>> 
>>>>>>> mrg
>>>>>>> 
>>>>>>> 
>>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>>>>> 
>>>>>>>> Hi Michael,
>>>>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>>>>> just
>>>>>>>> a different method of looking up connection information?
>>>>>>>> 
>>>>>>>> But I probably can’t use it anyway since one of the apps is a WebObjects
>>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>>>>> 
>>>>>>>> Thanks,
>>>>>>>> - hugi
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Hi Hugi,
>>>>>>>>> 
>>>>>>>>> Since this appears to be a web-based application, can you switch to
>>>>>>> using
>>>>>>>>> JNDI?
>>>>>>>>> 
>>>>>>>>> mrg
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>> Hi all,
>>>>>>>>>> This is still happening, even after I added a validationQuery, our app
>>>>>>>> is
>>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>>>>>>> there
>>>>>>>>>> any way for me to catch where connections are being opened in the code
>>>>>>>> and
>>>>>>>>>> at what location they’re hanging?
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>>>>> 
>>>>>>>>>> Cheer,
>>>>>>>>>> - hugi
>>>>>>>>>> 
>>>>>>>>>> // Hugi Thordarson
>>>>>>>>>> // http://www.loftfar.is/
>>>>>>>>>> // s. 895-6688
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>> What does validationQuery do?
>>>>>>>>>>> 
>>>>>>>>>>> Periodically executes for each pooled connection, and kills
>>>>>>> connections
>>>>>>>>>> that throw during validation. So it ensures that all pooled
>>>>>>> connections
>>>>>>>> are
>>>>>>>>>> in a good state.
>>>>>>>>>>> 
>>>>>>>>>>> Andrus
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
Also pretty easy - define a custom DataSourceFactory:

builder.addModule(b -> b.bind(DataSourceFactory.class).to(MyImpl.class));

Andrus

> On Mar 8, 2016, at 3:20 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
> Not quite done :).
> 
> I have a project that uses multiple Cayenne models connected to multiple databases. The connection information is currently stored in the models and I’m constructing the ServerRuntime like this:
> 
> ServerRuntimeBuilder b = new ServerRuntimeBuilder( "Netbokhald" );
> b.addConfig( "cayenne-core/cayenne-project.xml" );
> b.addConfig( "cayenne-reporting/cayenne-project.xml" );
> 
> How would I go about programmatically configuring separate DataSources for each model?
> 
> Cheers,
> - hugi
> 
> 
> 
>> On 7. mar. 2016, at 21:03, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>> Well, that was easy! Up and running in production.
>> 
>> HikariConfig config = new HikariConfig();
>> config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
>> config.setUsername( “myUsername" );
>> config.setPassword( “myPassword" );
>> 
>> HikariDataSource dataSource = new HikariDataSource( config );
>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
>> 
>> Thanks,
>> - hugi
>> 
>> 
>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org> wrote:
>>> 
>>> Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:
>>> 
>>> DataSource ds = // instantiate it via API specific to you DS provider
>>> 
>>> ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
>>> // of course add any other things you need to add to the builder to get a working Cayenne stack.
>>> 
>>> Andrus
>>> 
>>> 
>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>> 
>>>> Thanks John! I’m going to try my hand at HikariCP.
>>>> 
>>>> Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?
>>>> 
>>>> Cheers,
>>>> - hugi
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>>>> 
>>>>> EOF can do JNDI, but that's not going to do anything to fix your problem.
>>>>> 
>>>>> The connection pool in cayenne had some changes somewhat recently so it's
>>>>> entirely possible there are bugs.
>>>>> 
>>>>> In practice it turns out many people don't use the connection pool built-in
>>>>> to Cayenne at all, and rather use a third-party connection pool, of which
>>>>> there are several.  The cayenne one is decent, but it is very limited in
>>>>> functionality and less robust due to having a smaller user base and being a
>>>>> non-core feature.
>>>>> 
>>>>> You can use another pool like:
>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
>>>>> new project I'd use this
>>>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
>>>>> This is what I currently use
>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>>>> c3po <http://www.mchange.com/projects/c3p0/>
>>>>> 
>>>>> The main reason I turned to a third-party connection pool was to get
>>>>> fair-scheduling which will provide connections to whoever has been waiting
>>>>> the longest, which helps avoid unnecessary errors caused by serving
>>>>> requests out of order.
>>>>> 
>>>>> John
>>>>> 
>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:
>>>>> 
>>>>>> Well, I'm not sure what you are using to run your web application, but
>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>>>>>> give it the JNDI name, then configure the container to provide the DB
>>>>>> connection.
>>>>>> 
>>>>>> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>>>> 
>>>>>> mrg
>>>>>> 
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>>>> 
>>>>>>> Hi Michael,
>>>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>>>> just
>>>>>>> a different method of looking up connection information?
>>>>>>> 
>>>>>>> But I probably can’t use it anyway since one of the apps is a WebObjects
>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> - hugi
>>>>>>> 
>>>>>>> 
>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>>>> wrote:
>>>>>>>> 
>>>>>>>> Hi Hugi,
>>>>>>>> 
>>>>>>>> Since this appears to be a web-based application, can you switch to
>>>>>> using
>>>>>>>> JNDI?
>>>>>>>> 
>>>>>>>> mrg
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>> wrote:
>>>>>>>> 
>>>>>>>>> Hi all,
>>>>>>>>> This is still happening, even after I added a validationQuery, our app
>>>>>>> is
>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>>>>>> there
>>>>>>>>> any way for me to catch where connections are being opened in the code
>>>>>>> and
>>>>>>>>> at what location they’re hanging?
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>>>> 
>>>>>>>>> Cheer,
>>>>>>>>> - hugi
>>>>>>>>> 
>>>>>>>>> // Hugi Thordarson
>>>>>>>>> // http://www.loftfar.is/
>>>>>>>>> // s. 895-6688
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>>>>>>>>> wrote:
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> What does validationQuery do?
>>>>>>>>>> 
>>>>>>>>>> Periodically executes for each pooled connection, and kills
>>>>>> connections
>>>>>>>>> that throw during validation. So it ensures that all pooled
>>>>>> connections
>>>>>>> are
>>>>>>>>> in a good state.
>>>>>>>>>> 
>>>>>>>>>> Andrus
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>> 
>>> 
>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Not quite done :).

I have a project that uses multiple Cayenne models connected to multiple databases. The connection information is currently stored in the models and I’m constructing the ServerRuntime like this:

ServerRuntimeBuilder b = new ServerRuntimeBuilder( "Netbokhald" );
b.addConfig( "cayenne-core/cayenne-project.xml" );
b.addConfig( "cayenne-reporting/cayenne-project.xml" );

How would I go about programmatically configuring separate DataSources for each model?

Cheers,
- hugi



> On 7. mar. 2016, at 21:03, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
> Well, that was easy! Up and running in production.
> 
> HikariConfig config = new HikariConfig();
> config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
> config.setUsername( “myUsername" );
> config.setPassword( “myPassword" );
> 
> HikariDataSource dataSource = new HikariDataSource( config );
> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
> 
> Thanks,
> - hugi
> 
> 
>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org> wrote:
>> 
>> Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:
>> 
>> DataSource ds = // instantiate it via API specific to you DS provider
>> 
>> ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
>> // of course add any other things you need to add to the builder to get a working Cayenne stack.
>> 
>> Andrus
>> 
>> 
>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>> 
>>> Thanks John! I’m going to try my hand at HikariCP.
>>> 
>>> Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?
>>> 
>>> Cheers,
>>> - hugi
>>> 
>>> 
>>> 
>>> 
>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>>> 
>>>> EOF can do JNDI, but that's not going to do anything to fix your problem.
>>>> 
>>>> The connection pool in cayenne had some changes somewhat recently so it's
>>>> entirely possible there are bugs.
>>>> 
>>>> In practice it turns out many people don't use the connection pool built-in
>>>> to Cayenne at all, and rather use a third-party connection pool, of which
>>>> there are several.  The cayenne one is decent, but it is very limited in
>>>> functionality and less robust due to having a smaller user base and being a
>>>> non-core feature.
>>>> 
>>>> You can use another pool like:
>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
>>>> new project I'd use this
>>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
>>>> This is what I currently use
>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>>> c3po <http://www.mchange.com/projects/c3p0/>
>>>> 
>>>> The main reason I turned to a third-party connection pool was to get
>>>> fair-scheduling which will provide connections to whoever has been waiting
>>>> the longest, which helps avoid unnecessary errors caused by serving
>>>> requests out of order.
>>>> 
>>>> John
>>>> 
>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:
>>>> 
>>>>> Well, I'm not sure what you are using to run your web application, but
>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>>>>> give it the JNDI name, then configure the container to provide the DB
>>>>> connection.
>>>>> 
>>>>> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>>> 
>>>>> mrg
>>>>> 
>>>>> 
>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>>> 
>>>>>> Hi Michael,
>>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>>> just
>>>>>> a different method of looking up connection information?
>>>>>> 
>>>>>> But I probably can’t use it anyway since one of the apps is a WebObjects
>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>>> 
>>>>>> Thanks,
>>>>>> - hugi
>>>>>> 
>>>>>> 
>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>>> wrote:
>>>>>>> 
>>>>>>> Hi Hugi,
>>>>>>> 
>>>>>>> Since this appears to be a web-based application, can you switch to
>>>>> using
>>>>>>> JNDI?
>>>>>>> 
>>>>>>> mrg
>>>>>>> 
>>>>>>> 
>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>> wrote:
>>>>>>> 
>>>>>>>> Hi all,
>>>>>>>> This is still happening, even after I added a validationQuery, our app
>>>>>> is
>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>>>>> there
>>>>>>>> any way for me to catch where connections are being opened in the code
>>>>>> and
>>>>>>>> at what location they’re hanging?
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>>> 
>>>>>>>> Cheer,
>>>>>>>> - hugi
>>>>>>>> 
>>>>>>>> // Hugi Thordarson
>>>>>>>> // http://www.loftfar.is/
>>>>>>>> // s. 895-6688
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>> wrote:
>>>>>>>>>> 
>>>>>>>>>> What does validationQuery do?
>>>>>>>>> 
>>>>>>>>> Periodically executes for each pooled connection, and kills
>>>>> connections
>>>>>>>> that throw during validation. So it ensures that all pooled
>>>>> connections
>>>>>> are
>>>>>>>> in a good state.
>>>>>>>>> 
>>>>>>>>> Andrus
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>> 
>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
>>> Unless you use Bootique, or your own property-based config mechanism.
>> 
>> Is bootique worth checking out? I’m just noticing it now for the first time and so happens I’m looking into a new basis for our web services/APIs (current favorite being spark framework).
> 
> Definitely. Bootique is a new project, and my hope is it will make it as far as Cayenne and further. I am doing a presentation at WOWODC this summer and at ApacheCon in May. In a few words, it is a flexible modular framework (or platform?) that allows you to build Java apps that run without containers (hence the jar/war meme that that I quoted from SpringBoo folks). It is very easy to create web services [1] and such, but also apps of any type and complexity. There's a Cayenne integration module, as well a dozen other modules (the list is quickly growing).
> 
> For those who haven't seen it yet, we just launched a new site at http://bootique.io/ .

Looks nice! Definitely checking it out.

- hugi

Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Mar 7, 2016, at 1:27 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Unless you use Bootique, or your own property-based config mechanism.
> 
> Is bootique worth checking out? I’m just noticing it now for the first time and so happens I’m looking into a new basis for our web services/APIs (current favorite being spark framework).

Definitely. Bootique is a new project, and my hope is it will make it as far as Cayenne and further. I am doing a presentation at WOWODC this summer and at ApacheCon in May. In a few words, it is a flexible modular framework (or platform?) that allows you to build Java apps that run without containers (hence the jar/war meme that that I quoted from SpringBoo folks). It is very easy to create web services [1] and such, but also apps of any type and complexity. There's a Cayenne integration module, as well a dozen other modules (the list is quickly growing).

For those who haven't seen it yet, we just launched a new site at http://bootique.io/ .

Andrus

[1] http://bootique.io/docs/0/getting-started/index.html


Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
Simple bash scripts. Much easier then container deployment.

scp my.jar my.server:/tmp
ssh my.server java -jar /tmp/my.jar &
ssh my.server pkill my.jar

Andrus

> On Mar 7, 2016, at 2:41 PM, Lon Varscsak <lo...@gmail.com> wrote:
> 
> lol, the name makes it seem like a joke. :P  Unfortunately (not really) we
> deploy internally.
> 
> On Mon, Mar 7, 2016 at 3:38 PM, John Huss <jo...@gmail.com> wrote:
> 
>> Amazon elastic beanstalk!
>> On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak <lo...@gmail.com>
>> wrote:
>> 
>>> Well, I actually have embedded Jetty in my application.  But I’m not sure
>>> how to manage creating instances/stoping/starting, etc.  In WebObjects we
>>> had a tool called Monitor which would allow you to do it all on the fly.
>>> :D
>>> 
>>> -Lon
>>> 
>>> On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mg...@masslight.net>
>>> wrote:
>>> 
>>>> 
>> http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
>>>> 
>>>> (sent too soon)
>>>> 
>>>> 
>>>> On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mg...@masslight.net>
>>>> wrote:
>>>> 
>>>>> Just embed Jetty in your application...
>>>>> 
>>>>> 
>>>>> On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com
>>> 
>>>>> wrote:
>>>>> 
>>>>>> OT: I’m planning to build jar not war…now I’m not sure how to
>> deploy.
>>> :P
>>>>>> 
>>>>>> -Lon
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>> wrote:
>>>>>> 
>>>>>>>>> It looks to me like this makes it much harder to deploy your
>>>>>>> application in
>>>>>>>>> development/test/etc type environments since your URL/etc are
>> in
>>>> the
>>>>>>> code.
>>>>>>> 
>>>>>>> Yeah, I see what you mean. We use a homebuilt property system for
>>> that
>>>>>>> which returns configuration based on environment. It’s not JNDI
>> but
>>>>>> works :)
>>>>>>> 
>>>>>>>> Unless you use Bootique, or your own property-based config
>>>> mechanism.
>>>>>>> 
>>>>>>> Is bootique worth checking out? I’m just noticing it now for the
>>> first
>>>>>>> time and so happens I’m looking into a new basis for our web
>>>>>> services/APIs
>>>>>>> (current favorite being spark framework).
>>>>>>> 
>>>>>>>> "Make jar, not war" :)
>>>>>>> 
>>>>>>> Ha ha ha :)
>>>>>>> 
>>>>>>> - hugi
>>>>>>> 
>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Mar 7, 2016, at 1:13 PM, Michael Gentry <
>>> mgentry@masslight.net>
>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Hi Hugi,
>>>>>>>>> 
>>>>>>>>> It looks to me like this makes it much harder to deploy your
>>>>>>> application in
>>>>>>>>> development/test/etc type environments since your URL/etc are
>> in
>>>> the
>>>>>>> code.
>>>>>>>>> The advantage of JNDI is you only reference a logical name that
>>> is
>>>>>>>>> configured external to the WAR, making it much easier to have
>> one
>>>>>> build
>>>>>>>>> that can be deployed in different environments.  I took a brief
>>>>>> glance
>>>>>>> at
>>>>>>>>> Hikari and don't think it includes JNDI natively.
>>>>>>>>> 
>>>>>>>>> mrg
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
>>> hugi@karlmenn.is>
>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>> Well, that was easy! Up and running in production.
>>>>>>>>>> 
>>>>>>>>>> HikariConfig config = new HikariConfig();
>>>>>>>>>> config.setJdbcUrl(
>>>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>> 
>>> 
>> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
>>>>>>>>>> );
>>>>>>>>>> config.setUsername( “myUsername" );
>>>>>>>>>> config.setPassword( “myPassword" );
>>>>>>>>>> 
>>>>>>>>>> HikariDataSource dataSource = new HikariDataSource( config );
>>>>>>>>>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
>>> dataSource
>>>>>> );
>>>>>>>>>> 
>>>>>>>>>> Thanks,
>>>>>>>>>> - hugi
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <
>>>> andrus@objectstyle.org
>>>>>>> 
>>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> Yep. Cayenne built-in pool is intentionally basic with a
>>> minimal
>>>>>>> number
>>>>>>>>>> of features (Here we may be dealing with a bug though, and I'd
>>>> like
>>>>>> to
>>>>>>> fix
>>>>>>>>>> it, but that's a separate issue). So yeah, using a third party
>>> DS
>>>>>> may
>>>>>>> be a
>>>>>>>>>> good idea. Here is an example how you can set it up:
>>>>>>>>>>> 
>>>>>>>>>>> DataSource ds = // instantiate it via API specific to you DS
>>>>>> provider
>>>>>>>>>>> 
>>>>>>>>>>> ServerRuntime runtime =
>>>>>>>>>> ServerRuntimeBuilder.builder().dataSource(ds).build();
>>>>>>>>>>> // of course add any other things you need to add to the
>>> builder
>>>> to
>>>>>>> get
>>>>>>>>>> a working Cayenne stack.
>>>>>>>>>>> 
>>>>>>>>>>> Andrus
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <
>>> hugi@karlmenn.is>
>>>>>>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>> Thanks John! I’m going to try my hand at HikariCP.
>>>>>>>>>>>> 
>>>>>>>>>>>> Are there any examples anywhere on how to configure Cayenne
>> to
>>>>>> use a
>>>>>>>>>> third party connection pool?
>>>>>>>>>>>> 
>>>>>>>>>>>> Cheers,
>>>>>>>>>>>> - hugi
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com>
>>>>>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>> EOF can do JNDI, but that's not going to do anything to fix
>>>> your
>>>>>>>>>> problem.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> The connection pool in cayenne had some changes somewhat
>>>>>> recently so
>>>>>>>>>> it's
>>>>>>>>>>>>> entirely possible there are bugs.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> In practice it turns out many people don't use the
>> connection
>>>>>> pool
>>>>>>>>>> built-in
>>>>>>>>>>>>> to Cayenne at all, and rather use a third-party connection
>>>> pool,
>>>>>> of
>>>>>>>>>> which
>>>>>>>>>>>>> there are several.  The cayenne one is decent, but it is
>> very
>>>>>>> limited
>>>>>>>>>> in
>>>>>>>>>>>>> functionality and less robust due to having a smaller user
>>> base
>>>>>> and
>>>>>>>>>> being a
>>>>>>>>>>>>> non-core feature.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> You can use another pool like:
>>>>>>>>>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If
>> I
>>>> was
>>>>>>>>>> starting a
>>>>>>>>>>>>> new project I'd use this
>>>>>>>>>>>>> tomcat-jdbc <
>>>>>>> https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
>>>>>>>>>> -
>>>>>>>>>>>>> This is what I currently use
>>>>>>>>>>>>> commonds-dbcp <
>>> https://commons.apache.org/proper/commons-dbcp/
>>>>> 
>>>>>>>>>>>>> c3po <http://www.mchange.com/projects/c3p0/>
>>>>>>>>>>>>> 
>>>>>>>>>>>>> The main reason I turned to a third-party connection pool
>> was
>>>> to
>>>>>> get
>>>>>>>>>>>>> fair-scheduling which will provide connections to whoever
>> has
>>>>>> been
>>>>>>>>>> waiting
>>>>>>>>>>>>> the longest, which helps avoid unnecessary errors caused by
>>>>>> serving
>>>>>>>>>>>>> requests out of order.
>>>>>>>>>>>>> 
>>>>>>>>>>>>> John
>>>>>>>>>>>>> 
>>>>>>>>>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
>>>>>>> mgentry@masslight.net>
>>>>>>>>>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Well, I'm not sure what you are using to run your web
>>>>>> application,
>>>>>>> but
>>>>>>>>>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide
>>> JNDI
>>>>>>> lookups
>>>>>>>>>> of DB
>>>>>>>>>>>>>> connection pools.  You just tell Cayenne Modeler to use
>> JNDI
>>>>>> lookup
>>>>>>>>>> and
>>>>>>>>>>>>>> give it the JNDI name, then configure the container to
>>> provide
>>>>>> the
>>>>>>> DB
>>>>>>>>>>>>>> connection.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Is your WO application using EOF or Cayenne?  Been a while
>>>>>> since I
>>>>>>>>>> used WO,
>>>>>>>>>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as
>> well.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> mrg
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
>>>>>> hugi@karlmenn.is>
>>>>>>>>>> wrote:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Hi Michael,
>>>>>>>>>>>>>>> does using JNDI change anything about the connection
>>> itself,
>>>>>>> isn’t it
>>>>>>>>>>>>>> just
>>>>>>>>>>>>>>> a different method of looking up connection information?
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> But I probably can’t use it anyway since one of the apps
>>> is a
>>>>>>>>>> WebObjects
>>>>>>>>>>>>>>> app and doesn’t provide a JNDI service (at least I’ve
>> never
>>>>>> used
>>>>>>> it).
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>>> - hugi
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <
>>>>>> mgentry@masslight.net
>>>>>>>> 
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Hi Hugi,
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Since this appears to be a web-based application, can
>> you
>>>>>> switch
>>>>>>> to
>>>>>>>>>>>>>> using
>>>>>>>>>>>>>>>> JNDI?
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> mrg
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
>>>>>>> hugi@karlmenn.is>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> Hi all,
>>>>>>>>>>>>>>>>> This is still happening, even after I added a
>>>>>> validationQuery,
>>>>>>> our
>>>>>>>>>> app
>>>>>>>>>>>>>>> is
>>>>>>>>>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to
>>> debug
>>>>>>> this,
>>>>>>>>>> is
>>>>>>>>>>>>>>> there
>>>>>>>>>>>>>>>>> any way for me to catch where connections are being
>>> opened
>>>> in
>>>>>>> the
>>>>>>>>>> code
>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>> at what location they’re hanging?
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>> 
>>> 
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> Cheer,
>>>>>>>>>>>>>>>>> - hugi
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> // Hugi Thordarson
>>>>>>>>>>>>>>>>> // http://www.loftfar.is/
>>>>>>>>>>>>>>>>> // s. 895-6688
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
>>>>>>>>>> andrus@objectstyle.org>
>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
>>>>>>> hugi@karlmenn.is>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>>> What does validationQuery do?
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Periodically executes for each pooled connection, and
>>>> kills
>>>>>>>>>>>>>> connections
>>>>>>>>>>>>>>>>> that throw during validation. So it ensures that all
>>> pooled
>>>>>>>>>>>>>> connections
>>>>>>>>>>>>>>> are
>>>>>>>>>>>>>>>>> in a good state.
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>>> Andrus
>>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 


Re: Reconnecting automatically after DB downtime

Posted by Lon Varscsak <lo...@gmail.com>.
lol, the name makes it seem like a joke. :P  Unfortunately (not really) we
deploy internally.

On Mon, Mar 7, 2016 at 3:38 PM, John Huss <jo...@gmail.com> wrote:

> Amazon elastic beanstalk!
> On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak <lo...@gmail.com>
> wrote:
>
> > Well, I actually have embedded Jetty in my application.  But I’m not sure
> > how to manage creating instances/stoping/starting, etc.  In WebObjects we
> > had a tool called Monitor which would allow you to do it all on the fly.
> > :D
> >
> > -Lon
> >
> > On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mg...@masslight.net>
> > wrote:
> >
> > >
> http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
> > >
> > > (sent too soon)
> > >
> > >
> > > On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mg...@masslight.net>
> > > wrote:
> > >
> > > > Just embed Jetty in your application...
> > > >
> > > >
> > > > On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com
> >
> > > > wrote:
> > > >
> > > >> OT: I’m planning to build jar not war…now I’m not sure how to
> deploy.
> > :P
> > > >>
> > > >> -Lon
> > > >>
> > > >> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is>
> > > wrote:
> > > >>
> > > >> > >> It looks to me like this makes it much harder to deploy your
> > > >> > application in
> > > >> > >> development/test/etc type environments since your URL/etc are
> in
> > > the
> > > >> > code.
> > > >> >
> > > >> > Yeah, I see what you mean. We use a homebuilt property system for
> > that
> > > >> > which returns configuration based on environment. It’s not JNDI
> but
> > > >> works :)
> > > >> >
> > > >> > > Unless you use Bootique, or your own property-based config
> > > mechanism.
> > > >> >
> > > >> > Is bootique worth checking out? I’m just noticing it now for the
> > first
> > > >> > time and so happens I’m looking into a new basis for our web
> > > >> services/APIs
> > > >> > (current favorite being spark framework).
> > > >> >
> > > >> > > "Make jar, not war" :)
> > > >> >
> > > >> > Ha ha ha :)
> > > >> >
> > > >> > - hugi
> > > >> >
> > > >> >
> > > >> > >
> > > >> > >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <
> > mgentry@masslight.net>
> > > >> > wrote:
> > > >> > >>
> > > >> > >> Hi Hugi,
> > > >> > >>
> > > >> > >> It looks to me like this makes it much harder to deploy your
> > > >> > application in
> > > >> > >> development/test/etc type environments since your URL/etc are
> in
> > > the
> > > >> > code.
> > > >> > >> The advantage of JNDI is you only reference a logical name that
> > is
> > > >> > >> configured external to the WAR, making it much easier to have
> one
> > > >> build
> > > >> > >> that can be deployed in different environments.  I took a brief
> > > >> glance
> > > >> > at
> > > >> > >> Hikari and don't think it includes JNDI natively.
> > > >> > >>
> > > >> > >> mrg
> > > >> > >>
> > > >> > >>
> > > >> > >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
> > hugi@karlmenn.is>
> > > >> > wrote:
> > > >> > >>
> > > >> > >>> Well, that was easy! Up and running in production.
> > > >> > >>>
> > > >> > >>> HikariConfig config = new HikariConfig();
> > > >> > >>> config.setJdbcUrl(
> > > >> > >>>
> > > >> >
> > > >>
> > >
> >
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> > > >> > >>> );
> > > >> > >>> config.setUsername( “myUsername" );
> > > >> > >>> config.setPassword( “myPassword" );
> > > >> > >>>
> > > >> > >>> HikariDataSource dataSource = new HikariDataSource( config );
> > > >> > >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
> > dataSource
> > > >> );
> > > >> > >>>
> > > >> > >>> Thanks,
> > > >> > >>> - hugi
> > > >> > >>>
> > > >> > >>>
> > > >> > >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <
> > > andrus@objectstyle.org
> > > >> >
> > > >> > >>> wrote:
> > > >> > >>>>
> > > >> > >>>> Yep. Cayenne built-in pool is intentionally basic with a
> > minimal
> > > >> > number
> > > >> > >>> of features (Here we may be dealing with a bug though, and I'd
> > > like
> > > >> to
> > > >> > fix
> > > >> > >>> it, but that's a separate issue). So yeah, using a third party
> > DS
> > > >> may
> > > >> > be a
> > > >> > >>> good idea. Here is an example how you can set it up:
> > > >> > >>>>
> > > >> > >>>> DataSource ds = // instantiate it via API specific to you DS
> > > >> provider
> > > >> > >>>>
> > > >> > >>>> ServerRuntime runtime =
> > > >> > >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
> > > >> > >>>> // of course add any other things you need to add to the
> > builder
> > > to
> > > >> > get
> > > >> > >>> a working Cayenne stack.
> > > >> > >>>>
> > > >> > >>>> Andrus
> > > >> > >>>>
> > > >> > >>>>
> > > >> > >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <
> > hugi@karlmenn.is>
> > > >> > wrote:
> > > >> > >>>>>
> > > >> > >>>>> Thanks John! I’m going to try my hand at HikariCP.
> > > >> > >>>>>
> > > >> > >>>>> Are there any examples anywhere on how to configure Cayenne
> to
> > > >> use a
> > > >> > >>> third party connection pool?
> > > >> > >>>>>
> > > >> > >>>>> Cheers,
> > > >> > >>>>> - hugi
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>
> > > >> > >>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com>
> > > >> wrote:
> > > >> > >>>>>>
> > > >> > >>>>>> EOF can do JNDI, but that's not going to do anything to fix
> > > your
> > > >> > >>> problem.
> > > >> > >>>>>>
> > > >> > >>>>>> The connection pool in cayenne had some changes somewhat
> > > >> recently so
> > > >> > >>> it's
> > > >> > >>>>>> entirely possible there are bugs.
> > > >> > >>>>>>
> > > >> > >>>>>> In practice it turns out many people don't use the
> connection
> > > >> pool
> > > >> > >>> built-in
> > > >> > >>>>>> to Cayenne at all, and rather use a third-party connection
> > > pool,
> > > >> of
> > > >> > >>> which
> > > >> > >>>>>> there are several.  The cayenne one is decent, but it is
> very
> > > >> > limited
> > > >> > >>> in
> > > >> > >>>>>> functionality and less robust due to having a smaller user
> > base
> > > >> and
> > > >> > >>> being a
> > > >> > >>>>>> non-core feature.
> > > >> > >>>>>>
> > > >> > >>>>>> You can use another pool like:
> > > >> > >>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If
> I
> > > was
> > > >> > >>> starting a
> > > >> > >>>>>> new project I'd use this
> > > >> > >>>>>> tomcat-jdbc <
> > > >> > https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> > > >> > >>> -
> > > >> > >>>>>> This is what I currently use
> > > >> > >>>>>> commonds-dbcp <
> > https://commons.apache.org/proper/commons-dbcp/
> > > >
> > > >> > >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
> > > >> > >>>>>>
> > > >> > >>>>>> The main reason I turned to a third-party connection pool
> was
> > > to
> > > >> get
> > > >> > >>>>>> fair-scheduling which will provide connections to whoever
> has
> > > >> been
> > > >> > >>> waiting
> > > >> > >>>>>> the longest, which helps avoid unnecessary errors caused by
> > > >> serving
> > > >> > >>>>>> requests out of order.
> > > >> > >>>>>>
> > > >> > >>>>>> John
> > > >> > >>>>>>
> > > >> > >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
> > > >> > mgentry@masslight.net>
> > > >> > >>> wrote:
> > > >> > >>>>>>
> > > >> > >>>>>>> Well, I'm not sure what you are using to run your web
> > > >> application,
> > > >> > but
> > > >> > >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide
> > JNDI
> > > >> > lookups
> > > >> > >>> of DB
> > > >> > >>>>>>> connection pools.  You just tell Cayenne Modeler to use
> JNDI
> > > >> lookup
> > > >> > >>> and
> > > >> > >>>>>>> give it the JNDI name, then configure the container to
> > provide
> > > >> the
> > > >> > DB
> > > >> > >>>>>>> connection.
> > > >> > >>>>>>>
> > > >> > >>>>>>> Is your WO application using EOF or Cayenne?  Been a while
> > > >> since I
> > > >> > >>> used WO,
> > > >> > >>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as
> well.
> > > >> > >>>>>>>
> > > >> > >>>>>>> mrg
> > > >> > >>>>>>>
> > > >> > >>>>>>>
> > > >> > >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
> > > >> hugi@karlmenn.is>
> > > >> > >>> wrote:
> > > >> > >>>>>>>
> > > >> > >>>>>>>> Hi Michael,
> > > >> > >>>>>>>> does using JNDI change anything about the connection
> > itself,
> > > >> > isn’t it
> > > >> > >>>>>>> just
> > > >> > >>>>>>>> a different method of looking up connection information?
> > > >> > >>>>>>>>
> > > >> > >>>>>>>> But I probably can’t use it anyway since one of the apps
> > is a
> > > >> > >>> WebObjects
> > > >> > >>>>>>>> app and doesn’t provide a JNDI service (at least I’ve
> never
> > > >> used
> > > >> > it).
> > > >> > >>>>>>>>
> > > >> > >>>>>>>> Thanks,
> > > >> > >>>>>>>> - hugi
> > > >> > >>>>>>>>
> > > >> > >>>>>>>>
> > > >> > >>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <
> > > >> mgentry@masslight.net
> > > >> > >
> > > >> > >>>>>>> wrote:
> > > >> > >>>>>>>>>
> > > >> > >>>>>>>>> Hi Hugi,
> > > >> > >>>>>>>>>
> > > >> > >>>>>>>>> Since this appears to be a web-based application, can
> you
> > > >> switch
> > > >> > to
> > > >> > >>>>>>> using
> > > >> > >>>>>>>>> JNDI?
> > > >> > >>>>>>>>>
> > > >> > >>>>>>>>> mrg
> > > >> > >>>>>>>>>
> > > >> > >>>>>>>>>
> > > >> > >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
> > > >> > hugi@karlmenn.is>
> > > >> > >>>>>>>> wrote:
> > > >> > >>>>>>>>>
> > > >> > >>>>>>>>>> Hi all,
> > > >> > >>>>>>>>>> This is still happening, even after I added a
> > > >> validationQuery,
> > > >> > our
> > > >> > >>> app
> > > >> > >>>>>>>> is
> > > >> > >>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to
> > debug
> > > >> > this,
> > > >> > >>> is
> > > >> > >>>>>>>> there
> > > >> > >>>>>>>>>> any way for me to catch where connections are being
> > opened
> > > in
> > > >> > the
> > > >> > >>> code
> > > >> > >>>>>>>> and
> > > >> > >>>>>>>>>> at what location they’re hanging?
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>
> > > >> > >>>>>>>
> > > >> > >>>
> > > >> >
> > > >>
> > >
> >
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>> Cheer,
> > > >> > >>>>>>>>>> - hugi
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>> // Hugi Thordarson
> > > >> > >>>>>>>>>> // http://www.loftfar.is/
> > > >> > >>>>>>>>>> // s. 895-6688
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> > > >> > >>> andrus@objectstyle.org>
> > > >> > >>>>>>>>>> wrote:
> > > >> > >>>>>>>>>>>
> > > >> > >>>>>>>>>>>
> > > >> > >>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
> > > >> > hugi@karlmenn.is>
> > > >> > >>>>>>>> wrote:
> > > >> > >>>>>>>>>>>>
> > > >> > >>>>>>>>>>>> What does validationQuery do?
> > > >> > >>>>>>>>>>>
> > > >> > >>>>>>>>>>> Periodically executes for each pooled connection, and
> > > kills
> > > >> > >>>>>>> connections
> > > >> > >>>>>>>>>> that throw during validation. So it ensures that all
> > pooled
> > > >> > >>>>>>> connections
> > > >> > >>>>>>>> are
> > > >> > >>>>>>>>>> in a good state.
> > > >> > >>>>>>>>>>>
> > > >> > >>>>>>>>>>> Andrus
> > > >> > >>>>>>>>>>>
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>>>
> > > >> > >>>>>>>>
> > > >> > >>>>>>>>
> > > >> > >>>>>>>
> > > >> > >>>>>
> > > >> > >>>>
> > > >> > >>>
> > > >> > >>>
> > > >> > >
> > > >> >
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Re: Reconnecting automatically after DB downtime

Posted by John Huss <jo...@gmail.com>.
Amazon elastic beanstalk!
On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak <lo...@gmail.com> wrote:

> Well, I actually have embedded Jetty in my application.  But I’m not sure
> how to manage creating instances/stoping/starting, etc.  In WebObjects we
> had a tool called Monitor which would allow you to do it all on the fly.
> :D
>
> -Lon
>
> On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mg...@masslight.net>
> wrote:
>
> > http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
> >
> > (sent too soon)
> >
> >
> > On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mg...@masslight.net>
> > wrote:
> >
> > > Just embed Jetty in your application...
> > >
> > >
> > > On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lo...@gmail.com>
> > > wrote:
> > >
> > >> OT: I’m planning to build jar not war…now I’m not sure how to deploy.
> :P
> > >>
> > >> -Lon
> > >>
> > >> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is>
> > wrote:
> > >>
> > >> > >> It looks to me like this makes it much harder to deploy your
> > >> > application in
> > >> > >> development/test/etc type environments since your URL/etc are in
> > the
> > >> > code.
> > >> >
> > >> > Yeah, I see what you mean. We use a homebuilt property system for
> that
> > >> > which returns configuration based on environment. It’s not JNDI but
> > >> works :)
> > >> >
> > >> > > Unless you use Bootique, or your own property-based config
> > mechanism.
> > >> >
> > >> > Is bootique worth checking out? I’m just noticing it now for the
> first
> > >> > time and so happens I’m looking into a new basis for our web
> > >> services/APIs
> > >> > (current favorite being spark framework).
> > >> >
> > >> > > "Make jar, not war" :)
> > >> >
> > >> > Ha ha ha :)
> > >> >
> > >> > - hugi
> > >> >
> > >> >
> > >> > >
> > >> > >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <
> mgentry@masslight.net>
> > >> > wrote:
> > >> > >>
> > >> > >> Hi Hugi,
> > >> > >>
> > >> > >> It looks to me like this makes it much harder to deploy your
> > >> > application in
> > >> > >> development/test/etc type environments since your URL/etc are in
> > the
> > >> > code.
> > >> > >> The advantage of JNDI is you only reference a logical name that
> is
> > >> > >> configured external to the WAR, making it much easier to have one
> > >> build
> > >> > >> that can be deployed in different environments.  I took a brief
> > >> glance
> > >> > at
> > >> > >> Hikari and don't think it includes JNDI natively.
> > >> > >>
> > >> > >> mrg
> > >> > >>
> > >> > >>
> > >> > >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
> hugi@karlmenn.is>
> > >> > wrote:
> > >> > >>
> > >> > >>> Well, that was easy! Up and running in production.
> > >> > >>>
> > >> > >>> HikariConfig config = new HikariConfig();
> > >> > >>> config.setJdbcUrl(
> > >> > >>>
> > >> >
> > >>
> >
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> > >> > >>> );
> > >> > >>> config.setUsername( “myUsername" );
> > >> > >>> config.setPassword( “myPassword" );
> > >> > >>>
> > >> > >>> HikariDataSource dataSource = new HikariDataSource( config );
> > >> > >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
> dataSource
> > >> );
> > >> > >>>
> > >> > >>> Thanks,
> > >> > >>> - hugi
> > >> > >>>
> > >> > >>>
> > >> > >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <
> > andrus@objectstyle.org
> > >> >
> > >> > >>> wrote:
> > >> > >>>>
> > >> > >>>> Yep. Cayenne built-in pool is intentionally basic with a
> minimal
> > >> > number
> > >> > >>> of features (Here we may be dealing with a bug though, and I'd
> > like
> > >> to
> > >> > fix
> > >> > >>> it, but that's a separate issue). So yeah, using a third party
> DS
> > >> may
> > >> > be a
> > >> > >>> good idea. Here is an example how you can set it up:
> > >> > >>>>
> > >> > >>>> DataSource ds = // instantiate it via API specific to you DS
> > >> provider
> > >> > >>>>
> > >> > >>>> ServerRuntime runtime =
> > >> > >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
> > >> > >>>> // of course add any other things you need to add to the
> builder
> > to
> > >> > get
> > >> > >>> a working Cayenne stack.
> > >> > >>>>
> > >> > >>>> Andrus
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <
> hugi@karlmenn.is>
> > >> > wrote:
> > >> > >>>>>
> > >> > >>>>> Thanks John! I’m going to try my hand at HikariCP.
> > >> > >>>>>
> > >> > >>>>> Are there any examples anywhere on how to configure Cayenne to
> > >> use a
> > >> > >>> third party connection pool?
> > >> > >>>>>
> > >> > >>>>> Cheers,
> > >> > >>>>> - hugi
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com>
> > >> wrote:
> > >> > >>>>>>
> > >> > >>>>>> EOF can do JNDI, but that's not going to do anything to fix
> > your
> > >> > >>> problem.
> > >> > >>>>>>
> > >> > >>>>>> The connection pool in cayenne had some changes somewhat
> > >> recently so
> > >> > >>> it's
> > >> > >>>>>> entirely possible there are bugs.
> > >> > >>>>>>
> > >> > >>>>>> In practice it turns out many people don't use the connection
> > >> pool
> > >> > >>> built-in
> > >> > >>>>>> to Cayenne at all, and rather use a third-party connection
> > pool,
> > >> of
> > >> > >>> which
> > >> > >>>>>> there are several.  The cayenne one is decent, but it is very
> > >> > limited
> > >> > >>> in
> > >> > >>>>>> functionality and less robust due to having a smaller user
> base
> > >> and
> > >> > >>> being a
> > >> > >>>>>> non-core feature.
> > >> > >>>>>>
> > >> > >>>>>> You can use another pool like:
> > >> > >>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I
> > was
> > >> > >>> starting a
> > >> > >>>>>> new project I'd use this
> > >> > >>>>>> tomcat-jdbc <
> > >> > https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> > >> > >>> -
> > >> > >>>>>> This is what I currently use
> > >> > >>>>>> commonds-dbcp <
> https://commons.apache.org/proper/commons-dbcp/
> > >
> > >> > >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
> > >> > >>>>>>
> > >> > >>>>>> The main reason I turned to a third-party connection pool was
> > to
> > >> get
> > >> > >>>>>> fair-scheduling which will provide connections to whoever has
> > >> been
> > >> > >>> waiting
> > >> > >>>>>> the longest, which helps avoid unnecessary errors caused by
> > >> serving
> > >> > >>>>>> requests out of order.
> > >> > >>>>>>
> > >> > >>>>>> John
> > >> > >>>>>>
> > >> > >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
> > >> > mgentry@masslight.net>
> > >> > >>> wrote:
> > >> > >>>>>>
> > >> > >>>>>>> Well, I'm not sure what you are using to run your web
> > >> application,
> > >> > but
> > >> > >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide
> JNDI
> > >> > lookups
> > >> > >>> of DB
> > >> > >>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI
> > >> lookup
> > >> > >>> and
> > >> > >>>>>>> give it the JNDI name, then configure the container to
> provide
> > >> the
> > >> > DB
> > >> > >>>>>>> connection.
> > >> > >>>>>>>
> > >> > >>>>>>> Is your WO application using EOF or Cayenne?  Been a while
> > >> since I
> > >> > >>> used WO,
> > >> > >>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> > >> > >>>>>>>
> > >> > >>>>>>> mrg
> > >> > >>>>>>>
> > >> > >>>>>>>
> > >> > >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
> > >> hugi@karlmenn.is>
> > >> > >>> wrote:
> > >> > >>>>>>>
> > >> > >>>>>>>> Hi Michael,
> > >> > >>>>>>>> does using JNDI change anything about the connection
> itself,
> > >> > isn’t it
> > >> > >>>>>>> just
> > >> > >>>>>>>> a different method of looking up connection information?
> > >> > >>>>>>>>
> > >> > >>>>>>>> But I probably can’t use it anyway since one of the apps
> is a
> > >> > >>> WebObjects
> > >> > >>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never
> > >> used
> > >> > it).
> > >> > >>>>>>>>
> > >> > >>>>>>>> Thanks,
> > >> > >>>>>>>> - hugi
> > >> > >>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <
> > >> mgentry@masslight.net
> > >> > >
> > >> > >>>>>>> wrote:
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> Hi Hugi,
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> Since this appears to be a web-based application, can you
> > >> switch
> > >> > to
> > >> > >>>>>>> using
> > >> > >>>>>>>>> JNDI?
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> mrg
> > >> > >>>>>>>>>
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
> > >> > hugi@karlmenn.is>
> > >> > >>>>>>>> wrote:
> > >> > >>>>>>>>>
> > >> > >>>>>>>>>> Hi all,
> > >> > >>>>>>>>>> This is still happening, even after I added a
> > >> validationQuery,
> > >> > our
> > >> > >>> app
> > >> > >>>>>>>> is
> > >> > >>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to
> debug
> > >> > this,
> > >> > >>> is
> > >> > >>>>>>>> there
> > >> > >>>>>>>>>> any way for me to catch where connections are being
> opened
> > in
> > >> > the
> > >> > >>> code
> > >> > >>>>>>>> and
> > >> > >>>>>>>>>> at what location they’re hanging?
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>
> > >> > >>>
> > >> >
> > >>
> >
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>> Cheer,
> > >> > >>>>>>>>>> - hugi
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>> // Hugi Thordarson
> > >> > >>>>>>>>>> // http://www.loftfar.is/
> > >> > >>>>>>>>>> // s. 895-6688
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> > >> > >>> andrus@objectstyle.org>
> > >> > >>>>>>>>>> wrote:
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
> > >> > hugi@karlmenn.is>
> > >> > >>>>>>>> wrote:
> > >> > >>>>>>>>>>>>
> > >> > >>>>>>>>>>>> What does validationQuery do?
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>> Periodically executes for each pooled connection, and
> > kills
> > >> > >>>>>>> connections
> > >> > >>>>>>>>>> that throw during validation. So it ensures that all
> pooled
> > >> > >>>>>>> connections
> > >> > >>>>>>>> are
> > >> > >>>>>>>>>> in a good state.
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>> Andrus
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>
> > >> > >>>>>
> > >> > >>>>
> > >> > >>>
> > >> > >>>
> > >> > >
> > >> >
> > >> >
> > >>
> > >
> > >
> >
>

Re: Reconnecting automatically after DB downtime

Posted by Lon Varscsak <lo...@gmail.com>.
Well, I actually have embedded Jetty in my application.  But I’m not sure
how to manage creating instances/stoping/starting, etc.  In WebObjects we
had a tool called Monitor which would allow you to do it all on the fly.  :D

-Lon

On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mg...@masslight.net>
wrote:

> http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
>
> (sent too soon)
>
>
> On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mg...@masslight.net>
> wrote:
>
> > Just embed Jetty in your application...
> >
> >
> > On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lo...@gmail.com>
> > wrote:
> >
> >> OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P
> >>
> >> -Lon
> >>
> >> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>
> >> > >> It looks to me like this makes it much harder to deploy your
> >> > application in
> >> > >> development/test/etc type environments since your URL/etc are in
> the
> >> > code.
> >> >
> >> > Yeah, I see what you mean. We use a homebuilt property system for that
> >> > which returns configuration based on environment. It’s not JNDI but
> >> works :)
> >> >
> >> > > Unless you use Bootique, or your own property-based config
> mechanism.
> >> >
> >> > Is bootique worth checking out? I’m just noticing it now for the first
> >> > time and so happens I’m looking into a new basis for our web
> >> services/APIs
> >> > (current favorite being spark framework).
> >> >
> >> > > "Make jar, not war" :)
> >> >
> >> > Ha ha ha :)
> >> >
> >> > - hugi
> >> >
> >> >
> >> > >
> >> > >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net>
> >> > wrote:
> >> > >>
> >> > >> Hi Hugi,
> >> > >>
> >> > >> It looks to me like this makes it much harder to deploy your
> >> > application in
> >> > >> development/test/etc type environments since your URL/etc are in
> the
> >> > code.
> >> > >> The advantage of JNDI is you only reference a logical name that is
> >> > >> configured external to the WAR, making it much easier to have one
> >> build
> >> > >> that can be deployed in different environments.  I took a brief
> >> glance
> >> > at
> >> > >> Hikari and don't think it includes JNDI natively.
> >> > >>
> >> > >> mrg
> >> > >>
> >> > >>
> >> > >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is>
> >> > wrote:
> >> > >>
> >> > >>> Well, that was easy! Up and running in production.
> >> > >>>
> >> > >>> HikariConfig config = new HikariConfig();
> >> > >>> config.setJdbcUrl(
> >> > >>>
> >> >
> >>
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> >> > >>> );
> >> > >>> config.setUsername( “myUsername" );
> >> > >>> config.setPassword( “myPassword" );
> >> > >>>
> >> > >>> HikariDataSource dataSource = new HikariDataSource( config );
> >> > >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource
> >> );
> >> > >>>
> >> > >>> Thanks,
> >> > >>> - hugi
> >> > >>>
> >> > >>>
> >> > >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <
> andrus@objectstyle.org
> >> >
> >> > >>> wrote:
> >> > >>>>
> >> > >>>> Yep. Cayenne built-in pool is intentionally basic with a minimal
> >> > number
> >> > >>> of features (Here we may be dealing with a bug though, and I'd
> like
> >> to
> >> > fix
> >> > >>> it, but that's a separate issue). So yeah, using a third party DS
> >> may
> >> > be a
> >> > >>> good idea. Here is an example how you can set it up:
> >> > >>>>
> >> > >>>> DataSource ds = // instantiate it via API specific to you DS
> >> provider
> >> > >>>>
> >> > >>>> ServerRuntime runtime =
> >> > >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
> >> > >>>> // of course add any other things you need to add to the builder
> to
> >> > get
> >> > >>> a working Cayenne stack.
> >> > >>>>
> >> > >>>> Andrus
> >> > >>>>
> >> > >>>>
> >> > >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is>
> >> > wrote:
> >> > >>>>>
> >> > >>>>> Thanks John! I’m going to try my hand at HikariCP.
> >> > >>>>>
> >> > >>>>> Are there any examples anywhere on how to configure Cayenne to
> >> use a
> >> > >>> third party connection pool?
> >> > >>>>>
> >> > >>>>> Cheers,
> >> > >>>>> - hugi
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>
> >> > >>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com>
> >> wrote:
> >> > >>>>>>
> >> > >>>>>> EOF can do JNDI, but that's not going to do anything to fix
> your
> >> > >>> problem.
> >> > >>>>>>
> >> > >>>>>> The connection pool in cayenne had some changes somewhat
> >> recently so
> >> > >>> it's
> >> > >>>>>> entirely possible there are bugs.
> >> > >>>>>>
> >> > >>>>>> In practice it turns out many people don't use the connection
> >> pool
> >> > >>> built-in
> >> > >>>>>> to Cayenne at all, and rather use a third-party connection
> pool,
> >> of
> >> > >>> which
> >> > >>>>>> there are several.  The cayenne one is decent, but it is very
> >> > limited
> >> > >>> in
> >> > >>>>>> functionality and less robust due to having a smaller user base
> >> and
> >> > >>> being a
> >> > >>>>>> non-core feature.
> >> > >>>>>>
> >> > >>>>>> You can use another pool like:
> >> > >>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I
> was
> >> > >>> starting a
> >> > >>>>>> new project I'd use this
> >> > >>>>>> tomcat-jdbc <
> >> > https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> >> > >>> -
> >> > >>>>>> This is what I currently use
> >> > >>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/
> >
> >> > >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
> >> > >>>>>>
> >> > >>>>>> The main reason I turned to a third-party connection pool was
> to
> >> get
> >> > >>>>>> fair-scheduling which will provide connections to whoever has
> >> been
> >> > >>> waiting
> >> > >>>>>> the longest, which helps avoid unnecessary errors caused by
> >> serving
> >> > >>>>>> requests out of order.
> >> > >>>>>>
> >> > >>>>>> John
> >> > >>>>>>
> >> > >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
> >> > mgentry@masslight.net>
> >> > >>> wrote:
> >> > >>>>>>
> >> > >>>>>>> Well, I'm not sure what you are using to run your web
> >> application,
> >> > but
> >> > >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
> >> > lookups
> >> > >>> of DB
> >> > >>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI
> >> lookup
> >> > >>> and
> >> > >>>>>>> give it the JNDI name, then configure the container to provide
> >> the
> >> > DB
> >> > >>>>>>> connection.
> >> > >>>>>>>
> >> > >>>>>>> Is your WO application using EOF or Cayenne?  Been a while
> >> since I
> >> > >>> used WO,
> >> > >>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> >> > >>>>>>>
> >> > >>>>>>> mrg
> >> > >>>>>>>
> >> > >>>>>>>
> >> > >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
> >> hugi@karlmenn.is>
> >> > >>> wrote:
> >> > >>>>>>>
> >> > >>>>>>>> Hi Michael,
> >> > >>>>>>>> does using JNDI change anything about the connection itself,
> >> > isn’t it
> >> > >>>>>>> just
> >> > >>>>>>>> a different method of looking up connection information?
> >> > >>>>>>>>
> >> > >>>>>>>> But I probably can’t use it anyway since one of the apps is a
> >> > >>> WebObjects
> >> > >>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never
> >> used
> >> > it).
> >> > >>>>>>>>
> >> > >>>>>>>> Thanks,
> >> > >>>>>>>> - hugi
> >> > >>>>>>>>
> >> > >>>>>>>>
> >> > >>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <
> >> mgentry@masslight.net
> >> > >
> >> > >>>>>>> wrote:
> >> > >>>>>>>>>
> >> > >>>>>>>>> Hi Hugi,
> >> > >>>>>>>>>
> >> > >>>>>>>>> Since this appears to be a web-based application, can you
> >> switch
> >> > to
> >> > >>>>>>> using
> >> > >>>>>>>>> JNDI?
> >> > >>>>>>>>>
> >> > >>>>>>>>> mrg
> >> > >>>>>>>>>
> >> > >>>>>>>>>
> >> > >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
> >> > hugi@karlmenn.is>
> >> > >>>>>>>> wrote:
> >> > >>>>>>>>>
> >> > >>>>>>>>>> Hi all,
> >> > >>>>>>>>>> This is still happening, even after I added a
> >> validationQuery,
> >> > our
> >> > >>> app
> >> > >>>>>>>> is
> >> > >>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug
> >> > this,
> >> > >>> is
> >> > >>>>>>>> there
> >> > >>>>>>>>>> any way for me to catch where connections are being opened
> in
> >> > the
> >> > >>> code
> >> > >>>>>>>> and
> >> > >>>>>>>>>> at what location they’re hanging?
> >> > >>>>>>>>>>
> >> > >>>>>>>>>>
> >> > >>>>>>>>>>
> >> > >>>>>>>>
> >> > >>>>>>>
> >> > >>>
> >> >
> >>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> >> > >>>>>>>>>>
> >> > >>>>>>>>>> Cheer,
> >> > >>>>>>>>>> - hugi
> >> > >>>>>>>>>>
> >> > >>>>>>>>>> // Hugi Thordarson
> >> > >>>>>>>>>> // http://www.loftfar.is/
> >> > >>>>>>>>>> // s. 895-6688
> >> > >>>>>>>>>>
> >> > >>>>>>>>>>
> >> > >>>>>>>>>>
> >> > >>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> >> > >>> andrus@objectstyle.org>
> >> > >>>>>>>>>> wrote:
> >> > >>>>>>>>>>>
> >> > >>>>>>>>>>>
> >> > >>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
> >> > hugi@karlmenn.is>
> >> > >>>>>>>> wrote:
> >> > >>>>>>>>>>>>
> >> > >>>>>>>>>>>> What does validationQuery do?
> >> > >>>>>>>>>>>
> >> > >>>>>>>>>>> Periodically executes for each pooled connection, and
> kills
> >> > >>>>>>> connections
> >> > >>>>>>>>>> that throw during validation. So it ensures that all pooled
> >> > >>>>>>> connections
> >> > >>>>>>>> are
> >> > >>>>>>>>>> in a good state.
> >> > >>>>>>>>>>>
> >> > >>>>>>>>>>> Andrus
> >> > >>>>>>>>>>>
> >> > >>>>>>>>>>
> >> > >>>>>>>>>>
> >> > >>>>>>>>
> >> > >>>>>>>>
> >> > >>>>>>>
> >> > >>>>>
> >> > >>>>
> >> > >>>
> >> > >>>
> >> > >
> >> >
> >> >
> >>
> >
> >
>

Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html

(sent too soon)


On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mg...@masslight.net>
wrote:

> Just embed Jetty in your application...
>
>
> On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lo...@gmail.com>
> wrote:
>
>> OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P
>>
>> -Lon
>>
>> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>
>> > >> It looks to me like this makes it much harder to deploy your
>> > application in
>> > >> development/test/etc type environments since your URL/etc are in the
>> > code.
>> >
>> > Yeah, I see what you mean. We use a homebuilt property system for that
>> > which returns configuration based on environment. It’s not JNDI but
>> works :)
>> >
>> > > Unless you use Bootique, or your own property-based config mechanism.
>> >
>> > Is bootique worth checking out? I’m just noticing it now for the first
>> > time and so happens I’m looking into a new basis for our web
>> services/APIs
>> > (current favorite being spark framework).
>> >
>> > > "Make jar, not war" :)
>> >
>> > Ha ha ha :)
>> >
>> > - hugi
>> >
>> >
>> > >
>> > >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net>
>> > wrote:
>> > >>
>> > >> Hi Hugi,
>> > >>
>> > >> It looks to me like this makes it much harder to deploy your
>> > application in
>> > >> development/test/etc type environments since your URL/etc are in the
>> > code.
>> > >> The advantage of JNDI is you only reference a logical name that is
>> > >> configured external to the WAR, making it much easier to have one
>> build
>> > >> that can be deployed in different environments.  I took a brief
>> glance
>> > at
>> > >> Hikari and don't think it includes JNDI natively.
>> > >>
>> > >> mrg
>> > >>
>> > >>
>> > >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is>
>> > wrote:
>> > >>
>> > >>> Well, that was easy! Up and running in production.
>> > >>>
>> > >>> HikariConfig config = new HikariConfig();
>> > >>> config.setJdbcUrl(
>> > >>>
>> >
>> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
>> > >>> );
>> > >>> config.setUsername( “myUsername" );
>> > >>> config.setPassword( “myPassword" );
>> > >>>
>> > >>> HikariDataSource dataSource = new HikariDataSource( config );
>> > >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource
>> );
>> > >>>
>> > >>> Thanks,
>> > >>> - hugi
>> > >>>
>> > >>>
>> > >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <andrus@objectstyle.org
>> >
>> > >>> wrote:
>> > >>>>
>> > >>>> Yep. Cayenne built-in pool is intentionally basic with a minimal
>> > number
>> > >>> of features (Here we may be dealing with a bug though, and I'd like
>> to
>> > fix
>> > >>> it, but that's a separate issue). So yeah, using a third party DS
>> may
>> > be a
>> > >>> good idea. Here is an example how you can set it up:
>> > >>>>
>> > >>>> DataSource ds = // instantiate it via API specific to you DS
>> provider
>> > >>>>
>> > >>>> ServerRuntime runtime =
>> > >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
>> > >>>> // of course add any other things you need to add to the builder to
>> > get
>> > >>> a working Cayenne stack.
>> > >>>>
>> > >>>> Andrus
>> > >>>>
>> > >>>>
>> > >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is>
>> > wrote:
>> > >>>>>
>> > >>>>> Thanks John! I’m going to try my hand at HikariCP.
>> > >>>>>
>> > >>>>> Are there any examples anywhere on how to configure Cayenne to
>> use a
>> > >>> third party connection pool?
>> > >>>>>
>> > >>>>> Cheers,
>> > >>>>> - hugi
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>
>> > >>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com>
>> wrote:
>> > >>>>>>
>> > >>>>>> EOF can do JNDI, but that's not going to do anything to fix your
>> > >>> problem.
>> > >>>>>>
>> > >>>>>> The connection pool in cayenne had some changes somewhat
>> recently so
>> > >>> it's
>> > >>>>>> entirely possible there are bugs.
>> > >>>>>>
>> > >>>>>> In practice it turns out many people don't use the connection
>> pool
>> > >>> built-in
>> > >>>>>> to Cayenne at all, and rather use a third-party connection pool,
>> of
>> > >>> which
>> > >>>>>> there are several.  The cayenne one is decent, but it is very
>> > limited
>> > >>> in
>> > >>>>>> functionality and less robust due to having a smaller user base
>> and
>> > >>> being a
>> > >>>>>> non-core feature.
>> > >>>>>>
>> > >>>>>> You can use another pool like:
>> > >>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
>> > >>> starting a
>> > >>>>>> new project I'd use this
>> > >>>>>> tomcat-jdbc <
>> > https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
>> > >>> -
>> > >>>>>> This is what I currently use
>> > >>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>> > >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
>> > >>>>>>
>> > >>>>>> The main reason I turned to a third-party connection pool was to
>> get
>> > >>>>>> fair-scheduling which will provide connections to whoever has
>> been
>> > >>> waiting
>> > >>>>>> the longest, which helps avoid unnecessary errors caused by
>> serving
>> > >>>>>> requests out of order.
>> > >>>>>>
>> > >>>>>> John
>> > >>>>>>
>> > >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
>> > mgentry@masslight.net>
>> > >>> wrote:
>> > >>>>>>
>> > >>>>>>> Well, I'm not sure what you are using to run your web
>> application,
>> > but
>> > >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
>> > lookups
>> > >>> of DB
>> > >>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI
>> lookup
>> > >>> and
>> > >>>>>>> give it the JNDI name, then configure the container to provide
>> the
>> > DB
>> > >>>>>>> connection.
>> > >>>>>>>
>> > >>>>>>> Is your WO application using EOF or Cayenne?  Been a while
>> since I
>> > >>> used WO,
>> > >>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>> > >>>>>>>
>> > >>>>>>> mrg
>> > >>>>>>>
>> > >>>>>>>
>> > >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
>> hugi@karlmenn.is>
>> > >>> wrote:
>> > >>>>>>>
>> > >>>>>>>> Hi Michael,
>> > >>>>>>>> does using JNDI change anything about the connection itself,
>> > isn’t it
>> > >>>>>>> just
>> > >>>>>>>> a different method of looking up connection information?
>> > >>>>>>>>
>> > >>>>>>>> But I probably can’t use it anyway since one of the apps is a
>> > >>> WebObjects
>> > >>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never
>> used
>> > it).
>> > >>>>>>>>
>> > >>>>>>>> Thanks,
>> > >>>>>>>> - hugi
>> > >>>>>>>>
>> > >>>>>>>>
>> > >>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <
>> mgentry@masslight.net
>> > >
>> > >>>>>>> wrote:
>> > >>>>>>>>>
>> > >>>>>>>>> Hi Hugi,
>> > >>>>>>>>>
>> > >>>>>>>>> Since this appears to be a web-based application, can you
>> switch
>> > to
>> > >>>>>>> using
>> > >>>>>>>>> JNDI?
>> > >>>>>>>>>
>> > >>>>>>>>> mrg
>> > >>>>>>>>>
>> > >>>>>>>>>
>> > >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
>> > hugi@karlmenn.is>
>> > >>>>>>>> wrote:
>> > >>>>>>>>>
>> > >>>>>>>>>> Hi all,
>> > >>>>>>>>>> This is still happening, even after I added a
>> validationQuery,
>> > our
>> > >>> app
>> > >>>>>>>> is
>> > >>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug
>> > this,
>> > >>> is
>> > >>>>>>>> there
>> > >>>>>>>>>> any way for me to catch where connections are being opened in
>> > the
>> > >>> code
>> > >>>>>>>> and
>> > >>>>>>>>>> at what location they’re hanging?
>> > >>>>>>>>>>
>> > >>>>>>>>>>
>> > >>>>>>>>>>
>> > >>>>>>>>
>> > >>>>>>>
>> > >>>
>> >
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>> > >>>>>>>>>>
>> > >>>>>>>>>> Cheer,
>> > >>>>>>>>>> - hugi
>> > >>>>>>>>>>
>> > >>>>>>>>>> // Hugi Thordarson
>> > >>>>>>>>>> // http://www.loftfar.is/
>> > >>>>>>>>>> // s. 895-6688
>> > >>>>>>>>>>
>> > >>>>>>>>>>
>> > >>>>>>>>>>
>> > >>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
>> > >>> andrus@objectstyle.org>
>> > >>>>>>>>>> wrote:
>> > >>>>>>>>>>>
>> > >>>>>>>>>>>
>> > >>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
>> > hugi@karlmenn.is>
>> > >>>>>>>> wrote:
>> > >>>>>>>>>>>>
>> > >>>>>>>>>>>> What does validationQuery do?
>> > >>>>>>>>>>>
>> > >>>>>>>>>>> Periodically executes for each pooled connection, and kills
>> > >>>>>>> connections
>> > >>>>>>>>>> that throw during validation. So it ensures that all pooled
>> > >>>>>>> connections
>> > >>>>>>>> are
>> > >>>>>>>>>> in a good state.
>> > >>>>>>>>>>>
>> > >>>>>>>>>>> Andrus
>> > >>>>>>>>>>>
>> > >>>>>>>>>>
>> > >>>>>>>>>>
>> > >>>>>>>>
>> > >>>>>>>>
>> > >>>>>>>
>> > >>>>>
>> > >>>>
>> > >>>
>> > >>>
>> > >
>> >
>> >
>>
>
>

Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
Just embed Jetty in your application...


On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lo...@gmail.com> wrote:

> OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P
>
> -Lon
>
> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>
> > >> It looks to me like this makes it much harder to deploy your
> > application in
> > >> development/test/etc type environments since your URL/etc are in the
> > code.
> >
> > Yeah, I see what you mean. We use a homebuilt property system for that
> > which returns configuration based on environment. It’s not JNDI but
> works :)
> >
> > > Unless you use Bootique, or your own property-based config mechanism.
> >
> > Is bootique worth checking out? I’m just noticing it now for the first
> > time and so happens I’m looking into a new basis for our web
> services/APIs
> > (current favorite being spark framework).
> >
> > > "Make jar, not war" :)
> >
> > Ha ha ha :)
> >
> > - hugi
> >
> >
> > >
> > >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net>
> > wrote:
> > >>
> > >> Hi Hugi,
> > >>
> > >> It looks to me like this makes it much harder to deploy your
> > application in
> > >> development/test/etc type environments since your URL/etc are in the
> > code.
> > >> The advantage of JNDI is you only reference a logical name that is
> > >> configured external to the WAR, making it much easier to have one
> build
> > >> that can be deployed in different environments.  I took a brief glance
> > at
> > >> Hikari and don't think it includes JNDI natively.
> > >>
> > >> mrg
> > >>
> > >>
> > >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is>
> > wrote:
> > >>
> > >>> Well, that was easy! Up and running in production.
> > >>>
> > >>> HikariConfig config = new HikariConfig();
> > >>> config.setJdbcUrl(
> > >>>
> >
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> > >>> );
> > >>> config.setUsername( “myUsername" );
> > >>> config.setPassword( “myPassword" );
> > >>>
> > >>> HikariDataSource dataSource = new HikariDataSource( config );
> > >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
> > >>>
> > >>> Thanks,
> > >>> - hugi
> > >>>
> > >>>
> > >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org>
> > >>> wrote:
> > >>>>
> > >>>> Yep. Cayenne built-in pool is intentionally basic with a minimal
> > number
> > >>> of features (Here we may be dealing with a bug though, and I'd like
> to
> > fix
> > >>> it, but that's a separate issue). So yeah, using a third party DS may
> > be a
> > >>> good idea. Here is an example how you can set it up:
> > >>>>
> > >>>> DataSource ds = // instantiate it via API specific to you DS
> provider
> > >>>>
> > >>>> ServerRuntime runtime =
> > >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
> > >>>> // of course add any other things you need to add to the builder to
> > get
> > >>> a working Cayenne stack.
> > >>>>
> > >>>> Andrus
> > >>>>
> > >>>>
> > >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is>
> > wrote:
> > >>>>>
> > >>>>> Thanks John! I’m going to try my hand at HikariCP.
> > >>>>>
> > >>>>> Are there any examples anywhere on how to configure Cayenne to use
> a
> > >>> third party connection pool?
> > >>>>>
> > >>>>> Cheers,
> > >>>>> - hugi
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
> > >>>>>>
> > >>>>>> EOF can do JNDI, but that's not going to do anything to fix your
> > >>> problem.
> > >>>>>>
> > >>>>>> The connection pool in cayenne had some changes somewhat recently
> so
> > >>> it's
> > >>>>>> entirely possible there are bugs.
> > >>>>>>
> > >>>>>> In practice it turns out many people don't use the connection pool
> > >>> built-in
> > >>>>>> to Cayenne at all, and rather use a third-party connection pool,
> of
> > >>> which
> > >>>>>> there are several.  The cayenne one is decent, but it is very
> > limited
> > >>> in
> > >>>>>> functionality and less robust due to having a smaller user base
> and
> > >>> being a
> > >>>>>> non-core feature.
> > >>>>>>
> > >>>>>> You can use another pool like:
> > >>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
> > >>> starting a
> > >>>>>> new project I'd use this
> > >>>>>> tomcat-jdbc <
> > https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> > >>> -
> > >>>>>> This is what I currently use
> > >>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> > >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
> > >>>>>>
> > >>>>>> The main reason I turned to a third-party connection pool was to
> get
> > >>>>>> fair-scheduling which will provide connections to whoever has been
> > >>> waiting
> > >>>>>> the longest, which helps avoid unnecessary errors caused by
> serving
> > >>>>>> requests out of order.
> > >>>>>>
> > >>>>>> John
> > >>>>>>
> > >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
> > mgentry@masslight.net>
> > >>> wrote:
> > >>>>>>
> > >>>>>>> Well, I'm not sure what you are using to run your web
> application,
> > but
> > >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
> > lookups
> > >>> of DB
> > >>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI
> lookup
> > >>> and
> > >>>>>>> give it the JNDI name, then configure the container to provide
> the
> > DB
> > >>>>>>> connection.
> > >>>>>>>
> > >>>>>>> Is your WO application using EOF or Cayenne?  Been a while since
> I
> > >>> used WO,
> > >>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> > >>>>>>>
> > >>>>>>> mrg
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <
> hugi@karlmenn.is>
> > >>> wrote:
> > >>>>>>>
> > >>>>>>>> Hi Michael,
> > >>>>>>>> does using JNDI change anything about the connection itself,
> > isn’t it
> > >>>>>>> just
> > >>>>>>>> a different method of looking up connection information?
> > >>>>>>>>
> > >>>>>>>> But I probably can’t use it anyway since one of the apps is a
> > >>> WebObjects
> > >>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used
> > it).
> > >>>>>>>>
> > >>>>>>>> Thanks,
> > >>>>>>>> - hugi
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <
> mgentry@masslight.net
> > >
> > >>>>>>> wrote:
> > >>>>>>>>>
> > >>>>>>>>> Hi Hugi,
> > >>>>>>>>>
> > >>>>>>>>> Since this appears to be a web-based application, can you
> switch
> > to
> > >>>>>>> using
> > >>>>>>>>> JNDI?
> > >>>>>>>>>
> > >>>>>>>>> mrg
> > >>>>>>>>>
> > >>>>>>>>>
> > >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
> > hugi@karlmenn.is>
> > >>>>>>>> wrote:
> > >>>>>>>>>
> > >>>>>>>>>> Hi all,
> > >>>>>>>>>> This is still happening, even after I added a validationQuery,
> > our
> > >>> app
> > >>>>>>>> is
> > >>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug
> > this,
> > >>> is
> > >>>>>>>> there
> > >>>>>>>>>> any way for me to catch where connections are being opened in
> > the
> > >>> code
> > >>>>>>>> and
> > >>>>>>>>>> at what location they’re hanging?
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>
> > >>>>>>>
> > >>>
> >
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> > >>>>>>>>>>
> > >>>>>>>>>> Cheer,
> > >>>>>>>>>> - hugi
> > >>>>>>>>>>
> > >>>>>>>>>> // Hugi Thordarson
> > >>>>>>>>>> // http://www.loftfar.is/
> > >>>>>>>>>> // s. 895-6688
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> > >>> andrus@objectstyle.org>
> > >>>>>>>>>> wrote:
> > >>>>>>>>>>>
> > >>>>>>>>>>>
> > >>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
> > hugi@karlmenn.is>
> > >>>>>>>> wrote:
> > >>>>>>>>>>>>
> > >>>>>>>>>>>> What does validationQuery do?
> > >>>>>>>>>>>
> > >>>>>>>>>>> Periodically executes for each pooled connection, and kills
> > >>>>>>> connections
> > >>>>>>>>>> that throw during validation. So it ensures that all pooled
> > >>>>>>> connections
> > >>>>>>>> are
> > >>>>>>>>>> in a good state.
> > >>>>>>>>>>>
> > >>>>>>>>>>> Andrus
> > >>>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>>>
> > >>>>>>>>
> > >>>>>>>>
> > >>>>>>>
> > >>>>>
> > >>>>
> > >>>
> > >>>
> > >
> >
> >
>

Re: Reconnecting automatically after DB downtime

Posted by Lon Varscsak <lo...@gmail.com>.
OT: I’m planning to build jar not war…now I’m not sure how to deploy. :P

-Lon

On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> >> It looks to me like this makes it much harder to deploy your
> application in
> >> development/test/etc type environments since your URL/etc are in the
> code.
>
> Yeah, I see what you mean. We use a homebuilt property system for that
> which returns configuration based on environment. It’s not JNDI but works :)
>
> > Unless you use Bootique, or your own property-based config mechanism.
>
> Is bootique worth checking out? I’m just noticing it now for the first
> time and so happens I’m looking into a new basis for our web services/APIs
> (current favorite being spark framework).
>
> > "Make jar, not war" :)
>
> Ha ha ha :)
>
> - hugi
>
>
> >
> >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net>
> wrote:
> >>
> >> Hi Hugi,
> >>
> >> It looks to me like this makes it much harder to deploy your
> application in
> >> development/test/etc type environments since your URL/etc are in the
> code.
> >> The advantage of JNDI is you only reference a logical name that is
> >> configured external to the WAR, making it much easier to have one build
> >> that can be deployed in different environments.  I took a brief glance
> at
> >> Hikari and don't think it includes JNDI natively.
> >>
> >> mrg
> >>
> >>
> >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>
> >>> Well, that was easy! Up and running in production.
> >>>
> >>> HikariConfig config = new HikariConfig();
> >>> config.setJdbcUrl(
> >>>
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> >>> );
> >>> config.setUsername( “myUsername" );
> >>> config.setPassword( “myPassword" );
> >>>
> >>> HikariDataSource dataSource = new HikariDataSource( config );
> >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
> >>>
> >>> Thanks,
> >>> - hugi
> >>>
> >>>
> >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org>
> >>> wrote:
> >>>>
> >>>> Yep. Cayenne built-in pool is intentionally basic with a minimal
> number
> >>> of features (Here we may be dealing with a bug though, and I'd like to
> fix
> >>> it, but that's a separate issue). So yeah, using a third party DS may
> be a
> >>> good idea. Here is an example how you can set it up:
> >>>>
> >>>> DataSource ds = // instantiate it via API specific to you DS provider
> >>>>
> >>>> ServerRuntime runtime =
> >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
> >>>> // of course add any other things you need to add to the builder to
> get
> >>> a working Cayenne stack.
> >>>>
> >>>> Andrus
> >>>>
> >>>>
> >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>>>>
> >>>>> Thanks John! I’m going to try my hand at HikariCP.
> >>>>>
> >>>>> Are there any examples anywhere on how to configure Cayenne to use a
> >>> third party connection pool?
> >>>>>
> >>>>> Cheers,
> >>>>> - hugi
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
> >>>>>>
> >>>>>> EOF can do JNDI, but that's not going to do anything to fix your
> >>> problem.
> >>>>>>
> >>>>>> The connection pool in cayenne had some changes somewhat recently so
> >>> it's
> >>>>>> entirely possible there are bugs.
> >>>>>>
> >>>>>> In practice it turns out many people don't use the connection pool
> >>> built-in
> >>>>>> to Cayenne at all, and rather use a third-party connection pool, of
> >>> which
> >>>>>> there are several.  The cayenne one is decent, but it is very
> limited
> >>> in
> >>>>>> functionality and less robust due to having a smaller user base and
> >>> being a
> >>>>>> non-core feature.
> >>>>>>
> >>>>>> You can use another pool like:
> >>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
> >>> starting a
> >>>>>> new project I'd use this
> >>>>>> tomcat-jdbc <
> https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> >>> -
> >>>>>> This is what I currently use
> >>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
> >>>>>>
> >>>>>> The main reason I turned to a third-party connection pool was to get
> >>>>>> fair-scheduling which will provide connections to whoever has been
> >>> waiting
> >>>>>> the longest, which helps avoid unnecessary errors caused by serving
> >>>>>> requests out of order.
> >>>>>>
> >>>>>> John
> >>>>>>
> >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <
> mgentry@masslight.net>
> >>> wrote:
> >>>>>>
> >>>>>>> Well, I'm not sure what you are using to run your web application,
> but
> >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
> lookups
> >>> of DB
> >>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup
> >>> and
> >>>>>>> give it the JNDI name, then configure the container to provide the
> DB
> >>>>>>> connection.
> >>>>>>>
> >>>>>>> Is your WO application using EOF or Cayenne?  Been a while since I
> >>> used WO,
> >>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> >>>>>>>
> >>>>>>> mrg
> >>>>>>>
> >>>>>>>
> >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
> >>> wrote:
> >>>>>>>
> >>>>>>>> Hi Michael,
> >>>>>>>> does using JNDI change anything about the connection itself,
> isn’t it
> >>>>>>> just
> >>>>>>>> a different method of looking up connection information?
> >>>>>>>>
> >>>>>>>> But I probably can’t use it anyway since one of the apps is a
> >>> WebObjects
> >>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used
> it).
> >>>>>>>>
> >>>>>>>> Thanks,
> >>>>>>>> - hugi
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mgentry@masslight.net
> >
> >>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>> Hi Hugi,
> >>>>>>>>>
> >>>>>>>>> Since this appears to be a web-based application, can you switch
> to
> >>>>>>> using
> >>>>>>>>> JNDI?
> >>>>>>>>>
> >>>>>>>>> mrg
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <
> hugi@karlmenn.is>
> >>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> Hi all,
> >>>>>>>>>> This is still happening, even after I added a validationQuery,
> our
> >>> app
> >>>>>>>> is
> >>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug
> this,
> >>> is
> >>>>>>>> there
> >>>>>>>>>> any way for me to catch where connections are being opened in
> the
> >>> code
> >>>>>>>> and
> >>>>>>>>>> at what location they’re hanging?
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> >>>>>>>>>>
> >>>>>>>>>> Cheer,
> >>>>>>>>>> - hugi
> >>>>>>>>>>
> >>>>>>>>>> // Hugi Thordarson
> >>>>>>>>>> // http://www.loftfar.is/
> >>>>>>>>>> // s. 895-6688
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> >>> andrus@objectstyle.org>
> >>>>>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <
> hugi@karlmenn.is>
> >>>>>>>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>> What does validationQuery do?
> >>>>>>>>>>>
> >>>>>>>>>>> Periodically executes for each pooled connection, and kills
> >>>>>>> connections
> >>>>>>>>>> that throw during validation. So it ensures that all pooled
> >>>>>>> connections
> >>>>>>>> are
> >>>>>>>>>> in a good state.
> >>>>>>>>>>>
> >>>>>>>>>>> Andrus
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >
>
>

Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
>> It looks to me like this makes it much harder to deploy your application in
>> development/test/etc type environments since your URL/etc are in the code.

Yeah, I see what you mean. We use a homebuilt property system for that which returns configuration based on environment. It’s not JNDI but works :)

> Unless you use Bootique, or your own property-based config mechanism.

Is bootique worth checking out? I’m just noticing it now for the first time and so happens I’m looking into a new basis for our web services/APIs (current favorite being spark framework).

> "Make jar, not war" :)

Ha ha ha :)

- hugi


> 
>> On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net> wrote:
>> 
>> Hi Hugi,
>> 
>> It looks to me like this makes it much harder to deploy your application in
>> development/test/etc type environments since your URL/etc are in the code.
>> The advantage of JNDI is you only reference a logical name that is
>> configured external to the WAR, making it much easier to have one build
>> that can be deployed in different environments.  I took a brief glance at
>> Hikari and don't think it includes JNDI natively.
>> 
>> mrg
>> 
>> 
>> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>>> Well, that was easy! Up and running in production.
>>> 
>>> HikariConfig config = new HikariConfig();
>>> config.setJdbcUrl(
>>> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
>>> );
>>> config.setUsername( “myUsername" );
>>> config.setPassword( “myPassword" );
>>> 
>>> HikariDataSource dataSource = new HikariDataSource( config );
>>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
>>> 
>>> Thanks,
>>> - hugi
>>> 
>>> 
>>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org>
>>> wrote:
>>>> 
>>>> Yep. Cayenne built-in pool is intentionally basic with a minimal number
>>> of features (Here we may be dealing with a bug though, and I'd like to fix
>>> it, but that's a separate issue). So yeah, using a third party DS may be a
>>> good idea. Here is an example how you can set it up:
>>>> 
>>>> DataSource ds = // instantiate it via API specific to you DS provider
>>>> 
>>>> ServerRuntime runtime =
>>> ServerRuntimeBuilder.builder().dataSource(ds).build();
>>>> // of course add any other things you need to add to the builder to get
>>> a working Cayenne stack.
>>>> 
>>>> Andrus
>>>> 
>>>> 
>>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>>> 
>>>>> Thanks John! I’m going to try my hand at HikariCP.
>>>>> 
>>>>> Are there any examples anywhere on how to configure Cayenne to use a
>>> third party connection pool?
>>>>> 
>>>>> Cheers,
>>>>> - hugi
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>>>>> 
>>>>>> EOF can do JNDI, but that's not going to do anything to fix your
>>> problem.
>>>>>> 
>>>>>> The connection pool in cayenne had some changes somewhat recently so
>>> it's
>>>>>> entirely possible there are bugs.
>>>>>> 
>>>>>> In practice it turns out many people don't use the connection pool
>>> built-in
>>>>>> to Cayenne at all, and rather use a third-party connection pool, of
>>> which
>>>>>> there are several.  The cayenne one is decent, but it is very limited
>>> in
>>>>>> functionality and less robust due to having a smaller user base and
>>> being a
>>>>>> non-core feature.
>>>>>> 
>>>>>> You can use another pool like:
>>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
>>> starting a
>>>>>> new project I'd use this
>>>>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
>>> -
>>>>>> This is what I currently use
>>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>>>>> c3po <http://www.mchange.com/projects/c3p0/>
>>>>>> 
>>>>>> The main reason I turned to a third-party connection pool was to get
>>>>>> fair-scheduling which will provide connections to whoever has been
>>> waiting
>>>>>> the longest, which helps avoid unnecessary errors caused by serving
>>>>>> requests out of order.
>>>>>> 
>>>>>> John
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net>
>>> wrote:
>>>>>> 
>>>>>>> Well, I'm not sure what you are using to run your web application, but
>>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
>>> of DB
>>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup
>>> and
>>>>>>> give it the JNDI name, then configure the container to provide the DB
>>>>>>> connection.
>>>>>>> 
>>>>>>> Is your WO application using EOF or Cayenne?  Been a while since I
>>> used WO,
>>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>>>>> 
>>>>>>> mrg
>>>>>>> 
>>>>>>> 
>>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
>>> wrote:
>>>>>>> 
>>>>>>>> Hi Michael,
>>>>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>>>>> just
>>>>>>>> a different method of looking up connection information?
>>>>>>>> 
>>>>>>>> But I probably can’t use it anyway since one of the apps is a
>>> WebObjects
>>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>>>>> 
>>>>>>>> Thanks,
>>>>>>>> - hugi
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Hi Hugi,
>>>>>>>>> 
>>>>>>>>> Since this appears to be a web-based application, can you switch to
>>>>>>> using
>>>>>>>>> JNDI?
>>>>>>>>> 
>>>>>>>>> mrg
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>> Hi all,
>>>>>>>>>> This is still happening, even after I added a validationQuery, our
>>> app
>>>>>>>> is
>>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this,
>>> is
>>>>>>>> there
>>>>>>>>>> any way for me to catch where connections are being opened in the
>>> code
>>>>>>>> and
>>>>>>>>>> at what location they’re hanging?
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>>>>> 
>>>>>>>>>> Cheer,
>>>>>>>>>> - hugi
>>>>>>>>>> 
>>>>>>>>>> // Hugi Thordarson
>>>>>>>>>> // http://www.loftfar.is/
>>>>>>>>>> // s. 895-6688
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
>>> andrus@objectstyle.org>
>>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>>> wrote:
>>>>>>>>>>>> 
>>>>>>>>>>>> What does validationQuery do?
>>>>>>>>>>> 
>>>>>>>>>>> Periodically executes for each pooled connection, and kills
>>>>>>> connections
>>>>>>>>>> that throw during validation. So it ensures that all pooled
>>>>>>> connections
>>>>>>>> are
>>>>>>>>>> in a good state.
>>>>>>>>>>> 
>>>>>>>>>>> Andrus
>>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>> 
>>>> 
>>> 
>>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
I didn't name it!  :-)


On Mon, Mar 7, 2016 at 4:19 PM, Andrus Adamchik <an...@objectstyle.org>
wrote:

> > It looks to me like this makes it much harder to deploy your application
> in
> > development/test/etc type environments since your URL/etc are in the
> code.
>
> Unless you use Bootique, or your own property-based config mechanism.
> "Make jar, not war" :)
>
> Andrus
>
>
> > On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net>
> wrote:
> >
> > Hi Hugi,
> >
> > It looks to me like this makes it much harder to deploy your application
> in
> > development/test/etc type environments since your URL/etc are in the
> code.
> > The advantage of JNDI is you only reference a logical name that is
> > configured external to the WAR, making it much easier to have one build
> > that can be deployed in different environments.  I took a brief glance at
> > Hikari and don't think it includes JNDI natively.
> >
> > mrg
> >
> >
> > On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >
> >> Well, that was easy! Up and running in production.
> >>
> >> HikariConfig config = new HikariConfig();
> >> config.setJdbcUrl(
> >>
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> >> );
> >> config.setUsername( “myUsername" );
> >> config.setPassword( “myPassword" );
> >>
> >> HikariDataSource dataSource = new HikariDataSource( config );
> >> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
> >>
> >> Thanks,
> >> - hugi
> >>
> >>
> >>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org>
> >> wrote:
> >>>
> >>> Yep. Cayenne built-in pool is intentionally basic with a minimal number
> >> of features (Here we may be dealing with a bug though, and I'd like to
> fix
> >> it, but that's a separate issue). So yeah, using a third party DS may
> be a
> >> good idea. Here is an example how you can set it up:
> >>>
> >>> DataSource ds = // instantiate it via API specific to you DS provider
> >>>
> >>> ServerRuntime runtime =
> >> ServerRuntimeBuilder.builder().dataSource(ds).build();
> >>> // of course add any other things you need to add to the builder to get
> >> a working Cayenne stack.
> >>>
> >>> Andrus
> >>>
> >>>
> >>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>>>
> >>>> Thanks John! I’m going to try my hand at HikariCP.
> >>>>
> >>>> Are there any examples anywhere on how to configure Cayenne to use a
> >> third party connection pool?
> >>>>
> >>>> Cheers,
> >>>> - hugi
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
> >>>>>
> >>>>> EOF can do JNDI, but that's not going to do anything to fix your
> >> problem.
> >>>>>
> >>>>> The connection pool in cayenne had some changes somewhat recently so
> >> it's
> >>>>> entirely possible there are bugs.
> >>>>>
> >>>>> In practice it turns out many people don't use the connection pool
> >> built-in
> >>>>> to Cayenne at all, and rather use a third-party connection pool, of
> >> which
> >>>>> there are several.  The cayenne one is decent, but it is very limited
> >> in
> >>>>> functionality and less robust due to having a smaller user base and
> >> being a
> >>>>> non-core feature.
> >>>>>
> >>>>> You can use another pool like:
> >>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
> >> starting a
> >>>>> new project I'd use this
> >>>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
> >
> >> -
> >>>>> This is what I currently use
> >>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> >>>>> c3po <http://www.mchange.com/projects/c3p0/>
> >>>>>
> >>>>> The main reason I turned to a third-party connection pool was to get
> >>>>> fair-scheduling which will provide connections to whoever has been
> >> waiting
> >>>>> the longest, which helps avoid unnecessary errors caused by serving
> >>>>> requests out of order.
> >>>>>
> >>>>> John
> >>>>>
> >>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mgentry@masslight.net
> >
> >> wrote:
> >>>>>
> >>>>>> Well, I'm not sure what you are using to run your web application,
> but
> >>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI
> lookups
> >> of DB
> >>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup
> >> and
> >>>>>> give it the JNDI name, then configure the container to provide the
> DB
> >>>>>> connection.
> >>>>>>
> >>>>>> Is your WO application using EOF or Cayenne?  Been a while since I
> >> used WO,
> >>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> >>>>>>
> >>>>>> mrg
> >>>>>>
> >>>>>>
> >>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
> >> wrote:
> >>>>>>
> >>>>>>> Hi Michael,
> >>>>>>> does using JNDI change anything about the connection itself, isn’t
> it
> >>>>>> just
> >>>>>>> a different method of looking up connection information?
> >>>>>>>
> >>>>>>> But I probably can’t use it anyway since one of the apps is a
> >> WebObjects
> >>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used
> it).
> >>>>>>>
> >>>>>>> Thanks,
> >>>>>>> - hugi
> >>>>>>>
> >>>>>>>
> >>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
> >>>>>> wrote:
> >>>>>>>>
> >>>>>>>> Hi Hugi,
> >>>>>>>>
> >>>>>>>> Since this appears to be a web-based application, can you switch
> to
> >>>>>> using
> >>>>>>>> JNDI?
> >>>>>>>>
> >>>>>>>> mrg
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hugi@karlmenn.is
> >
> >>>>>>> wrote:
> >>>>>>>>
> >>>>>>>>> Hi all,
> >>>>>>>>> This is still happening, even after I added a validationQuery,
> our
> >> app
> >>>>>>> is
> >>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this,
> >> is
> >>>>>>> there
> >>>>>>>>> any way for me to catch where connections are being opened in the
> >> code
> >>>>>>> and
> >>>>>>>>> at what location they’re hanging?
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>
> >>>>>>
> >>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> >>>>>>>>>
> >>>>>>>>> Cheer,
> >>>>>>>>> - hugi
> >>>>>>>>>
> >>>>>>>>> // Hugi Thordarson
> >>>>>>>>> // http://www.loftfar.is/
> >>>>>>>>> // s. 895-6688
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> >> andrus@objectstyle.org>
> >>>>>>>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hugi@karlmenn.is
> >
> >>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>> What does validationQuery do?
> >>>>>>>>>>
> >>>>>>>>>> Periodically executes for each pooled connection, and kills
> >>>>>> connections
> >>>>>>>>> that throw during validation. So it ensures that all pooled
> >>>>>> connections
> >>>>>>> are
> >>>>>>>>> in a good state.
> >>>>>>>>>>
> >>>>>>>>>> Andrus
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>
> >>>
> >>
> >>
>
>

Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
> It looks to me like this makes it much harder to deploy your application in
> development/test/etc type environments since your URL/etc are in the code.

Unless you use Bootique, or your own property-based config mechanism. "Make jar, not war" :)

Andrus


> On Mar 7, 2016, at 1:13 PM, Michael Gentry <mg...@masslight.net> wrote:
> 
> Hi Hugi,
> 
> It looks to me like this makes it much harder to deploy your application in
> development/test/etc type environments since your URL/etc are in the code.
> The advantage of JNDI is you only reference a logical name that is
> configured external to the WAR, making it much easier to have one build
> that can be deployed in different environments.  I took a brief glance at
> Hikari and don't think it includes JNDI natively.
> 
> mrg
> 
> 
> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Well, that was easy! Up and running in production.
>> 
>> HikariConfig config = new HikariConfig();
>> config.setJdbcUrl(
>> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
>> );
>> config.setUsername( “myUsername" );
>> config.setPassword( “myPassword" );
>> 
>> HikariDataSource dataSource = new HikariDataSource( config );
>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
>> 
>> Thanks,
>> - hugi
>> 
>> 
>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org>
>> wrote:
>>> 
>>> Yep. Cayenne built-in pool is intentionally basic with a minimal number
>> of features (Here we may be dealing with a bug though, and I'd like to fix
>> it, but that's a separate issue). So yeah, using a third party DS may be a
>> good idea. Here is an example how you can set it up:
>>> 
>>> DataSource ds = // instantiate it via API specific to you DS provider
>>> 
>>> ServerRuntime runtime =
>> ServerRuntimeBuilder.builder().dataSource(ds).build();
>>> // of course add any other things you need to add to the builder to get
>> a working Cayenne stack.
>>> 
>>> Andrus
>>> 
>>> 
>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>> 
>>>> Thanks John! I’m going to try my hand at HikariCP.
>>>> 
>>>> Are there any examples anywhere on how to configure Cayenne to use a
>> third party connection pool?
>>>> 
>>>> Cheers,
>>>> - hugi
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>>>> 
>>>>> EOF can do JNDI, but that's not going to do anything to fix your
>> problem.
>>>>> 
>>>>> The connection pool in cayenne had some changes somewhat recently so
>> it's
>>>>> entirely possible there are bugs.
>>>>> 
>>>>> In practice it turns out many people don't use the connection pool
>> built-in
>>>>> to Cayenne at all, and rather use a third-party connection pool, of
>> which
>>>>> there are several.  The cayenne one is decent, but it is very limited
>> in
>>>>> functionality and less robust due to having a smaller user base and
>> being a
>>>>> non-core feature.
>>>>> 
>>>>> You can use another pool like:
>>>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
>> starting a
>>>>> new project I'd use this
>>>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
>> -
>>>>> This is what I currently use
>>>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>>>> c3po <http://www.mchange.com/projects/c3p0/>
>>>>> 
>>>>> The main reason I turned to a third-party connection pool was to get
>>>>> fair-scheduling which will provide connections to whoever has been
>> waiting
>>>>> the longest, which helps avoid unnecessary errors caused by serving
>>>>> requests out of order.
>>>>> 
>>>>> John
>>>>> 
>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net>
>> wrote:
>>>>> 
>>>>>> Well, I'm not sure what you are using to run your web application, but
>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
>> of DB
>>>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup
>> and
>>>>>> give it the JNDI name, then configure the container to provide the DB
>>>>>> connection.
>>>>>> 
>>>>>> Is your WO application using EOF or Cayenne?  Been a while since I
>> used WO,
>>>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>>>> 
>>>>>> mrg
>>>>>> 
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
>> wrote:
>>>>>> 
>>>>>>> Hi Michael,
>>>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>>>> just
>>>>>>> a different method of looking up connection information?
>>>>>>> 
>>>>>>> But I probably can’t use it anyway since one of the apps is a
>> WebObjects
>>>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>>>> 
>>>>>>> Thanks,
>>>>>>> - hugi
>>>>>>> 
>>>>>>> 
>>>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>>>> wrote:
>>>>>>>> 
>>>>>>>> Hi Hugi,
>>>>>>>> 
>>>>>>>> Since this appears to be a web-based application, can you switch to
>>>>>> using
>>>>>>>> JNDI?
>>>>>>>> 
>>>>>>>> mrg
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>> wrote:
>>>>>>>> 
>>>>>>>>> Hi all,
>>>>>>>>> This is still happening, even after I added a validationQuery, our
>> app
>>>>>>> is
>>>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this,
>> is
>>>>>>> there
>>>>>>>>> any way for me to catch where connections are being opened in the
>> code
>>>>>>> and
>>>>>>>>> at what location they’re hanging?
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>>> 
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>>>> 
>>>>>>>>> Cheer,
>>>>>>>>> - hugi
>>>>>>>>> 
>>>>>>>>> // Hugi Thordarson
>>>>>>>>> // http://www.loftfar.is/
>>>>>>>>> // s. 895-6688
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
>> andrus@objectstyle.org>
>>>>>>>>> wrote:
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>> What does validationQuery do?
>>>>>>>>>> 
>>>>>>>>>> Periodically executes for each pooled connection, and kills
>>>>>> connections
>>>>>>>>> that throw during validation. So it ensures that all pooled
>>>>>> connections
>>>>>>> are
>>>>>>>>> in a good state.
>>>>>>>>>> 
>>>>>>>>>> Andrus
>>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>> 
>>> 
>> 
>> 


Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
Hi Hugi,

It looks to me like this makes it much harder to deploy your application in
development/test/etc type environments since your URL/etc are in the code.
The advantage of JNDI is you only reference a logical name that is
configured external to the WAR, making it much easier to have one build
that can be deployed in different environments.  I took a brief glance at
Hikari and don't think it includes JNDI natively.

mrg


On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Well, that was easy! Up and running in production.
>
> HikariConfig config = new HikariConfig();
> config.setJdbcUrl(
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> );
> config.setUsername( “myUsername" );
> config.setPassword( “myPassword" );
>
> HikariDataSource dataSource = new HikariDataSource( config );
> serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );
>
> Thanks,
> - hugi
>
>
> > On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org>
> wrote:
> >
> > Yep. Cayenne built-in pool is intentionally basic with a minimal number
> of features (Here we may be dealing with a bug though, and I'd like to fix
> it, but that's a separate issue). So yeah, using a third party DS may be a
> good idea. Here is an example how you can set it up:
> >
> > DataSource ds = // instantiate it via API specific to you DS provider
> >
> > ServerRuntime runtime =
> ServerRuntimeBuilder.builder().dataSource(ds).build();
> > // of course add any other things you need to add to the builder to get
> a working Cayenne stack.
> >
> > Andrus
> >
> >
> >> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> >>
> >> Thanks John! I’m going to try my hand at HikariCP.
> >>
> >> Are there any examples anywhere on how to configure Cayenne to use a
> third party connection pool?
> >>
> >> Cheers,
> >> - hugi
> >>
> >>
> >>
> >>
> >>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
> >>>
> >>> EOF can do JNDI, but that's not going to do anything to fix your
> problem.
> >>>
> >>> The connection pool in cayenne had some changes somewhat recently so
> it's
> >>> entirely possible there are bugs.
> >>>
> >>> In practice it turns out many people don't use the connection pool
> built-in
> >>> to Cayenne at all, and rather use a third-party connection pool, of
> which
> >>> there are several.  The cayenne one is decent, but it is very limited
> in
> >>> functionality and less robust due to having a smaller user base and
> being a
> >>> non-core feature.
> >>>
> >>> You can use another pool like:
> >>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
> starting a
> >>> new project I'd use this
> >>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> -
> >>> This is what I currently use
> >>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> >>> c3po <http://www.mchange.com/projects/c3p0/>
> >>>
> >>> The main reason I turned to a third-party connection pool was to get
> >>> fair-scheduling which will provide connections to whoever has been
> waiting
> >>> the longest, which helps avoid unnecessary errors caused by serving
> >>> requests out of order.
> >>>
> >>> John
> >>>
> >>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net>
> wrote:
> >>>
> >>>> Well, I'm not sure what you are using to run your web application, but
> >>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
> of DB
> >>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup
> and
> >>>> give it the JNDI name, then configure the container to provide the DB
> >>>> connection.
> >>>>
> >>>> Is your WO application using EOF or Cayenne?  Been a while since I
> used WO,
> >>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> >>>>
> >>>> mrg
> >>>>
> >>>>
> >>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>>>
> >>>>> Hi Michael,
> >>>>> does using JNDI change anything about the connection itself, isn’t it
> >>>> just
> >>>>> a different method of looking up connection information?
> >>>>>
> >>>>> But I probably can’t use it anyway since one of the apps is a
> WebObjects
> >>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
> >>>>>
> >>>>> Thanks,
> >>>>> - hugi
> >>>>>
> >>>>>
> >>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
> >>>> wrote:
> >>>>>>
> >>>>>> Hi Hugi,
> >>>>>>
> >>>>>> Since this appears to be a web-based application, can you switch to
> >>>> using
> >>>>>> JNDI?
> >>>>>>
> >>>>>> mrg
> >>>>>>
> >>>>>>
> >>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
> >>>>> wrote:
> >>>>>>
> >>>>>>> Hi all,
> >>>>>>> This is still happening, even after I added a validationQuery, our
> app
> >>>>> is
> >>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this,
> is
> >>>>> there
> >>>>>>> any way for me to catch where connections are being opened in the
> code
> >>>>> and
> >>>>>>> at what location they’re hanging?
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>
> >>>>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> >>>>>>>
> >>>>>>> Cheer,
> >>>>>>> - hugi
> >>>>>>>
> >>>>>>> // Hugi Thordarson
> >>>>>>> // http://www.loftfar.is/
> >>>>>>> // s. 895-6688
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> andrus@objectstyle.org>
> >>>>>>> wrote:
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
> >>>>> wrote:
> >>>>>>>>>
> >>>>>>>>> What does validationQuery do?
> >>>>>>>>
> >>>>>>>> Periodically executes for each pooled connection, and kills
> >>>> connections
> >>>>>>> that throw during validation. So it ensures that all pooled
> >>>> connections
> >>>>> are
> >>>>>>> in a good state.
> >>>>>>>>
> >>>>>>>> Andrus
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>
> >>>>>
> >>>>
> >>
> >
>
>

Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Well, that was easy! Up and running in production.

HikariConfig config = new HikariConfig();
config.setJdbcUrl( "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0" );
config.setUsername( “myUsername" );
config.setPassword( “myPassword" );

HikariDataSource dataSource = new HikariDataSource( config );
serverRuntimeBuilder = serverRuntimeBuilder.dataSource( dataSource );

Thanks,
- hugi


> On 7. mar. 2016, at 20:51, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
> Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:
> 
> DataSource ds = // instantiate it via API specific to you DS provider
> 
> ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
> // of course add any other things you need to add to the builder to get a working Cayenne stack.
> 
> Andrus
> 
> 
>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>> Thanks John! I’m going to try my hand at HikariCP.
>> 
>> Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?
>> 
>> Cheers,
>> - hugi
>> 
>> 
>> 
>> 
>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>> 
>>> EOF can do JNDI, but that's not going to do anything to fix your problem.
>>> 
>>> The connection pool in cayenne had some changes somewhat recently so it's
>>> entirely possible there are bugs.
>>> 
>>> In practice it turns out many people don't use the connection pool built-in
>>> to Cayenne at all, and rather use a third-party connection pool, of which
>>> there are several.  The cayenne one is decent, but it is very limited in
>>> functionality and less robust due to having a smaller user base and being a
>>> non-core feature.
>>> 
>>> You can use another pool like:
>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
>>> new project I'd use this
>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
>>> This is what I currently use
>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>> c3po <http://www.mchange.com/projects/c3p0/>
>>> 
>>> The main reason I turned to a third-party connection pool was to get
>>> fair-scheduling which will provide connections to whoever has been waiting
>>> the longest, which helps avoid unnecessary errors caused by serving
>>> requests out of order.
>>> 
>>> John
>>> 
>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:
>>> 
>>>> Well, I'm not sure what you are using to run your web application, but
>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>>>> give it the JNDI name, then configure the container to provide the DB
>>>> connection.
>>>> 
>>>> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>> 
>>>> mrg
>>>> 
>>>> 
>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>> 
>>>>> Hi Michael,
>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>> just
>>>>> a different method of looking up connection information?
>>>>> 
>>>>> But I probably can’t use it anyway since one of the apps is a WebObjects
>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>> 
>>>>> Thanks,
>>>>> - hugi
>>>>> 
>>>>> 
>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>> wrote:
>>>>>> 
>>>>>> Hi Hugi,
>>>>>> 
>>>>>> Since this appears to be a web-based application, can you switch to
>>>> using
>>>>>> JNDI?
>>>>>> 
>>>>>> mrg
>>>>>> 
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>> wrote:
>>>>>> 
>>>>>>> Hi all,
>>>>>>> This is still happening, even after I added a validationQuery, our app
>>>>> is
>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>>>> there
>>>>>>> any way for me to catch where connections are being opened in the code
>>>>> and
>>>>>>> at what location they’re hanging?
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>> 
>>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>> 
>>>>>>> Cheer,
>>>>>>> - hugi
>>>>>>> 
>>>>>>> // Hugi Thordarson
>>>>>>> // http://www.loftfar.is/
>>>>>>> // s. 895-6688
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>>>>>>> wrote:
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> What does validationQuery do?
>>>>>>>> 
>>>>>>>> Periodically executes for each pooled connection, and kills
>>>> connections
>>>>>>> that throw during validation. So it ensures that all pooled
>>>> connections
>>>>> are
>>>>>>> in a good state.
>>>>>>>> 
>>>>>>>> Andrus
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>> 
>>>>> 
>>>> 
>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
Yep. Cayenne built-in pool is intentionally basic with a minimal number of features (Here we may be dealing with a bug though, and I'd like to fix it, but that's a separate issue). So yeah, using a third party DS may be a good idea. Here is an example how you can set it up:

DataSource ds = // instantiate it via API specific to you DS provider

ServerRuntime runtime = ServerRuntimeBuilder.builder().dataSource(ds).build();
// of course add any other things you need to add to the builder to get a working Cayenne stack.

Andrus


> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
> Thanks John! I’m going to try my hand at HikariCP.
> 
> Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?
> 
> Cheers,
> - hugi
> 
> 
> 
> 
>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>> 
>> EOF can do JNDI, but that's not going to do anything to fix your problem.
>> 
>> The connection pool in cayenne had some changes somewhat recently so it's
>> entirely possible there are bugs.
>> 
>> In practice it turns out many people don't use the connection pool built-in
>> to Cayenne at all, and rather use a third-party connection pool, of which
>> there are several.  The cayenne one is decent, but it is very limited in
>> functionality and less robust due to having a smaller user base and being a
>> non-core feature.
>> 
>> You can use another pool like:
>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
>> new project I'd use this
>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
>> This is what I currently use
>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>> c3po <http://www.mchange.com/projects/c3p0/>
>> 
>> The main reason I turned to a third-party connection pool was to get
>> fair-scheduling which will provide connections to whoever has been waiting
>> the longest, which helps avoid unnecessary errors caused by serving
>> requests out of order.
>> 
>> John
>> 
>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:
>> 
>>> Well, I'm not sure what you are using to run your web application, but
>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>>> give it the JNDI name, then configure the container to provide the DB
>>> connection.
>>> 
>>> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>> 
>>> mrg
>>> 
>>> 
>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>> 
>>>> Hi Michael,
>>>> does using JNDI change anything about the connection itself, isn’t it
>>> just
>>>> a different method of looking up connection information?
>>>> 
>>>> But I probably can’t use it anyway since one of the apps is a WebObjects
>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>> 
>>>> Thanks,
>>>> - hugi
>>>> 
>>>> 
>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>> wrote:
>>>>> 
>>>>> Hi Hugi,
>>>>> 
>>>>> Since this appears to be a web-based application, can you switch to
>>> using
>>>>> JNDI?
>>>>> 
>>>>> mrg
>>>>> 
>>>>> 
>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>> wrote:
>>>>> 
>>>>>> Hi all,
>>>>>> This is still happening, even after I added a validationQuery, our app
>>>> is
>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>>> there
>>>>>> any way for me to catch where connections are being opened in the code
>>>> and
>>>>>> at what location they’re hanging?
>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>> 
>>>>>> Cheer,
>>>>>> - hugi
>>>>>> 
>>>>>> // Hugi Thordarson
>>>>>> // http://www.loftfar.is/
>>>>>> // s. 895-6688
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>>>>>> wrote:
>>>>>>> 
>>>>>>> 
>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>> wrote:
>>>>>>>> 
>>>>>>>> What does validationQuery do?
>>>>>>> 
>>>>>>> Periodically executes for each pooled connection, and kills
>>> connections
>>>>>> that throw during validation. So it ensures that all pooled
>>> connections
>>>> are
>>>>>> in a good state.
>>>>>>> 
>>>>>>> Andrus
>>>>>>> 
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Thanks Michael, I chose to do this programmatically since I don’t think WO provides JNDI lookup (and my WO applications don’t run inside a container).
EOF does allow you to use JNDI, but I haven’t seen that used unless you’re running the WO application inside a container.

Cheers,
- hugi


> On 7. mar. 2016, at 20:54, Michael Gentry <mg...@masslight.net> wrote:
> 
> Cayenne is pretty easy.  In Cayenne Modeler, under the DataNode
> configuration, select the JNDI DataSource Factory option and give it a name
> like "jdbc/myDataSource".
> 
> Configuring Tomcat/Jetty/etc is a bit harder, but plenty of examples out
> there.  Which container are you using?
> 
> 
> On Mon, Mar 7, 2016 at 3:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Thanks John! I’m going to try my hand at HikariCP.
>> 
>> Are there any examples anywhere on how to configure Cayenne to use a third
>> party connection pool?
>> 
>> Cheers,
>> - hugi
>> 
>> 
>> 
>> 
>>> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
>>> 
>>> EOF can do JNDI, but that's not going to do anything to fix your problem.
>>> 
>>> The connection pool in cayenne had some changes somewhat recently so it's
>>> entirely possible there are bugs.
>>> 
>>> In practice it turns out many people don't use the connection pool
>> built-in
>>> to Cayenne at all, and rather use a third-party connection pool, of which
>>> there are several.  The cayenne one is decent, but it is very limited in
>>> functionality and less robust due to having a smaller user base and
>> being a
>>> non-core feature.
>>> 
>>> You can use another pool like:
>>> hikari <https://github.com/brettwooldridge/HikariCP> - If I was
>> starting a
>>> new project I'd use this
>>> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
>>> This is what I currently use
>>> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
>>> c3po <http://www.mchange.com/projects/c3p0/>
>>> 
>>> The main reason I turned to a third-party connection pool was to get
>>> fair-scheduling which will provide connections to whoever has been
>> waiting
>>> the longest, which helps avoid unnecessary errors caused by serving
>>> requests out of order.
>>> 
>>> John
>>> 
>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net>
>> wrote:
>>> 
>>>> Well, I'm not sure what you are using to run your web application, but
>>>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
>> of DB
>>>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>>>> give it the JNDI name, then configure the container to provide the DB
>>>> connection.
>>>> 
>>>> Is your WO application using EOF or Cayenne?  Been a while since I used
>> WO,
>>>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>>>> 
>>>> mrg
>>>> 
>>>> 
>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
>> wrote:
>>>> 
>>>>> Hi Michael,
>>>>> does using JNDI change anything about the connection itself, isn’t it
>>>> just
>>>>> a different method of looking up connection information?
>>>>> 
>>>>> But I probably can’t use it anyway since one of the apps is a
>> WebObjects
>>>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>>>> 
>>>>> Thanks,
>>>>> - hugi
>>>>> 
>>>>> 
>>>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>>>> wrote:
>>>>>> 
>>>>>> Hi Hugi,
>>>>>> 
>>>>>> Since this appears to be a web-based application, can you switch to
>>>> using
>>>>>> JNDI?
>>>>>> 
>>>>>> mrg
>>>>>> 
>>>>>> 
>>>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>>>> wrote:
>>>>>> 
>>>>>>> Hi all,
>>>>>>> This is still happening, even after I added a validationQuery, our
>> app
>>>>> is
>>>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>>>> there
>>>>>>> any way for me to catch where connections are being opened in the
>> code
>>>>> and
>>>>>>> at what location they’re hanging?
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>> 
>>>> 
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>>>> 
>>>>>>> Cheer,
>>>>>>> - hugi
>>>>>>> 
>>>>>>> // Hugi Thordarson
>>>>>>> // http://www.loftfar.is/
>>>>>>> // s. 895-6688
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org
>>> 
>>>>>>> wrote:
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> What does validationQuery do?
>>>>>>>> 
>>>>>>>> Periodically executes for each pooled connection, and kills
>>>> connections
>>>>>>> that throw during validation. So it ensures that all pooled
>>>> connections
>>>>> are
>>>>>>> in a good state.
>>>>>>>> 
>>>>>>>> Andrus
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>> 
>>>>> 
>>>> 
>> 
>> 


Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
Cayenne is pretty easy.  In Cayenne Modeler, under the DataNode
configuration, select the JNDI DataSource Factory option and give it a name
like "jdbc/myDataSource".

Configuring Tomcat/Jetty/etc is a bit harder, but plenty of examples out
there.  Which container are you using?


On Mon, Mar 7, 2016 at 3:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Thanks John! I’m going to try my hand at HikariCP.
>
> Are there any examples anywhere on how to configure Cayenne to use a third
> party connection pool?
>
> Cheers,
> - hugi
>
>
>
>
> > On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
> >
> > EOF can do JNDI, but that's not going to do anything to fix your problem.
> >
> > The connection pool in cayenne had some changes somewhat recently so it's
> > entirely possible there are bugs.
> >
> > In practice it turns out many people don't use the connection pool
> built-in
> > to Cayenne at all, and rather use a third-party connection pool, of which
> > there are several.  The cayenne one is decent, but it is very limited in
> > functionality and less robust due to having a smaller user base and
> being a
> > non-core feature.
> >
> > You can use another pool like:
> > hikari <https://github.com/brettwooldridge/HikariCP> - If I was
> starting a
> > new project I'd use this
> > tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
> > This is what I currently use
> > commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> > c3po <http://www.mchange.com/projects/c3p0/>
> >
> > The main reason I turned to a third-party connection pool was to get
> > fair-scheduling which will provide connections to whoever has been
> waiting
> > the longest, which helps avoid unnecessary errors caused by serving
> > requests out of order.
> >
> > John
> >
> > On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net>
> wrote:
> >
> >> Well, I'm not sure what you are using to run your web application, but
> >> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups
> of DB
> >> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
> >> give it the JNDI name, then configure the container to provide the DB
> >> connection.
> >>
> >> Is your WO application using EOF or Cayenne?  Been a while since I used
> WO,
> >> but I'd be stunned if EOF cannot use a JNDI lookup as well.
> >>
> >> mrg
> >>
> >>
> >> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>
> >>> Hi Michael,
> >>> does using JNDI change anything about the connection itself, isn’t it
> >> just
> >>> a different method of looking up connection information?
> >>>
> >>> But I probably can’t use it anyway since one of the apps is a
> WebObjects
> >>> app and doesn’t provide a JNDI service (at least I’ve never used it).
> >>>
> >>> Thanks,
> >>> - hugi
> >>>
> >>>
> >>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
> >> wrote:
> >>>>
> >>>> Hi Hugi,
> >>>>
> >>>> Since this appears to be a web-based application, can you switch to
> >> using
> >>>> JNDI?
> >>>>
> >>>> mrg
> >>>>
> >>>>
> >>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
> >>> wrote:
> >>>>
> >>>>> Hi all,
> >>>>> This is still happening, even after I added a validationQuery, our
> app
> >>> is
> >>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
> >>> there
> >>>>> any way for me to catch where connections are being opened in the
> code
> >>> and
> >>>>> at what location they’re hanging?
> >>>>>
> >>>>>
> >>>>>
> >>>
> >>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> >>>>>
> >>>>> Cheer,
> >>>>> - hugi
> >>>>>
> >>>>> // Hugi Thordarson
> >>>>> // http://www.loftfar.is/
> >>>>> // s. 895-6688
> >>>>>
> >>>>>
> >>>>>
> >>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <andrus@objectstyle.org
> >
> >>>>> wrote:
> >>>>>>
> >>>>>>
> >>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
> >>> wrote:
> >>>>>>>
> >>>>>>> What does validationQuery do?
> >>>>>>
> >>>>>> Periodically executes for each pooled connection, and kills
> >> connections
> >>>>> that throw during validation. So it ensures that all pooled
> >> connections
> >>> are
> >>>>> in a good state.
> >>>>>>
> >>>>>> Andrus
> >>>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >>
>
>

Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Thanks John! I’m going to try my hand at HikariCP.

Are there any examples anywhere on how to configure Cayenne to use a third party connection pool?

Cheers,
- hugi




> On 7. mar. 2016, at 20:39, John Huss <jo...@gmail.com> wrote:
> 
> EOF can do JNDI, but that's not going to do anything to fix your problem.
> 
> The connection pool in cayenne had some changes somewhat recently so it's
> entirely possible there are bugs.
> 
> In practice it turns out many people don't use the connection pool built-in
> to Cayenne at all, and rather use a third-party connection pool, of which
> there are several.  The cayenne one is decent, but it is very limited in
> functionality and less robust due to having a smaller user base and being a
> non-core feature.
> 
> You can use another pool like:
> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
> new project I'd use this
> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
> This is what I currently use
> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> c3po <http://www.mchange.com/projects/c3p0/>
> 
> The main reason I turned to a third-party connection pool was to get
> fair-scheduling which will provide connections to whoever has been waiting
> the longest, which helps avoid unnecessary errors caused by serving
> requests out of order.
> 
> John
> 
> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:
> 
>> Well, I'm not sure what you are using to run your web application, but
>> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
>> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
>> give it the JNDI name, then configure the container to provide the DB
>> connection.
>> 
>> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
>> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>> 
>> mrg
>> 
>> 
>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>>> Hi Michael,
>>> does using JNDI change anything about the connection itself, isn’t it
>> just
>>> a different method of looking up connection information?
>>> 
>>> But I probably can’t use it anyway since one of the apps is a WebObjects
>>> app and doesn’t provide a JNDI service (at least I’ve never used it).
>>> 
>>> Thanks,
>>> - hugi
>>> 
>>> 
>>>> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
>> wrote:
>>>> 
>>>> Hi Hugi,
>>>> 
>>>> Since this appears to be a web-based application, can you switch to
>> using
>>>> JNDI?
>>>> 
>>>> mrg
>>>> 
>>>> 
>>>> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
>>> wrote:
>>>> 
>>>>> Hi all,
>>>>> This is still happening, even after I added a validationQuery, our app
>>> is
>>>>> dying quite frequently :(.  I’m not quite sure how to debug this, is
>>> there
>>>>> any way for me to catch where connections are being opened in the code
>>> and
>>>>> at what location they’re hanging?
>>>>> 
>>>>> 
>>>>> 
>>> 
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>>>> 
>>>>> Cheer,
>>>>> - hugi
>>>>> 
>>>>> // Hugi Thordarson
>>>>> // http://www.loftfar.is/
>>>>> // s. 895-6688
>>>>> 
>>>>> 
>>>>> 
>>>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>>>>> wrote:
>>>>>> 
>>>>>> 
>>>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
>>> wrote:
>>>>>>> 
>>>>>>> What does validationQuery do?
>>>>>> 
>>>>>> Periodically executes for each pooled connection, and kills
>> connections
>>>>> that throw during validation. So it ensures that all pooled
>> connections
>>> are
>>>>> in a good state.
>>>>>> 
>>>>>> Andrus
>>>>>> 
>>>>> 
>>>>> 
>>> 
>>> 
>> 


Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
I looked at the built-in Cayenne connection pooling years ago and it was
OK, but I felt a third-party one would be more reliable and handle error
conditions better.  I've always used Apache Commons DBCP with Jetty/Tomcat
and it seems to work fine, but I haven't explored other external providers.


On Mon, Mar 7, 2016 at 3:39 PM, John Huss <jo...@gmail.com> wrote:

> EOF can do JNDI, but that's not going to do anything to fix your problem.
>
> The connection pool in cayenne had some changes somewhat recently so it's
> entirely possible there are bugs.
>
> In practice it turns out many people don't use the connection pool built-in
> to Cayenne at all, and rather use a third-party connection pool, of which
> there are several.  The cayenne one is decent, but it is very limited in
> functionality and less robust due to having a smaller user base and being a
> non-core feature.
>
> You can use another pool like:
> hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
> new project I'd use this
> tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
> This is what I currently use
> commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
> c3po <http://www.mchange.com/projects/c3p0/>
>
> The main reason I turned to a third-party connection pool was to get
> fair-scheduling which will provide connections to whoever has been waiting
> the longest, which helps avoid unnecessary errors caused by serving
> requests out of order.
>
> John
>
> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net>
> wrote:
>
> > Well, I'm not sure what you are using to run your web application, but
> > Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of
> DB
> > connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
> > give it the JNDI name, then configure the container to provide the DB
> > connection.
> >
> > Is your WO application using EOF or Cayenne?  Been a while since I used
> WO,
> > but I'd be stunned if EOF cannot use a JNDI lookup as well.
> >
> > mrg
> >
> >
> > On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >
> > > Hi Michael,
> > > does using JNDI change anything about the connection itself, isn’t it
> > just
> > > a different method of looking up connection information?
> > >
> > > But I probably can’t use it anyway since one of the apps is a
> WebObjects
> > > app and doesn’t provide a JNDI service (at least I’ve never used it).
> > >
> > > Thanks,
> > > - hugi
> > >
> > >
> > > > On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
> > wrote:
> > > >
> > > > Hi Hugi,
> > > >
> > > > Since this appears to be a web-based application, can you switch to
> > using
> > > > JNDI?
> > > >
> > > > mrg
> > > >
> > > >
> > > > On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
> > > wrote:
> > > >
> > > >> Hi all,
> > > >> This is still happening, even after I added a validationQuery, our
> app
> > > is
> > > >> dying quite frequently :(.  I’m not quite sure how to debug this, is
> > > there
> > > >> any way for me to catch where connections are being opened in the
> code
> > > and
> > > >> at what location they’re hanging?
> > > >>
> > > >>
> > > >>
> > >
> >
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> > > >>
> > > >> Cheer,
> > > >> - hugi
> > > >>
> > > >> // Hugi Thordarson
> > > >> // http://www.loftfar.is/
> > > >> // s. 895-6688
> > > >>
> > > >>
> > > >>
> > > >>> On 29. feb. 2016, at 11:25, Andrus Adamchik <
> andrus@objectstyle.org>
> > > >> wrote:
> > > >>>
> > > >>>
> > > >>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
> > > wrote:
> > > >>>>
> > > >>>> What does validationQuery do?
> > > >>>
> > > >>> Periodically executes for each pooled connection, and kills
> > connections
> > > >> that throw during validation. So it ensures that all pooled
> > connections
> > > are
> > > >> in a good state.
> > > >>>
> > > >>> Andrus
> > > >>>
> > > >>
> > > >>
> > >
> > >
> >
>

Re: Reconnecting automatically after DB downtime

Posted by John Huss <jo...@gmail.com>.
EOF can do JNDI, but that's not going to do anything to fix your problem.

The connection pool in cayenne had some changes somewhat recently so it's
entirely possible there are bugs.

In practice it turns out many people don't use the connection pool built-in
to Cayenne at all, and rather use a third-party connection pool, of which
there are several.  The cayenne one is decent, but it is very limited in
functionality and less robust due to having a smaller user base and being a
non-core feature.

You can use another pool like:
hikari <https://github.com/brettwooldridge/HikariCP> - If I was starting a
new project I'd use this
tomcat-jdbc <https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html> -
This is what I currently use
commonds-dbcp <https://commons.apache.org/proper/commons-dbcp/>
c3po <http://www.mchange.com/projects/c3p0/>

The main reason I turned to a third-party connection pool was to get
fair-scheduling which will provide connections to whoever has been waiting
the longest, which helps avoid unnecessary errors caused by serving
requests out of order.

John

On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry <mg...@masslight.net> wrote:

> Well, I'm not sure what you are using to run your web application, but
> Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
> connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
> give it the JNDI name, then configure the container to provide the DB
> connection.
>
> Is your WO application using EOF or Cayenne?  Been a while since I used WO,
> but I'd be stunned if EOF cannot use a JNDI lookup as well.
>
> mrg
>
>
> On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>
> > Hi Michael,
> > does using JNDI change anything about the connection itself, isn’t it
> just
> > a different method of looking up connection information?
> >
> > But I probably can’t use it anyway since one of the apps is a WebObjects
> > app and doesn’t provide a JNDI service (at least I’ve never used it).
> >
> > Thanks,
> > - hugi
> >
> >
> > > On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net>
> wrote:
> > >
> > > Hi Hugi,
> > >
> > > Since this appears to be a web-based application, can you switch to
> using
> > > JNDI?
> > >
> > > mrg
> > >
> > >
> > > On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
> > wrote:
> > >
> > >> Hi all,
> > >> This is still happening, even after I added a validationQuery, our app
> > is
> > >> dying quite frequently :(.  I’m not quite sure how to debug this, is
> > there
> > >> any way for me to catch where connections are being opened in the code
> > and
> > >> at what location they’re hanging?
> > >>
> > >>
> > >>
> >
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> > >>
> > >> Cheer,
> > >> - hugi
> > >>
> > >> // Hugi Thordarson
> > >> // http://www.loftfar.is/
> > >> // s. 895-6688
> > >>
> > >>
> > >>
> > >>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
> > >> wrote:
> > >>>
> > >>>
> > >>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
> > wrote:
> > >>>>
> > >>>> What does validationQuery do?
> > >>>
> > >>> Periodically executes for each pooled connection, and kills
> connections
> > >> that throw during validation. So it ensures that all pooled
> connections
> > are
> > >> in a good state.
> > >>>
> > >>> Andrus
> > >>>
> > >>
> > >>
> >
> >
>

Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
Well, I'm not sure what you are using to run your web application, but
Tomcat, Jetty, JBoss, etc all have mechanisms to provide JNDI lookups of DB
connection pools.  You just tell Cayenne Modeler to use JNDI lookup and
give it the JNDI name, then configure the container to provide the DB
connection.

Is your WO application using EOF or Cayenne?  Been a while since I used WO,
but I'd be stunned if EOF cannot use a JNDI lookup as well.

mrg


On Mon, Mar 7, 2016 at 3:07 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Hi Michael,
> does using JNDI change anything about the connection itself, isn’t it just
> a different method of looking up connection information?
>
> But I probably can’t use it anyway since one of the apps is a WebObjects
> app and doesn’t provide a JNDI service (at least I’ve never used it).
>
> Thanks,
> - hugi
>
>
> > On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net> wrote:
> >
> > Hi Hugi,
> >
> > Since this appears to be a web-based application, can you switch to using
> > JNDI?
> >
> > mrg
> >
> >
> > On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >
> >> Hi all,
> >> This is still happening, even after I added a validationQuery, our app
> is
> >> dying quite frequently :(.  I’m not quite sure how to debug this, is
> there
> >> any way for me to catch where connections are being opened in the code
> and
> >> at what location they’re hanging?
> >>
> >>
> >>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> >>
> >> Cheer,
> >> - hugi
> >>
> >> // Hugi Thordarson
> >> // http://www.loftfar.is/
> >> // s. 895-6688
> >>
> >>
> >>
> >>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
> >> wrote:
> >>>
> >>>
> >>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is>
> wrote:
> >>>>
> >>>> What does validationQuery do?
> >>>
> >>> Periodically executes for each pooled connection, and kills connections
> >> that throw during validation. So it ensures that all pooled connections
> are
> >> in a good state.
> >>>
> >>> Andrus
> >>>
> >>
> >>
>
>

Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Hi Michael,
does using JNDI change anything about the connection itself, isn’t it just a different method of looking up connection information?

But I probably can’t use it anyway since one of the apps is a WebObjects app and doesn’t provide a JNDI service (at least I’ve never used it).

Thanks,
- hugi


> On 7. mar. 2016, at 19:13, Michael Gentry <mg...@masslight.net> wrote:
> 
> Hi Hugi,
> 
> Since this appears to be a web-based application, can you switch to using
> JNDI?
> 
> mrg
> 
> 
> On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Hi all,
>> This is still happening, even after I added a validationQuery, our app is
>> dying quite frequently :(.  I’m not quite sure how to debug this, is there
>> any way for me to catch where connections are being opened in the code and
>> at what location they’re hanging?
>> 
>> 
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>> 
>> Cheer,
>> - hugi
>> 
>> // Hugi Thordarson
>> // http://www.loftfar.is/
>> // s. 895-6688
>> 
>> 
>> 
>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
>> wrote:
>>> 
>>> 
>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>> 
>>>> What does validationQuery do?
>>> 
>>> Periodically executes for each pooled connection, and kills connections
>> that throw during validation. So it ensures that all pooled connections are
>> in a good state.
>>> 
>>> Andrus
>>> 
>> 
>> 


Re: Reconnecting automatically after DB downtime

Posted by Michael Gentry <mg...@masslight.net>.
Hi Hugi,

Since this appears to be a web-based application, can you switch to using
JNDI?

mrg


On Mon, Mar 7, 2016 at 5:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Hi all,
> This is still happening, even after I added a validationQuery, our app is
> dying quite frequently :(.  I’m not quite sure how to debug this, is there
> any way for me to catch where connections are being opened in the code and
> at what location they’re hanging?
>
>
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>
> Cheer,
> - hugi
>
> // Hugi Thordarson
> // http://www.loftfar.is/
> // s. 895-6688
>
>
>
> > On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org>
> wrote:
> >
> >
> >> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> >>
> >> What does validationQuery do?
> >
> > Periodically executes for each pooled connection, and kills connections
> that throw during validation. So it ensures that all pooled connections are
> in a good state.
> >
> > Andrus
> >
>
>

Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Is it possible it’s a configuration issue? I’m setting minConnections to 1 and maxConnections to 10. Should I rather leave these at default values or choose different values?

Cheers,
- hugi

// Hugi Thordarson
// http://www.loftfar.is/
// s. 895-6688



> On 7. mar. 2016, at 20:01, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
> Thanks for the reply Andrus!
> 
> Sounds like it might be the case. But actually, this now happens without the DB going down (and I don’t think it’s a communication problem with the DB either, since the DB runs on the same server as the apps).
> 
> I recently added a PostCommitListener that does quite a lot of DB work and I believe the issue started around the same time. At first I thought it might be a deadlocking sitation, but a jstack thread dump from a dead process does not point to that.
> 
> Is there any way for me to check the number and status of currently open connections?
> 
> Cheers,
> - hugi
> 
> 
> 
>> On 7. mar. 2016, at 18:54, Andrus Adamchik <an...@objectstyle.org> wrote:
>> 
>> Hmm... It shows there are zero connections in the pool. I have a theory about that. Looks like when you uncheck your first connection after the DB restart, pool goes through all connections to find a valid one, and removing bad connections in the process. As there are no longer valid connections there, the pool is drained completely. Then the error happens; and then at a later time, pool manager thread kicks in and fills the pool with new connections. 
>> 
>> I need to test it.. And perhaps move the validation to background. 
>> 
>> (and perhaps add Tomcat connection pool to a list of DataSource options ... that's the one I am using in Bootique: https://github.com/nhl/bootique-jdbc and elsewhere in production).
>> 
>> Andrus
>> 
>>> On Mar 7, 2016, at 2:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>> 
>>> Hi all,
>>> This is still happening, even after I added a validationQuery, our app is dying quite frequently :(.  I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?
>>> 
>>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>>> 
>>> Cheer,
>>> - hugi
>>> 
>>> // Hugi Thordarson
>>> // http://www.loftfar.is/
>>> // s. 895-6688
>>> 
>>> 
>>> 
>>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org> wrote:
>>>> 
>>>> 
>>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>>> 
>>>>> What does validationQuery do?
>>>> 
>>>> Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.
>>>> 
>>>> Andrus
>>>> 
>>> 
>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Thanks for the reply Andrus!

Sounds like it might be the case. But actually, this now happens without the DB going down (and I don’t think it’s a communication problem with the DB either, since the DB runs on the same server as the apps).

I recently added a PostCommitListener that does quite a lot of DB work and I believe the issue started around the same time. At first I thought it might be a deadlocking sitation, but a jstack thread dump from a dead process does not point to that.

Is there any way for me to check the number and status of currently open connections?

Cheers,
- hugi



> On 7. mar. 2016, at 18:54, Andrus Adamchik <an...@objectstyle.org> wrote:
> 
> Hmm... It shows there are zero connections in the pool. I have a theory about that. Looks like when you uncheck your first connection after the DB restart, pool goes through all connections to find a valid one, and removing bad connections in the process. As there are no longer valid connections there, the pool is drained completely. Then the error happens; and then at a later time, pool manager thread kicks in and fills the pool with new connections. 
> 
> I need to test it.. And perhaps move the validation to background. 
> 
> (and perhaps add Tomcat connection pool to a list of DataSource options ... that's the one I am using in Bootique: https://github.com/nhl/bootique-jdbc and elsewhere in production).
> 
> Andrus
> 
>> On Mar 7, 2016, at 2:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>> 
>> Hi all,
>> This is still happening, even after I added a validationQuery, our app is dying quite frequently :(.  I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?
>> 
>> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
>> 
>> Cheer,
>> - hugi
>> 
>> // Hugi Thordarson
>> // http://www.loftfar.is/
>> // s. 895-6688
>> 
>> 
>> 
>>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org> wrote:
>>> 
>>> 
>>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>>> 
>>>> What does validationQuery do?
>>> 
>>> Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.
>>> 
>>> Andrus
>>> 
>> 
> 


Re: Reconnecting automatically after DB downtime

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hmm... It shows there are zero connections in the pool. I have a theory about that. Looks like when you uncheck your first connection after the DB restart, pool goes through all connections to find a valid one, and removing bad connections in the process. As there are no longer valid connections there, the pool is drained completely. Then the error happens; and then at a later time, pool manager thread kicks in and fills the pool with new connections. 

I need to test it.. And perhaps move the validation to background. 

(and perhaps add Tomcat connection pool to a list of DataSource options ... that's the one I am using in Bootique: https://github.com/nhl/bootique-jdbc and elsewhere in production).

Andrus

> On Mar 7, 2016, at 2:46 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
> Hi all,
> This is still happening, even after I added a validationQuery, our app is dying quite frequently :(.  I’m not quite sure how to debug this, is there any way for me to catch where connections are being opened in the code and at what location they’re hanging?
> 
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> 
> Cheer,
> - hugi
> 
> // Hugi Thordarson
> // http://www.loftfar.is/
> // s. 895-6688
> 
> 
> 
>> On 29. feb. 2016, at 11:25, Andrus Adamchik <an...@objectstyle.org> wrote:
>> 
>> 
>>> On Feb 29, 2016, at 2:20 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>> 
>>> What does validationQuery do?
>> 
>> Periodically executes for each pooled connection, and kills connections that throw during validation. So it ensures that all pooled connections are in a good state.
>> 
>> Andrus
>> 
>