You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by amit shah <am...@gmail.com> on 2013/03/11 05:52:25 UTC

Tomcat jdbc pool connection failover

Hello,
        I would like to know if the tomcat jdbc pool (7.0.34+) provides
connection failover capabilities i.e. to transparently close all the open
database connections and switch to a another database server on an
planned/unplanned database server outage event.
        I read through the tomcat documentation but didn't find any details
related to this. If this feature is not supported are there any recommended
alternatives and any future plans to add this feature to the jdbc pool?

Thank you,
Amit.

Re: Tomcat jdbc pool connection failover

Posted by amit shah <am...@gmail.com>.
I understand that unplanned outages are rare but we need a high
availability solution which does not involve manual intervention.


On Mon, Mar 11, 2013 at 9:05 PM, Shanti Suresh <sh...@umich.edu> wrote:

> On Mon, Mar 11, 2013 at 11:00 AM, André Warnier <aw...@ice-sa.com> wrote:
>
> >
> > amit shah wrote:
> >
> >> Apparently we use Oracle as our data store while the solution you
> >> mentioned
> >> is for mysql.
> >>
> >
> > And did you check if the Oracle JDBC driver provides such an option ?
> >
> >
> >
> >> Is there a way tomcat can provide a notification after all its retries
> to
> >> the database server have failed? This way at least I can create a new
> >> connection pool configured to a different database server in order to
> >> simulate a automatic connection failover from the application side. I
> >> understand that this step would require time for the retries and
> creation
> >> of new pool.
> >>
> >
> > I am not a Java specialist, but I would imagine that at least your
> > application would get some kind of I/O exception when that happens on a
> > read or a write.
> > Can you not catch that and do whatever you need to then ?
> > After all, even if the driver itself handles the primary case, there
> would
> > still be a possibility that even your backup database server would also
> be
> > unreachable, no ?
> >
> >
> How often does an unplanned outage occur?  It would seem drastic if an
> unplanned database server outage occurs often.
> For planned server outages, usually, the failover is done out-of-band with
> Tomcat.  Please correct me if I am wrong.
> Some simple options I can think of include:
> * DNS mapping - map the DNS name of the Oracle server to the new IP address
> of the second server - make sure that "networkaddress.cache.ttl=1800" or
> something other than "-1" in the jre/lib/java.security file
> * a loadbalancer listing both database servers with one inactive - then you
> mark the secondary server as active, and the primary as inactive during
> maintenance of the primary database server.
>
> Thanks.
>
>                       -Shanti
>
> >
> >
> >> On Mon, Mar 11, 2013 at 6:15 PM, Daniel Mikusa <dm...@vmware.com>
> >> wrote:
> >>
> >>  On Mar 11, 2013, at 12:52 AM, amit shah wrote:
> >>>
> >>>  Hello,
> >>>>        I would like to know if the tomcat jdbc pool (7.0.34+) provides
> >>>> connection failover capabilities i.e. to transparently close all the
> >>>> open
> >>>> database connections and switch to a another database server on an
> >>>> planned/unplanned database server outage event.
> >>>>        I read through the tomcat documentation but didn't find any
> >>>>
> >>> details
> >>>
> >>>> related to this. If this feature is not supported are there any
> >>>>
> >>> recommended
> >>>
> >>>> alternatives and any future plans to add this feature to the jdbc
> pool?
> >>>>
> >>> You might want to see if your JDBC driver will handle this for you.  I
> >>> know that some do, like MySQL [1].
> >>>
> >>
>

Re: Tomcat jdbc pool connection failover

Posted by Shanti Suresh <sh...@umich.edu>.
On Mon, Mar 11, 2013 at 11:00 AM, André Warnier <aw...@ice-sa.com> wrote:

>
> amit shah wrote:
>
>> Apparently we use Oracle as our data store while the solution you
>> mentioned
>> is for mysql.
>>
>
> And did you check if the Oracle JDBC driver provides such an option ?
>
>
>
>> Is there a way tomcat can provide a notification after all its retries to
>> the database server have failed? This way at least I can create a new
>> connection pool configured to a different database server in order to
>> simulate a automatic connection failover from the application side. I
>> understand that this step would require time for the retries and creation
>> of new pool.
>>
>
> I am not a Java specialist, but I would imagine that at least your
> application would get some kind of I/O exception when that happens on a
> read or a write.
> Can you not catch that and do whatever you need to then ?
> After all, even if the driver itself handles the primary case, there would
> still be a possibility that even your backup database server would also be
> unreachable, no ?
>
>
How often does an unplanned outage occur?  It would seem drastic if an
unplanned database server outage occurs often.
For planned server outages, usually, the failover is done out-of-band with
Tomcat.  Please correct me if I am wrong.
Some simple options I can think of include:
* DNS mapping - map the DNS name of the Oracle server to the new IP address
of the second server - make sure that "networkaddress.cache.ttl=1800" or
something other than "-1" in the jre/lib/java.security file
* a loadbalancer listing both database servers with one inactive - then you
mark the secondary server as active, and the primary as inactive during
maintenance of the primary database server.

Thanks.

                      -Shanti

>
>
>> On Mon, Mar 11, 2013 at 6:15 PM, Daniel Mikusa <dm...@vmware.com>
>> wrote:
>>
>>  On Mar 11, 2013, at 12:52 AM, amit shah wrote:
>>>
>>>  Hello,
>>>>        I would like to know if the tomcat jdbc pool (7.0.34+) provides
>>>> connection failover capabilities i.e. to transparently close all the
>>>> open
>>>> database connections and switch to a another database server on an
>>>> planned/unplanned database server outage event.
>>>>        I read through the tomcat documentation but didn't find any
>>>>
>>> details
>>>
>>>> related to this. If this feature is not supported are there any
>>>>
>>> recommended
>>>
>>>> alternatives and any future plans to add this feature to the jdbc pool?
>>>>
>>> You might want to see if your JDBC driver will handle this for you.  I
>>> know that some do, like MySQL [1].
>>>
>>

Re: Tomcat jdbc pool connection failover

Posted by André Warnier <aw...@ice-sa.com>.
Hi.
Don't "top post".

amit shah wrote:
> Apparently we use Oracle as our data store while the solution you mentioned
> is for mysql.

And did you check if the Oracle JDBC driver provides such an option ?

> 
> Is there a way tomcat can provide a notification after all its retries to
> the database server have failed? This way at least I can create a new
> connection pool configured to a different database server in order to
> simulate a automatic connection failover from the application side. I
> understand that this step would require time for the retries and creation
> of new pool.

I am not a Java specialist, but I would imagine that at least your application would get 
some kind of I/O exception when that happens on a read or a write.
Can you not catch that and do whatever you need to then ?
After all, even if the driver itself handles the primary case, there would still be a 
possibility that even your backup database server would also be unreachable, no ?

> 
> Thanks.
> 
> 
> On Mon, Mar 11, 2013 at 6:15 PM, Daniel Mikusa <dm...@vmware.com> wrote:
> 
>> On Mar 11, 2013, at 12:52 AM, amit shah wrote:
>>
>>> Hello,
>>>        I would like to know if the tomcat jdbc pool (7.0.34+) provides
>>> connection failover capabilities i.e. to transparently close all the open
>>> database connections and switch to a another database server on an
>>> planned/unplanned database server outage event.
>>>        I read through the tomcat documentation but didn't find any
>> details
>>> related to this. If this feature is not supported are there any
>> recommended
>>> alternatives and any future plans to add this feature to the jdbc pool?
>> You might want to see if your JDBC driver will handle this for you.  I
>> know that some do, like MySQL [1].
>>
>> Dan
>>
>> [1] -
>> https://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
>>
>>> Thank you,
>>> Amit
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by Daniel Mikusa <dm...@vmware.com>.
On Mar 11, 2013, at 10:09 AM, amit shah wrote:

> Apparently we use Oracle as our data store while the solution you mentioned
> is for mysql.

I'm not an Oracle guy, but I'm pretty sure that it supports failover.  Not sure it's as simple as changing the JDBC URL though, you'll probably want to check with your DBA to figure out more.

> 
> Is there a way tomcat can provide a notification after all its retries to
> the database server have failed?

This should throw an exception and indicate it was unable to create a connection.  I suppose that you could catch this and do something else.  It's not the best approach though.  I think the JDBC driver could handle this more seamlessly, since it's closer to the DB.

> This way at least I can create a new
> connection pool configured to a different database server in order to
> simulate a automatic connection failover from the application side. I
> understand that this step would require time for the retries and creation
> of new pool.

Perhaps you could create two datasources on startup, a primary and a secondary.  The application would always default to the primary, unless it couldn't get a connection.  Then it would use the secondary.  Not a great solution, but sounds similar to what you mentioned.

Dan



> 
> Thanks.
> 
> 
> On Mon, Mar 11, 2013 at 6:15 PM, Daniel Mikusa <dm...@vmware.com> wrote:
> 
>> On Mar 11, 2013, at 12:52 AM, amit shah wrote:
>> 
>>> Hello,
>>>       I would like to know if the tomcat jdbc pool (7.0.34+) provides
>>> connection failover capabilities i.e. to transparently close all the open
>>> database connections and switch to a another database server on an
>>> planned/unplanned database server outage event.
>>>       I read through the tomcat documentation but didn't find any
>> details
>>> related to this. If this feature is not supported are there any
>> recommended
>>> alternatives and any future plans to add this feature to the jdbc pool?
>> 
>> You might want to see if your JDBC driver will handle this for you.  I
>> know that some do, like MySQL [1].
>> 
>> Dan
>> 
>> [1] -
>> https://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
>> 
>>> 
>>> Thank you,
>>> Amit
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by amit shah <am...@gmail.com>.
Apparently we use Oracle as our data store while the solution you mentioned
is for mysql.

Is there a way tomcat can provide a notification after all its retries to
the database server have failed? This way at least I can create a new
connection pool configured to a different database server in order to
simulate a automatic connection failover from the application side. I
understand that this step would require time for the retries and creation
of new pool.

Thanks.


On Mon, Mar 11, 2013 at 6:15 PM, Daniel Mikusa <dm...@vmware.com> wrote:

> On Mar 11, 2013, at 12:52 AM, amit shah wrote:
>
> > Hello,
> >        I would like to know if the tomcat jdbc pool (7.0.34+) provides
> > connection failover capabilities i.e. to transparently close all the open
> > database connections and switch to a another database server on an
> > planned/unplanned database server outage event.
> >        I read through the tomcat documentation but didn't find any
> details
> > related to this. If this feature is not supported are there any
> recommended
> > alternatives and any future plans to add this feature to the jdbc pool?
>
> You might want to see if your JDBC driver will handle this for you.  I
> know that some do, like MySQL [1].
>
> Dan
>
> [1] -
> https://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
>
> >
> > Thank you,
> > Amit
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat jdbc pool connection failover

Posted by Daniel Mikusa <dm...@vmware.com>.
On Mar 11, 2013, at 12:52 AM, amit shah wrote:

> Hello,
>        I would like to know if the tomcat jdbc pool (7.0.34+) provides
> connection failover capabilities i.e. to transparently close all the open
> database connections and switch to a another database server on an
> planned/unplanned database server outage event.
>        I read through the tomcat documentation but didn't find any details
> related to this. If this feature is not supported are there any recommended
> alternatives and any future plans to add this feature to the jdbc pool?

You might want to see if your JDBC driver will handle this for you.  I know that some do, like MySQL [1].

Dan

[1] - https://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html

> 
> Thank you,
> Amit

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by André Warnier <aw...@ice-sa.com>.
amit shah wrote:
> Hello,
>         I would like to know if the tomcat jdbc pool (7.0.34+) provides
> connection failover capabilities i.e. to transparently close all the open
> database connections and switch to a another database server on an
> planned/unplanned database server outage event.
>         I read through the tomcat documentation but didn't find any details
> related to this. If this feature is not supported are there any recommended
> alternatives and any future plans to add this feature to the jdbc pool?
> 
Hi.
This is not a direct answer to your question, and I am not able to provide one.
But one alternative to your above scenario which does exist, is to have a pool of Tomcats, 
each with its own database server.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by amit shah <am...@gmail.com>.
On Wed, Mar 13, 2013 at 12:52 PM, André Warnier <aw...@ice-sa.com> wrote:

> Rainer Frey wrote:
>
>> On 12.03.2013, at 17:14, Christopher Schultz <
>> chris@christopherschultz.net> wrote:
>>
>>> On 3/12/13 7:54 AM, amit shah wrote:
>>>
>>>> I am using Oracle. Oracle JDBC Driver provides the Oracle
>>>> Universal Connection Pool (UCP) which includes this feature<
>>>> http://docs.oracle.**com/cd/E11882_01/java.112/**e16548/fstconfo.htm<http://docs.oracle.com/cd/E11882_01/java.112/e16548/fstconfo.htm>
>>>> >of
>>>>
>>>>
>>>>  connection failover but since we use tomcat jdbc connection pool we
>>>
>>>> cannot use UCP.
>>>>
>>> Why not?
>>>
>>
>> Because it would be two-level pooling?
>>
>>  Also UCP has lot of synchronized code which leads to blocking
>>>> threads and less concurrency support.
>>>>
>>>> Let me know your suggestions/thoughts.
>>>>
>>> I'm thinking that a low-performance fail-over is preferable to a
>>> zero-performance non-fail-over.
>>>
>>
>> Well, low overall performance, but possibility of failover in the
>> hopefully rare case,
>> may not be acceptable compared to high(er) overall performance and a
>> search for other ways
>> to perform failover.
>>
>>
> I am not sure that I totally follow the arguments here, but it seems that
> there exist
> - a JDBC pool with good performance, but no fail-over
> - a JDBC pool with failover, but bad performance
> Why not move the problem one level higher, and instead of using one tomcat
> with several pools, use several tomcats each with their own pool ?
> Several tomcats can be configured as a "failover pool" of tomcats, no ?
>
>
I am using the tomcat jdbc pool independently by placing the jars in my
web-application. We use glassfish as our application server. So what you
suggest is not an option.


>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.**apache.org<us...@tomcat.apache.org>
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat jdbc pool connection failover

Posted by André Warnier <aw...@ice-sa.com>.
Rainer Frey wrote:
> On 12.03.2013, at 17:14, Christopher Schultz <ch...@christopherschultz.net> wrote:
>> On 3/12/13 7:54 AM, amit shah wrote:
>>> I am using Oracle. Oracle JDBC Driver provides the Oracle
>>> Universal Connection Pool (UCP) which includes this 
>>> feature<http://docs.oracle.com/cd/E11882_01/java.112/e16548/fstconfo.htm>of
>>>
>>>
>> connection failover but since we use tomcat jdbc connection pool we
>>> cannot use UCP.
>> Why not?
> 
> Because it would be two-level pooling?
> 
>>> Also UCP has lot of synchronized code which leads to blocking
>>> threads and less concurrency support.
>>>
>>> Let me know your suggestions/thoughts.
>> I'm thinking that a low-performance fail-over is preferable to a
>> zero-performance non-fail-over.
> 
> Well, low overall performance, but possibility of failover in the hopefully rare case,
> may not be acceptable compared to high(er) overall performance and a search for other ways
> to perform failover.
> 

I am not sure that I totally follow the arguments here, but it seems that there exist
- a JDBC pool with good performance, but no fail-over
- a JDBC pool with failover, but bad performance
Why not move the problem one level higher, and instead of using one tomcat with several 
pools, use several tomcats each with their own pool ?
Several tomcats can be configured as a "failover pool" of tomcats, no ?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by Rainer Frey <ra...@inxmail.de>.
On 12.03.2013, at 17:14, Christopher Schultz <ch...@christopherschultz.net> wrote:
> On 3/12/13 7:54 AM, amit shah wrote:
>> I am using Oracle. Oracle JDBC Driver provides the Oracle
>> Universal Connection Pool (UCP) which includes this 
>> feature<http://docs.oracle.com/cd/E11882_01/java.112/e16548/fstconfo.htm>of
>> 
>> 
> connection failover but since we use tomcat jdbc connection pool we
>> cannot use UCP.
> 
> Why not?

Because it would be two-level pooling?

>> Also UCP has lot of synchronized code which leads to blocking
>> threads and less concurrency support.
>> 
>> Let me know your suggestions/thoughts.
> 
> I'm thinking that a low-performance fail-over is preferable to a
> zero-performance non-fail-over.

Well, low overall performance, but possibility of failover in the hopefully rare case,
may not be acceptable compared to high(er) overall performance and a search for other ways
to perform failover.

Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Amit,

On 3/12/13 7:54 AM, amit shah wrote:
> I am using Oracle. Oracle JDBC Driver provides the Oracle
> Universal Connection Pool (UCP) which includes this 
> feature<http://docs.oracle.com/cd/E11882_01/java.112/e16548/fstconfo.htm>of
>
> 
connection failover but since we use tomcat jdbc connection pool we
> cannot use UCP.

Why not?

> Also UCP has lot of synchronized code which leads to blocking
> threads and less concurrency support.
> 
> Let me know your suggestions/thoughts.

I'm thinking that a low-performance fail-over is preferable to a
zero-performance non-fail-over.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlE/VEoACgkQ9CaO5/Lv0PDnvgCfdimagPAHXpTmNex8ZlWlb5Te
7BsAoIUiGWLZ2LTWOb4r7LBV/XciWj6u
=RvDu
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat jdbc pool connection failover

Posted by amit shah <am...@gmail.com>.
I am using Oracle. Oracle JDBC Driver provides the Oracle Universal
Connection Pool (UCP) which includes this
feature<http://docs.oracle.com/cd/E11882_01/java.112/e16548/fstconfo.htm>of
connection failover but since we use tomcat jdbc connection pool we
cannot use UCP. Also UCP has lot of synchronized code which leads to
blocking threads and less concurrency support.

Let me know your suggestions/thoughts.



On Tue, Mar 12, 2013 at 1:54 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Amit,
>
> On 3/11/13 12:52 AM, amit shah wrote:
> > Hello, I would like to know if the tomcat jdbc pool (7.0.34+)
> > provides connection failover capabilities i.e. to transparently
> > close all the open database connections and switch to a another
> > database server on an planned/unplanned database server outage
> > event. I read through the tomcat documentation but didn't find any
> > details related to this. If this feature is not supported are there
> > any recommended alternatives and any future plans to add this
> > feature to the jdbc pool?
>
> This is usually done at the driver level. What database are you using?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEAREIAAYFAlE+PYkACgkQ9CaO5/Lv0PAAtgCeIMaEODHLFvVqG5losN1EApM6
> CxMAnRyRG7Qdx3hI+uQ4pD4yx07p++tx
> =UVeg
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Tomcat jdbc pool connection failover

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Amit,

On 3/11/13 12:52 AM, amit shah wrote:
> Hello, I would like to know if the tomcat jdbc pool (7.0.34+)
> provides connection failover capabilities i.e. to transparently
> close all the open database connections and switch to a another
> database server on an planned/unplanned database server outage
> event. I read through the tomcat documentation but didn't find any
> details related to this. If this feature is not supported are there
> any recommended alternatives and any future plans to add this
> feature to the jdbc pool?

This is usually done at the driver level. What database are you using?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlE+PYkACgkQ9CaO5/Lv0PAAtgCeIMaEODHLFvVqG5losN1EApM6
CxMAnRyRG7Qdx3hI+uQ4pD4yx07p++tx
=UVeg
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org