Re: POC: Cleaning up orphaned files using undo logs - Mailing list pgsql-hackers

From Kuntal Ghosh
Subject Re: POC: Cleaning up orphaned files using undo logs
Date
Msg-id CAGz5QCJCdaeyo6UTwrWKubyg=iOwKbzQ5B8+DPfHK5_dEXJmPw@mail.gmail.com
Whole thread Raw
In response to Re: POC: Cleaning up orphaned files using undo logs  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hello Andres,

On Tue, Aug 6, 2019 at 1:26 PM Andres Freund <andres@anarazel.de> wrote:
> > +/* Each worker queue is a binary heap. */
> > +typedef struct
> > +{
> > +     binaryheap *bh;
> > +     union
> > +     {
> > +             UndoXidQueue *xid_elems;
> > +             UndoSizeQueue *size_elems;
> > +             UndoErrorQueue *error_elems;
> > +     }                       q_choice;
> > +} UndoWorkerQueue;
>
> As we IIRC have decided to change this into a rbtree, I'll ignore
> related parts of the current code.  What is the status of that work?
> I've checked the git trees, without seeing anything? Your last mail with
> patches
> https://www.postgresql.org/message-id/CAA4eK1KKAFBCJuPnFtgdc89djv4xO%3DZkAdXvKQinqN4hWiRbvA%40mail.gmail.com
> doesn't seem to contain that either?
>
Yeah, we're changing this into a rbtree. This is still work-in-progress.

>
> > .........
> > +#define GetErrorQueueNthElem(n) \
> > +( \
> > +     AssertMacro(!ErrorQueueIsEmpty()), \
> > +     DatumGetPointer(binaryheap_nth(UndoWorkerQueues[ERROR_QUEUE].bh, n)) \
> > +)
>
>
> -ETOOMANYMACROS
>
> I think nearly all of these shouldn't exist. See further below.
>
>
> > +#define SetErrorQueueElem(elem, e_dbid, e_full_xid, e_start_urec_ptr, e_retry_at, e_occurred_at) \
> > +( \
> > +     GetErrorQueueElem(elem).dbid = e_dbid, \
> > +     GetErrorQueueElem(elem).full_xid = e_full_xid, \
> > +     GetErrorQueueElem(elem).start_urec_ptr = e_start_urec_ptr, \
> > +     GetErrorQueueElem(elem).next_retry_at = e_retry_at, \
> > +     GetErrorQueueElem(elem).err_occurred_at = e_occurred_at \
> > +)
>
> It's very very rarely a good idea to have macros that evaluate their
> arguments multiple times. It'll also never be a good idea to get the
> same element multiple times from a queue.  If needed - I'm very doubtful
> of that, given that there's a single caller - it should be a static
> inline function that gets the element once, stores it in a local
> variable, and then updates all the fields.
>
Noted. Earlier, Robert also raised the point of using so many macros.
He also suggested to use a single type of object that stores all the
information we need. It'll make things simpler and easier to
understand. In the upcoming patch set, we're removing all these
changes.


-- 
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: partition routing layering in nodeModifyTable.c
Next
From: Amit Langote
Date:
Subject: Re: Handling RestrictInfo in expression_tree_walker