Re: [PING] [PATCH v2] parallel pg_restore: avoid disk seeks when jumping short distance forward - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PING] [PATCH v2] parallel pg_restore: avoid disk seeks when jumping short distance forward
Date
Msg-id 376918.1760995762@sss.pgh.pa.us
Whole thread Raw
In response to Re: [PING] [PATCH v2] parallel pg_restore: avoid disk seeks when jumping short distance forward  (Dimitrios Apostolou <jimis@gmx.net>)
List pgsql-hackers
Dimitrios Apostolou <jimis@gmx.net> writes:
> +               /* Dump buffer if full */
> +               if (nonecs->bufdata >= nonecs->buflen)

> Shouldn't this be equality check instead:
>      if (nonecs->bufdata == nonecs->buflen)

Old defensive-programming habit.  The invariant we want to establish
is that there's some space available, ie
    nonecs->bufdata < nonecs->buflen
and if we just test for equality then we haven't proven that.
Agreed that bufdata shouldn't ever be greater than buflen, but if
it somehow is, an equality test here would contribute to making
things worse (writing ever further past the buffer) not better.

> And possibly also assert(nonecs->bufdata <= nonecs->buflen) ?

Maybe, but that code is simple enough that I didn't see a big
need for an assertion check.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: abi-compliance-check failure due to recent changes to pg_{clear,restore}_{attribute,relation}_stats()
Next
From: Mihail Nikalayeu
Date:
Subject: Re: Fix race condition in SSI when reading PredXact->SxactGlobalXmin