instead of recursively locking unconditionally
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/21055 | core#21055]] [15/16]
https://github.com/bitcoin/bitcoin/pull/21055/commits/e11b6496506246882df450586acf735dabedf731
Depends on D11221