Hello:
I noticed the following lines in my PostgreSQL log file today:
2022-12-01 14:16:54.517 UTC [10073] ERROR: cannot commit while a portal is pinned
2022-12-01 14:16:54.517 UTC [10073] STATEMENT: call p_annotate_db_stats()
The process ID can be traced to plpython procedure call.
What is baffling is there's no commit (or rollback) inside the stored procedure call.
The notable changes I made to the stored procedure is:
adding this block of code
try:
--processing stuff
except:
exc_type, exc_value, tb = sys.exc_info()
if tb is None:
print("No exception / traceback information", file=sys.stderr)
sys.exit(-1)
prev = tb
curr = tb.tb_next
while curr is not None:
prev = curr
curr = curr.tb_next
print(prev.tb_frame.f_locals, file=sys.stderr)
traceback.print_exception(*sys.exc_info())
print("Exiting", file=sys.stderr)
The stored procedure is executed via psql call using the following command in bash:
nohup psql -c "call p_annotate_db_stats()" &
Postgresql version : PostgreSQL 14.6 on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat
7.3.1-15),64-bit
Python version : Python 3.7.10
What could be the cause of the error? Thank you.
Regards,
Ludwig Lim