Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, chris(dot)tessels(at)inergy(dot)nl, Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION
Date: 2016-02-25 17:20:06
Message-ID: 29282.1456420806@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andres Freund <andres(at)anarazel(dot)de> writes:
> On 2016-02-25 09:51:49 -0500, Tom Lane wrote:
>> Marking pgprocno volatile is silly. What *is* missing is this:
>>
>> - ProcArrayStruct *arrayP = procArray;
>> + volatile ProcArrayStruct *arrayP = procArray;

> Well, that'll also force arrayP->numProcs to be loaded from memory every
> loop iteration. Not sure if we really want that.

I think we do. The entire point here is not to assume that that storage
isn't changing.

> What bothers me about this right now is that we currently write the
> pgprocno array with:
> memmove(&arrayP->pgprocnos[index + 1], &arrayP->pgprocnos[index],
> (arrayP->numProcs - index) * sizeof(int));
> arrayP->pgprocnos[index] = proc->pgprocno;
> arrayP->numProcs++;
> afaics there's absolutely no guarantee that memmov() will only use
> aligned sizeof(int) writes.

Ugh. That's a separate problem, but yes, it's a problem.

Seems like we can either (1) get rid of that memmove in favor of
a handwritten loop, or (2) give up on unlocked access to the
pgprocnos array. Which performance hit would you rather take?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2016-02-25 17:29:58 Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION
Previous Message Andres Freund 2016-02-25 17:06:38 Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION