Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP

From: Bryn Llewellyn <bryn(at)yugabyte(dot)com>
To: Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Ravi Krishna <s_ravikrishna(at)aol(dot)com>, pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Date: 2022-10-18 21:15:20
Message-ID: E05E818F-1CF6-40E2-A66A-8EB119AAB819@yugabyte.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> xof(at)thebuild(dot)com wrote:
>
>> s_ravikrishna(at)aol(dot)com wrote:
>>
>> I am getting error at COMMIT -> cannot commit while a subtransaction is active...
>
> You can commit in a loop, but not in BEGIN / END block that has an exception handler: that creates a subtransaction for the duration of the BEGIN / END.

This surprised me when I first started to use PG (after all those years with ORCL). There are some use cases where this limitation is a nuisance. For example, if you want to implement the famous retry loop (with exponential backoff) for an error that is provoked at commit time... well, you have to do it in client-side code.

Could the limitation be lifted by making tractable internal implementation changes? Or is it rooted in profoundly deep features of the architecture—meaning that it could never be lifted?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ravi Krishna 2022-10-18 21:29:11 Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Previous Message Christophe Pettus 2022-10-18 20:16:29 Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP