Pi-hole becomes unresponsive during pihole -d and -q

As the pihole -q issue seems to have the same cause as written here I will mention the outcome here to save prospective readers almost 100 topic replies.

It came down to different versions of awk: the issue occurred only with mawk but not with gawk. So installing gawk fixed it.

Final solution was to circumvent awk in pihole -q and using shell regex checking.
At the moment one can try it with

pihole checkout core fix/awkInQuery