[v9_18] Resolve "stale-serve and RPZ put in SERVFAIL cache unexpected record"
Backport of !7096 (merged).
Partial backport of !6417 (merged) to silence Clang Static Analyzer. See the following two threads for more information:
Closes #3678 (closed).
Edited by Michał Kępień