Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-22 Thread Amit Kapila
On Mon, Mar 22, 2021 at 7:57 AM Amit Kapila wrote: > > On Mon, Mar 22, 2021 at 3:20 AM Peter Smith wrote: > > > > On Sun, Mar 21, 2021 at 8:54 PM Amit Kapila wrote: > > > > > > On Sat, Mar 20, 2021 at 12:54 PM Peter Smith > > > wrote: > > > > > > > > PSA my patch to correct this by firstly

Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-21 Thread Amit Kapila
On Mon, Mar 22, 2021 at 3:20 AM Peter Smith wrote: > > On Sun, Mar 21, 2021 at 8:54 PM Amit Kapila wrote: > > > > On Sat, Mar 20, 2021 at 12:54 PM Peter Smith wrote: > > > > > > PSA my patch to correct this by firstly doing a HASH_FIND, then only > > > HASH_REMOVE after we've finished using the

Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-21 Thread Andres Freund
Hi, On 2021-03-22 11:20:37 +1300, Thomas Munro wrote: > On Mon, Mar 22, 2021 at 10:50 AM Peter Smith wrote: > > The real problem isn't the Assert. It's all those other usages of ent > > disobeying the API rule: "(NB: in the case of the REMOVE action, the > > result is a dangling pointer that

Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-21 Thread Peter Smith
On Mon, Mar 22, 2021 at 9:21 AM Thomas Munro wrote: > > On Mon, Mar 22, 2021 at 10:50 AM Peter Smith wrote: > > The real problem isn't the Assert. It's all those other usages of ent > > disobeying the API rule: "(NB: in the case of the REMOVE action, the > > result is a dangling pointer that

Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-21 Thread Thomas Munro
On Mon, Mar 22, 2021 at 10:50 AM Peter Smith wrote: > The real problem isn't the Assert. It's all those other usages of ent > disobeying the API rule: "(NB: in the case of the REMOVE action, the > result is a dangling pointer that shouldn't be dereferenced!)" I suppose the HASH_REMOVE case could

Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-21 Thread Peter Smith
On Sun, Mar 21, 2021 at 8:54 PM Amit Kapila wrote: > > On Sat, Mar 20, 2021 at 12:54 PM Peter Smith wrote: > > > > PSA my patch to correct this by firstly doing a HASH_FIND, then only > > HASH_REMOVE after we've finished using the ent. > > > > Why can't we keep using HASH_REMOVE as it is but get

Re: replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-21 Thread Amit Kapila
On Sat, Mar 20, 2021 at 12:54 PM Peter Smith wrote: > > PSA my patch to correct this by firstly doing a HASH_FIND, then only > HASH_REMOVE after we've finished using the ent. > Why can't we keep using HASH_REMOVE as it is but get the output (entry found or not) in the last parameter of

replication cleanup code incorrect way to use of HTAB HASH_REMOVE ?

2021-03-20 Thread Peter Smith
Hi, I found some dubious looking HTAB cleanup code for replication streams (see file:worker.c, function:stream_cleanup_files). viz. -- static void stream_cleanup_files(Oid subid, TransactionId xid) { charpath[MAXPGPATH]; StreamXidHash *ent; /* Remove the xid entry