You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Niranjan Babu Bommu <ni...@gmail.com> on 2016/06/13 18:21:30 UTC

tomcat cache database server IP forever

Hi All,

I have an issue with tomcat dns cache ttl, where if I change the IP address
of the database, tomcat still sending connection requests to an old IP
until I restart tomcat, this is not the case with Jboss. I verified in java
security, this what we have in java.

#networkaddress.cache.ttl=-1

since this property has been disabled, by default ttl will be 30 sec, jboss
7 is respecting this value, but not tomcat.

so far I have tried these things in tomcat.

https://bz.apache.org/bugzilla/show_bug.cgi?id=33226

neither of these settings is not working in tomcat

-Dnetworkaddress.cache.ttl=0 or -Dsun.net.inetaddr.ttl=0


java version "1.7.0_60"
tomcat-7.0.56
os centos 6.

can someone please help me out to fix this issue
-- 
*Thanks*
*Niranjan*

Re: tomcat cache database server IP forever

Posted by Niranjan Babu Bommu <ni...@gmail.com>.
Thanks Chris,

thanks for the lead on this, will test this scenario and update on this.

Thanks
Niranjan

On Tue, Jun 14, 2016 at 3:56 PM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Niranjan,
>
> On 6/14/16 10:06 AM, Niranjan Babu Bommu wrote:
> > Thanks for your reply, here I'm attaching server.xml file in this
> > email.
> >
> > actually we are running MHA for mysql where we can spin up new db
> > server and  add to the cluster  or change the IP of db server
> > without impacting end user. our application is running on both
> > tomcat and jboss we switch whenever we want,  Recently we have
> > noticed that when we replaced the db server, jboss is able to
> > detect the dns change and sends connection requests to new IP where
> > as tomcat sending  connection requests to the old IP and throws
> > tons of error. Since we can't test this in real time in prod, we
> > were able to replicate this test env.
> >
> > tried with simple java program where it polls the host name  while
> > I'm changing the IP address of the server in DNS. I'm able to see
> > the new IP address imminently when I change that IP in DNS. this
> > confirms that java security setting looks fine, the same in-house
> > application works in jboss when we change the IP of DB server but
> > tomcat behaving differently. I ran out of options to figure out
> > where is the problem.
>
> What if you write a simple JSP, etc. that reports the IP address of
> db1.local and auto-refreshes every second?
>
> My suspicion is that the jdbc-pool is continuing to use connections
> that have already been established. No DNS resolution is performed to
> communicate over an existing TCP/IP connection.
>
> When you change the IP address of db1.local, are you also terminating
> all TCP/IP connections to the old db1.local host? If not, they will
> continue to function as if no change had occurred. New connections are
> likely to connect to the use server.
>
> Why are you playing games with IP addresses? If you are using MySQL
> HA, why not run it on a machine that doesn't change IP addresses and
> use that as a proxy to your db cluster? Then the HA proxy takes care
> of everything and you don't need to re-IP your whole cluster while
> it's running.
>
> - -chris
>
> > On Tue, Jun 14, 2016 at 4:04 AM, Mark Thomas <markt@apache.org
> > <ma...@apache.org>> wrote:
> >
> > On 13/06/2016 19:21, Niranjan Babu Bommu wrote:
> >> Hi All,
> >>
> >> I have an issue with tomcat dns cache ttl,
> >
> > That simply is not possible. Tomcat doesn't cache DNS entries.
> >
> >> where if I change the IP address of the database, tomcat still
> >> sending connection requests to an old IP until I restart tomcat,
> >
> > Now that sounds like a better start to the problem description. You
> > are going to need to expand on that. A lot.
> >
> > Tomcat doesn't use a database by default so is this really a
> > Tomcat issue or an application issue? How is the database
> > configured? Is connection pooling being used? How are you
> > confirming connection requests are being directed to the old IP
> > address? Define "restart Tomcat".
> >
> > Mark
> >
> >> this is not the case with Jboss. I verified in java security,
> >> this what we have in java.
> >>
> >> #networkaddress.cache.ttl=-1
> >>
> >> since this property has been disabled, by default ttl will be 30
> >> sec, jboss 7 is respecting this value, but not tomcat.
> >>
> >> so far I have tried these things in tomcat.
> >>
> >> https://bz.apache.org/bugzilla/show_bug.cgi?id=33226
> >>
> >> neither of these settings is not working in tomcat
> >>
> >> -Dnetworkaddress.cache.ttl=0 or -Dsun.net.inetaddr.ttl=0
> >>
> >>
> >> java version "1.7.0_60" tomcat-7.0.56 os centos 6.
> >>
> >> can someone please help me out to fix this issue
> >>
> >
> >
> > ---------------------------------------------------------------------
> >
> >
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > <ma...@tomcat.apache.org> For additional
> > commands, e-mail: users-help@tomcat.apache.org
> > <ma...@tomcat.apache.org>
> >
> >
> >
> >
> > -- /*Thanks*/ /*Niranjan*/ /*+1 781.956.6900*/
> >
> >
> >
> > ---------------------------------------------------------------------
> >
> >
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>
> iEYEARECAAYFAldgYWkACgkQ9CaO5/Lv0PBbGQCeIuMkUUcAZX1m5aE8Yh40lgll
> hJAAn3rSoZspVPai4PH5eJYh79wPzfPl
> =EX/E
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
*Thanks*
*Niranjan*

Re: tomcat cache database server IP forever

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

Niranjan,

On 6/14/16 10:06 AM, Niranjan Babu Bommu wrote:
> Thanks for your reply, here I'm attaching server.xml file in this
> email.
> 
> actually we are running MHA for mysql where we can spin up new db 
> server and  add to the cluster  or change the IP of db server
> without impacting end user. our application is running on both
> tomcat and jboss we switch whenever we want,  Recently we have
> noticed that when we replaced the db server, jboss is able to
> detect the dns change and sends connection requests to new IP where
> as tomcat sending  connection requests to the old IP and throws
> tons of error. Since we can't test this in real time in prod, we
> were able to replicate this test env.
> 
> tried with simple java program where it polls the host name  while
> I'm changing the IP address of the server in DNS. I'm able to see
> the new IP address imminently when I change that IP in DNS. this
> confirms that java security setting looks fine, the same in-house
> application works in jboss when we change the IP of DB server but
> tomcat behaving differently. I ran out of options to figure out
> where is the problem.

What if you write a simple JSP, etc. that reports the IP address of
db1.local and auto-refreshes every second?

My suspicion is that the jdbc-pool is continuing to use connections
that have already been established. No DNS resolution is performed to
communicate over an existing TCP/IP connection.

When you change the IP address of db1.local, are you also terminating
all TCP/IP connections to the old db1.local host? If not, they will
continue to function as if no change had occurred. New connections are
likely to connect to the use server.

Why are you playing games with IP addresses? If you are using MySQL
HA, why not run it on a machine that doesn't change IP addresses and
use that as a proxy to your db cluster? Then the HA proxy takes care
of everything and you don't need to re-IP your whole cluster while
it's running.

- -chris

> On Tue, Jun 14, 2016 at 4:04 AM, Mark Thomas <markt@apache.org 
> <ma...@apache.org>> wrote:
> 
> On 13/06/2016 19:21, Niranjan Babu Bommu wrote:
>> Hi All,
>> 
>> I have an issue with tomcat dns cache ttl,
> 
> That simply is not possible. Tomcat doesn't cache DNS entries.
> 
>> where if I change the IP address of the database, tomcat still
>> sending connection requests to an old IP until I restart tomcat,
> 
> Now that sounds like a better start to the problem description. You
> are going to need to expand on that. A lot.
> 
> Tomcat doesn't use a database by default so is this really a
> Tomcat issue or an application issue? How is the database
> configured? Is connection pooling being used? How are you
> confirming connection requests are being directed to the old IP
> address? Define "restart Tomcat".
> 
> Mark
> 
>> this is not the case with Jboss. I verified in java security,
>> this what we have in java.
>> 
>> #networkaddress.cache.ttl=-1
>> 
>> since this property has been disabled, by default ttl will be 30
>> sec, jboss 7 is respecting this value, but not tomcat.
>> 
>> so far I have tried these things in tomcat.
>> 
>> https://bz.apache.org/bugzilla/show_bug.cgi?id=33226
>> 
>> neither of these settings is not working in tomcat
>> 
>> -Dnetworkaddress.cache.ttl=0 or -Dsun.net.inetaddr.ttl=0
>> 
>> 
>> java version "1.7.0_60" tomcat-7.0.56 os centos 6.
>> 
>> can someone please help me out to fix this issue
>> 
> 
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> <ma...@tomcat.apache.org> For additional
> commands, e-mail: users-help@tomcat.apache.org 
> <ma...@tomcat.apache.org>
> 
> 
> 
> 
> -- /*Thanks*/ /*Niranjan*/ /*+1 781.956.6900*/
> 
> 
> 
> ---------------------------------------------------------------------
>
> 
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAldgYWkACgkQ9CaO5/Lv0PBbGQCeIuMkUUcAZX1m5aE8Yh40lgll
hJAAn3rSoZspVPai4PH5eJYh79wPzfPl
=EX/E
-----END PGP SIGNATURE-----

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


Re: tomcat cache database server IP forever

Posted by Niranjan Babu Bommu <ni...@gmail.com>.
Hi Mark,

Thanks for your reply, here I'm attaching server.xml file in this email.

 actually we are running MHA for mysql where we can spin up new db server
and  add to the cluster  or change the IP of db server without impacting
end user. our application is running on both tomcat and jboss we switch
whenever we want,  Recently we have noticed that when we  replaced the db
server, jboss is able to detect the dns change and sends connection
requests to new IP where as tomcat sending  connection requests to the old
IP and throws tons of error.
Since we can't test this in real time in prod, we were able to replicate
this test env.

 tried with simple java program where it polls the host name  while I'm
changing the IP address of the server in DNS. I'm able to see the new IP
address imminently when I change that IP in DNS. this confirms that java
security setting looks fine, the same in-house application works in jboss
when we change the IP of DB server but tomcat behaving differently. I ran
out of options to figure out where is the problem.

Thanks
Niranjan




On Tue, Jun 14, 2016 at 4:04 AM, Mark Thomas <ma...@apache.org> wrote:

> On 13/06/2016 19:21, Niranjan Babu Bommu wrote:
> > Hi All,
> >
> > I have an issue with tomcat dns cache ttl,
>
> That simply is not possible. Tomcat doesn't cache DNS entries.
>
> > where if I change the IP address
> > of the database, tomcat still sending connection requests to an old IP
> > until I restart tomcat,
>
> Now that sounds like a better start to the problem description. You are
> going to need to expand on that. A lot.
>
> Tomcat doesn't use a database by default so is this really a Tomcat
> issue or an application issue? How is the database configured? Is
> connection pooling being used? How are you confirming connection
> requests are being directed to the old IP address? Define "restart Tomcat".
>
> Mark
>
> > this is not the case with Jboss. I verified in java
> > security, this what we have in java.
> >
> > #networkaddress.cache.ttl=-1
> >
> > since this property has been disabled, by default ttl will be 30 sec,
> jboss
> > 7 is respecting this value, but not tomcat.
> >
> > so far I have tried these things in tomcat.
> >
> > https://bz.apache.org/bugzilla/show_bug.cgi?id=33226
> >
> > neither of these settings is not working in tomcat
> >
> > -Dnetworkaddress.cache.ttl=0 or -Dsun.net.inetaddr.ttl=0
> >
> >
> > java version "1.7.0_60"
> > tomcat-7.0.56
> > os centos 6.
> >
> > can someone please help me out to fix this issue
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
*Thanks*
*Niranjan*
*+1 781.956.6900*

Re: tomcat cache database server IP forever

Posted by Mark Thomas <ma...@apache.org>.
On 13/06/2016 19:21, Niranjan Babu Bommu wrote:
> Hi All,
> 
> I have an issue with tomcat dns cache ttl,

That simply is not possible. Tomcat doesn't cache DNS entries.

> where if I change the IP address
> of the database, tomcat still sending connection requests to an old IP
> until I restart tomcat,

Now that sounds like a better start to the problem description. You are
going to need to expand on that. A lot.

Tomcat doesn't use a database by default so is this really a Tomcat
issue or an application issue? How is the database configured? Is
connection pooling being used? How are you confirming connection
requests are being directed to the old IP address? Define "restart Tomcat".

Mark

> this is not the case with Jboss. I verified in java
> security, this what we have in java.
> 
> #networkaddress.cache.ttl=-1
> 
> since this property has been disabled, by default ttl will be 30 sec, jboss
> 7 is respecting this value, but not tomcat.
> 
> so far I have tried these things in tomcat.
> 
> https://bz.apache.org/bugzilla/show_bug.cgi?id=33226
> 
> neither of these settings is not working in tomcat
> 
> -Dnetworkaddress.cache.ttl=0 or -Dsun.net.inetaddr.ttl=0
> 
> 
> java version "1.7.0_60"
> tomcat-7.0.56
> os centos 6.
> 
> can someone please help me out to fix this issue
> 


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