Re: Enables to call Unregister*XactCallback() in Call*XactCallback() - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Enables to call Unregister*XactCallback() in Call*XactCallback()
Date
Msg-id 20220403163923.zeyslujq6q4aik7u@alap3.anarazel.de
Whole thread Raw
In response to Enables to call Unregister*XactCallback() in Call*XactCallback()  (Hao Wu <gfphoenix78@gmail.com>)
Responses Re: Enables to call Unregister*XactCallback() in Call*XactCallback()  (Hao Wu <gfphoenix78@gmail.com>)
Re: Enables to call Unregister*XactCallback() in Call*XactCallback()  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

On 2022-03-29 14:48:54 +0800, Hao Wu wrote:
> It's a natural requirement to unregister the callback for transaction or
> subtransaction when the callback is invoked, so we don't have to
> unregister the callback somewhere.

You normally shouldn'd need to do this frequently - what's your use case?
UnregisterXactCallback() is O(N), so workloads registering / unregistering a
lot of callbacks would be problematic.

> Luckily, we just need a few lines of code to support this feature,
> by saving the next pointer before calling the callback.

That seems reasonable...

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: A qsort template
Next
From: Joseph Koshakow
Date:
Subject: Re: Fix overflow in DecodeInterval