Redmine #6602: Fix LMDB max_readers setting being too low under load.

We did not previously take cf-hub into account when calculating how
large the max_readers setting can be. In the worst case, every thread
in both cf-serverd and child in cf-hub can have it open at the same
time, as well as occasional cf-agents, so account for that.

Also, improve the error checking when setting the maximum readers.
LMDB will only succeed at setting the maxreaders limit if no other
database handles are open, including in other processes, despite
always returning success. This means that we should check afterwards
whether the value we tried to set was honored, and warn if it wasn't.
If there is a window of opportunity where the database is not open,
the problem will correct itself, but if the load is so high that the
database is constantly open, then the administrator may have to take
action and restart CFEngine.

Also moved this to the database opening code itself, so that it is
active for every database. This way we won't hit the problem again in
some future unforeseen database.
Redmine #6602: Enable LMDB NOSYNC mode on hub to improve performance.

NOSYNC mode will prevent excessive fsync'ing to disk, esp. with the
busy lastseen database. This opens up to corruption issues if the
machine is unexpectedly shut down or crashes.

For the lock database we solved the corruption issue by making atomic
backups of the database and restoring it on restart, but this method
is not generic and needs to be adapted if we want to the same kind of
protection for other databases (see Redmine #6817). For now we
consider the corruption issue an acceptable compromise since a hard
shutdown is quite unlikely in serious production environments, and the
performance is quite bad in this area.

On agent nodes we keep the SYNC flag on, since they are much less
impacted by the performance problems (they do not serve thousands of
CFEngine clients), and fixing corruption on agent nodes is
operationally more work.