Boris Sagadin <sagadin(at)gmail(dot)com> writes:
> I don't know how to create a small, reproducible example, customer
> personal data is contained.
Well, then you're going to have to do your own debugging, because the
information you've provided so far is just about useless for identifying
the problem.
One place to start is by collecting a few stack traces while it seems to
be looping:
https://wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend
regards, tom lane