[#1011398] pgbouncer DNS resolution does not look up hostnames in TCP mode

View Trackers | Bugs | Download .csv | Monitor

Date:
2013-11-11 21:51
Priority:
3
State:
Open
Submitted by:
Shashank Bharadwaj (shashank)
Assigned to:
Nobody (None)
Category:
None
Group:
None
Resolution:
None
 
Summary:
pgbouncer DNS resolution does not look up hostnames in TCP mode

Detailed description
We had configured pgbouncer to use DNS to find the database:

$ cat /etc/pgbouncer.ini
<snip/>
[databases]
mytestdabase1 = host=db.example.com dbname=mytestdabase1 port=5432
mytestdabase2 = host=db.example.com dbname=mytestdabase2 port=5432

For a while, our internal DNS server were unable to resolve DNS in TCP mode, during which time pgbouncer was unable to resolve the database 'db.example.com' and failed with the error message:
----------------------
2013-11-06 11:48:16.278 3534 WARNING lookup failed: db.example.com: result=-4
2013-11-06 11:48:16.648 3534 WARNING C-0x2b5a4682f718: mytestdatabase1/reader@10.1.1.8:52826 Pooler Error: no working server connection
2013-11-06 11:48:16.758 3534 WARNING C-0x8167890: mytestdatabase2/reader@10.1.1.9:38565 Pooler Error: no working server connection
----------------------

But during that time, lookup using TCP was entirely possible:

----------------------
$ host db.example.com
;; Truncated, retrying in TCP mode.
db.example.com is an alias for db3.example.com
db3.example.com has address 10.1.5.1
----------------------

The above message shows that DNS resolution was truncated in UDP mode (that's the default mode), and it succeeded in TCP mode.

We think that pgbouncer's resolver libraries can't (or won't) use TCP, we should probably fix that. It's entirely
possible to have valid data that exceeds 512 bytes (and thereby can't run over UDP?)

As a temporary fix to the issue, we have by-passed the DNS lookups entirely by hardcoding IP addresses in the ini file:
----------------------
$ cat /etc/pgbouncer.ini
<snip/>
[databases]
mytestdabase1 = host=10.1.5.1 dbname=mytestdabase1 port=5432
mytestdabase2 = host=10.1.5.1 dbname=mytestdabase2 port=5432
----------------------

Let me know if you need more information!
Shashank

[PS: thanks for your effort on pgbouncer, it's an amazing tool!]

Followup

Message
Date: 2013-11-14 09:07
Sender: Heikki Linnakangas

pgbouncer has many alternative "backends" for doing DNS lookups. See README,
section DNS lookup support.

You can tell which backend is being by looking at the log message pgbouncer prints when it starts up. For example:

2013-11-14 03:59:39.297 8424 LOG process up: pgbouncer 1.5.4, libevent 1.4.10-stable (poll), adns: compat

That last ands: entry indicates the DNS backend being used. "compat" means that it uses glibc's getaddrinfo_a() function.

According to the Programming with libevent online book, libevent doesn't support TCP lookups, so if you're using the libevent backend, TCP lookups won't work (see http://www.wangafu.net/~nickm/libevent-book/Ref9_dns.html). I'm pretty sure the getaddrinfo_a() function does support TCP lookups - it's just an interface to the regular libc DNS lookups after all.

In short, I believe the TCP lookup capability depends on the backend being used, and there isn't much we can do about it in the pgbouncer code itself. We probably should document that better, though, and perhaps reconsider the default backend chosen.

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge