This sounds like an application problem (not to say it can't be a bug of course).
What you could do is the following:
- https://world.mendix.com/display/refguide4/Custom+Settings -> set the LogMinDurationQuery custom setting on your application server (and restart the application) to see if any particular long-running query is causing this or running just around the time this occurs.
- Check the PostgreSQL pg_stat_activity table for more information.
- Check the application log for "deadlock" messages.
- Check the PostgreSQL pg_locks view for more information.
A good forum post on this topic: http://stackoverflow.com/questions/32546735/idle-in-transaction-how-to-get-the-query-caused