RE: [BUG] Assert failure in ReorderBufferReturnTXN during logical decoding due to leaked specinsert change

Vishal Prasanna <vishal.g@zohocorp.com>

From: Vishal Prasanna <vishal.g@zohocorp.com>
To: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
Cc: "'Álvaro Herrera'" <alvherre@kurilemu.de>, "pgsql-bugs" <pgsql-bugs@lists.postgresql.org>
Date: 2026-03-09T09:39:51Z
Lists: pgsql-bugs
Hi Hayato,

 > ``` 
 > @@ -2663,6 +2655,13 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, 
 >          if (using_subtxn) 
 >              RollbackAndReleaseCurrentSubTransaction(); 
 >  
 > +        /* Free the specinsert change before freeing the ReorderBufferTXN */ 
 > +        if (specinsert != NULL) 
 > +        { 
 > +            ReorderBufferReturnChange(rb, specinsert, true); 
 > +            specinsert = NULL; 
 > +        } 
 > ``` 
 >  
 > In PG17-, we seem to use the term "return" to deallocate the change. Should we follow that? 
 > I have no strong opinion for it. 

Internally, `ReorderBufferReturnChange()` frees the change, which is why comment uses "Free".
Either term is fine for me.


Thanks for the review and for registering the patch.

Regards,
Vishal Prasanna
Zoho Corporation




Commits

  1. logical decoding: Correctly free speculative insertion

  2. Fix memory counter update in ReorderBuffer.