I’ll assume your using PostgreSQL, I would start with checking the logs.
tail -f /usr/local/var/log/postgres.log
My guess is you have a transaction failed or a malformed SQL transaction for whatever reason was passed to the DB, maybe datatype format etc… DMY, MDY as an example, ( could be anything, without a log i am guessing) and the DB failed to roll back or release the savepoint, you need to read the logs when it happens.
I would read the logs and restart the system before I would do anything else.
This error most likely is caused by e.g. a trigger with no longer existing information.
Have a look what trigger might be affected and correct those. Should work after that.