[v12.x] backport #28609
The difference to the original PR are that the atomics assertion fail on older code and had to be changed.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines