Same issue and took us ages to work out that is was JIT! The default is on, and setting off solves the problem. I have seen several blogs reporting the same and so wonder why this default is on?
I can confirm this, even in v16 we've turned JIT off.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных