[9.18.25] Reduce lock contention during RBTDB tree pruning
The log message for commit a9af1ac5 explained:
In some older BIND 9 branches, the extra queuing overhead eliminated by
this change could be remotely exploited to cause excessive memory use.
Due to architectural shift, this branch is not vulnerable to that issue,
but applying the fix to the latter is nevertheless deemed prudent for
consistency and to make the code future-proof.
However, it turned out that having a single queue for the nodes to be pruned increased lock contention to a level where cleaning up nodes from the RBTDB took too long, causing the amount of memory used by the cache to grow indefinitely over time.
This commit reverts the change to the pruning mechanism introduced by commit a9af1ac5 as BIND branches newer than 9.16 were not affected by the excessive event queueing overhead issue mentioned in the log message for the above commit.
(cherry picked from commit eed17611) (cherry picked from commit 4b324567)
Closes #4596 (closed)
Backport of !8765 (merged)
Edited by Ondřej Surý