kevincdurand1 / quadra

Automatically exported from code.google.com/p/quadra
0 stars 0 forks source link

make sure we don't cache IPs too much #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Some servers disappeared from the master server at some point, and
reappeared after they had been restarted.

The master server is currently on a dynamic IP, with the DNS being updated,
but if there is too much IP address caching, this would cause this kind of
problem.

Original issue reported on code.google.com by pphaneuf on 18 Mar 2008 at 10:44

GoogleCodeExporter commented 8 years ago
Is there any way to make Quadra respect the TTL of the DNS? And if one of you 
runs
the master server, then you may want to reduce the TTL.

Original comment by Shrapnel.City@gmail.com on 24 Mar 2008 at 8:42

GoogleCodeExporter commented 8 years ago

Original comment by pphaneuf on 24 Mar 2008 at 8:15

GoogleCodeExporter commented 8 years ago
Looks like Qserv::http_addr (and Qserv::http_port) are the culprit, in
source/qserv.cpp. If we just cleared them on any kind of error, it should 
probably
work just fine (unless whoever takes over the IP of qserv *also* has a qserv in 
the
same location!).

Stéphane, you wrote that, could you give that a quick look? It should be 
really easy
to fix, if there is a good place to clear the cache...

Original comment by pphaneuf on 24 Mar 2008 at 8:37

GoogleCodeExporter commented 8 years ago
Why do you cache the IP? Doing a DNS lookup on every request should avoid such 
problems.

I changed in qserv.cpp (line 227) the section

  if(http_addr)
    req=new Http_post(host, http_addr, http_port, path);
  else
    req=new Http_post(host, port, path);

to

  req=new Http_post(host, port, path);

and the problem with the dynamic IP seems to be gone. At least this config runs 
since
yesterday on the NX servers without a problem.

Original comment by pie...@network-x.de on 29 Mar 2008 at 1:58

GoogleCodeExporter commented 8 years ago
That will indeed prevent this exact problem, but the game server might 
experience
momentarily lag when it does a qserv update, since the DNS resolution is done 
in a
blocking way on Linux (argh).

The *best* way to fix that would be to remove the caching code entirely 
(similarly to
what you've done), but make the DNS resolution asynchronous, so that the game 
is not
slowed down. But that's a bigger project, if only to figure out what's going on
exactly in the current code (Stéphane wrote this what, seven, eight years 
ago?)...

What I have in mind is more of an easy fix that will give us most of the result 
with
a very small scope: keep using the cache (so lag is avoided), but when we fail 
to
update qserv, for any reason, clear the cache. If, for some bad luck, whoever 
picks
up the old IP address of the master server when it changes IP *also* has a 
qserv,
then we're screwed. I figure the odds are pretty low. :-)

Even then, we could put in a TTL (time to live), where we're use the cache up 
to X
times, then clear it.

Original comment by pphaneuf on 30 Mar 2008 at 4:29

GoogleCodeExporter commented 8 years ago
This one is pretty important, as it prevents servers from updating themselves. 
I got
the NX server admin, piezza, to put in a temporary workaround in his version of
Quadra, since he had a home-built version from Subversion anyway, but this is 
broken.

Original comment by pphaneuf on 1 Apr 2008 at 2:34

GoogleCodeExporter commented 8 years ago

Original comment by pphaneuf on 20 Apr 2008 at 6:24

GoogleCodeExporter commented 8 years ago
Should be fixed by r495.

Original comment by pphaneuf on 21 Apr 2008 at 3:30

GoogleCodeExporter commented 8 years ago
Merged into the quadra-sdl branch with r496.

Original comment by pphaneuf on 21 Apr 2008 at 3:51