FS#34346 - [unbound] Setting num_threads to 2 makes unbound fail in ,multicore machine

Attached to Project: Community Packages
Opened by Mike Cloaked (mcloaked) - Sunday, 17 March 2013, 16:59 GMT
Last edited by Gaetan Bisson (vesath) - Tuesday, 19 March 2013, 01:07 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Gaetan Bisson (vesath)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
In a multicore machine it should be possible to have num_threads set to 2 in unbound.conf - however, doing so makes unbound fail to load.

Additional info:
* package version(s)
unbound 1.4.19-2
* config and/or log files etc.
Config file attached

Steps to reproduce:

unbound-checkconf unbound.conf
unbound-checkconf: no errors in unbound.conf.debug

systemctl start unbound using the attached config file. ( it would have to be amended to suit the system being used to run additional tests - and for example make sure that nsd is running or remove the forwarding lines for that, and the log file exists or remove the logging line.)

Unbound will not start. This is possibly an upstream bug?
This task depends upon

Closed by  Gaetan Bisson (vesath)
Tuesday, 19 March 2013, 01:07 GMT
Reason for closing:  Not a bug
Comment by Gaetan Bisson (vesath) - Monday, 18 March 2013, 09:18 GMT
Setting num-threads:2 works for me. If you cannot provide any debugging information, or a minimal unbound.conf to reproduce this issue, there is nothing nobody can do.
Comment by Mike Cloaked (mcloaked) - Monday, 18 March 2013, 10:23 GMT
With the attached config file, and copying to filename unbound.conf placed within the directory /etc/unbound/ and starting the service with:
systemctl start unbound (or restart as relevant) gives:

[root@lapmike3 unbound]# systemctl status unbound
unbound.service - Unbound DNS Resolver
Loaded: loaded (/usr/lib/systemd/system/unbound.service; enabled)
Active: active (running) since Mon 2013-03-18 10:11:58 GMT; 1s ago
Main PID: 841 (unbound)
CGroup: name=systemd:/system/unbound.service
└─841 /usr/sbin/unbound -d

Mar 18 10:11:58 lapmike3 systemd[1]: Started Unbound DNS Resolver.
Mar 18 10:11:58 lapmike3 unbound[841]: [1363601518] unbound[841:0] warning: too many file descriptors requested. The builti...ibevent
Mar 18 10:11:58 lapmike3 unbound[841]: [1363601518] unbound[841:0] warning: continuing with less udp ports: 477

So unbound fails to start fully without the problems listed.

The lines in /var/log/messages.log relevant to this status are:
Mar 18 10:11:58 localhost unbound[841]: [1363601518] unbound[841:0] warning: too many file descriptors requested. The builtinmini-event cannot handle more than 1024. Config for less fds or compile with libevent
Mar 18 10:11:58 localhost unbound[841]: [1363601518] unbound[841:0] warning: continuing with less udp ports: 477

Maybe the package was compiled without libevent (?) so cannot handle the increase requested by the change of num_threads parameter?

If the lines containing:
num-threads: 2
# num-threads: 1
are swapped over by commenting out the first and uncommenting the second with no other changes at all then restarting unbound gives:

[root@lapmike3 unbound]# systemctl restart unbound
[root@lapmike3 unbound]# systemctl status unbound
unbound.service - Unbound DNS Resolver
Loaded: loaded (/usr/lib/systemd/system/unbound.service; enabled)
Active: active (running) since Mon 2013-03-18 10:12:27 GMT; 1s ago
Main PID: 848 (unbound)
CGroup: name=systemd:/system/unbound.service
└─848 /usr/sbin/unbound -d

Mar 18 10:12:27 lapmike3 systemd[1]: Starting Unbound DNS Resolver...
Mar 18 10:12:27 lapmike3 systemd[1]: Started Unbound DNS Resolver.

So it then works without warnings printed merely by changing num_threads from 2 to 1.

The system that this is running on has an Intel Core Duo with 2 processors. T9300 @ 2.50GHz and the system is arch x86_64 with kernel:
3.7.10-1-ARCH

If you need further information I will try to provide the details.



Comment by Gaetan Bisson (vesath) - Monday, 18 March 2013, 21:52 GMT
Your configuration file is 17000 bytes, that's not minimal. Please remove all options you can that have no effect on the actual problem. Also, take a hint from "too many file descriptors"; for some reason it seems you are binding your unbound to >1024 ports.
Comment by Mike Cloaked (mcloaked) - Monday, 18 March 2013, 22:56 GMT
OK, after a lot of googling this evening, I found a useful reference which indicates that there are limits on three parameters that must be set with consideration of a set of rules, that ultimately governs the overall number of file descriptors.

http://www.unbound.net/documentation/howto_optimise.html

So num_threads can't be increased arbitrarily to the number of cores, but if increased above the value of 1, then it has to be done in combination with limiting both the outgoing-range and the num-queries-per-thread parameters.

This was far from immediately obvious but having the following parameters works fine.

num-threads: 2
outgoing-range: 450
num-queries-per-thread: 225

So this is not a bug but it is sufficiently difficult to find how to make it work that I will add this to the wiki for unbound to try to help other users.

This task can be closed.
Comment by Gaetan Bisson (vesath) - Tuesday, 19 March 2013, 01:07 GMT
Thanks.

Loading...