[Pdns-users] pdns recursor - unthreaded vs threaded operation

Daniel L. Miller dmiller at amfes.com
Thu Jan 5 03:31:26 UTC 2012

On 12/29/2011 12:55 AM, Fabio Sangiovanni wrote:
> Hello list,
> I'm a newbie of pdns and I'm setting up a recursor-only installation as local dns cache for a high load smtp server.
> I'm using the lua scripting feature as a way to track down MX queries. In particular, the preresolve() function relies on luasql to execute queries on a (local) mysql database.
> This is my problem: if I enable more than one thread in recursor.conf I get the lua script loaded more than once, and ultimately concurrent queries to the db that could mess up the stored data, depending on the execution order of select and update queries by the various threads.
> I'd like to avoid circumventing these race conditions through complicated lua coding, and instead I'd prefer to keep things as simple as possible and limit the number of pdns threads to just 1 ("threads=1" setting in recursor.conf).
> I know that the lua feature is not meant to be used this way, but this could really help me solving a big problem :)
Since I'm just hosting a tiny little site I'm probably missing something 
- but can you please explain what you're trying to accomplish?  If 
you're just logging MX queries as they occur - what's the race condition 
that you see occurring?  Are you totaling requests by client IP - in 
which case I don't see a concern, or by the target address?  If by the 
target address, could you not use a stored procedure that basically 
executes "lock table ; update bigtable set queries = queries + 1 where 
mxip = parameter ; unlock table" (I don't use mysql so I don't know 
mysql-specific syntax - nor how that would impact performance).

Alternatively, have your lua script only add records to a temporary 
table - so there would be potentially multiple entries for a given 
target address.  Then have a cron job periodically grab the temporary 
table, add the values to the primary totals table, and delete the 
temporary values.


More information about the Pdns-users mailing list