pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: rbiro@interfacefinancial.com
Subject: BUG #16705: Triggers deferred during commit callback are not executed
Date: Fri, 06 Nov 2020 03:17:02 +0000
Message-ID: <16705-f34c72116d9b2174@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16705
Logged by:          Ross Biro
Email address:      rbiro@interfacefinancial.com
PostgreSQL version: 10.10
Operating system:   Linux
Description:        

If you register a function with RegisterXactCallback that causes a trigger
to be deferred, that trigger is never executed.

The code in CommitTransaction:

     /*
      * Do pre-commit processing that involves calling user-defined code,
such
      * as triggers.  Since closing cursors could queue trigger actions,
      * triggers could open cursors, etc, we have to keep looping until
there's
      * nothing left to do.
      */
     for (;;)
     {
         /*
          * Fire all currently pending deferred triggers.
          */
         AfterTriggerFireDeferred();
 
         /*
          * Close open portals (converting holdable ones into static
portals).
          * If there weren't any, we are done ... otherwise loop back to
check
          * if they queued deferred triggers.  Lather, rinse, repeat.
          */
         if (!PreCommit_Portals(false))
             break;
     }
 
     CallXactCallbacks(is_parallel_worker ? XACT_EVENT_PARALLEL_PRE_COMMIT
                       : XACT_EVENT_PRE_COMMIT);
 
  
It may be possible to just move CallXactCallbacks inside the loop or ad a
second loop around the existing loop and the callbacks.  Alternatively,
perhaps the right solution is to document that commit callbacks cannot do
anything that might defer a trigger, or prevent triggers from being deferred
for the rest of the transactions.



view thread (3+ messages)  latest in thread

Message-ID: <16705-f34c72116d9b2174@postgresql.org>
Permalink:  ../16705-f34c72116d9b2174@postgresql.org/
Also on:    postgresql.org/message-id/16705-f34c72116d9b2174@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, rbiro@interfacefinancial.com
  Subject: Re: BUG #16705: Triggers deferred during commit callback are not executed
  In-Reply-To: <16705-f34c72116d9b2174@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox