ERROR : cannot commit while a portal is pinned from plpython

From: Ludwig Isaac Lim <ludz_lim(at)yahoo(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: ERROR : cannot commit while a portal is pinned from plpython
Date: 2022-12-02 08:45:06
Message-ID: 1061909348.200334.1669970706749@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Browse pgsql-general by date

  From Date Subject
Next Message Amitabh Kant 2022-12-02 10:33:18 Re: Finding free time period on non-continous tstzrange field values
Previous Message Martijn Tonies (Upscene Productions) 2022-12-02 07:49:32 Re: Stored procedure code no longer stored in v14 and v15, changed behaviour