Re: Problem with txid_snapshot_in/out() functionality

From: Jan Wieck <jan(at)wi3ck(dot)info>
To: Marko Kreen <markokr(at)gmail(dot)com>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Problem with txid_snapshot_in/out() functionality
Date: 2014-04-13 18:22:07
Message-ID: 534AD5CF.5040702@wi3ck.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04/13/14 08:27, Marko Kreen wrote:
> On Sat, Apr 12, 2014 at 02:10:13PM -0400, Jan Wieck wrote:
>> Since it doesn't seem to produce any side effects, I'd think that
>> making the snapshot unique within txid_current_snapshot() and
>> filtering duplicates on input should be sufficient and eligible for
>> backpatching.
>
> Agreed.
>
>> The attached patch adds a unique loop to the internal
>> sort_snapshot() function and skips duplicates on input. The git
>> commit is here:
>>
>> https://github.com/wieck/postgres/commit/a88a2b2c25b856478d7e2b012fc718106338fe00
>
>> static void
>> sort_snapshot(TxidSnapshot *snap)
>> {
>> + txid last = 0;
>> + int nxip, idx1, idx2;
>> +
>> if (snap->nxip > 1)
>> + {
>> qsort(snap->xip, snap->nxip, sizeof(txid), cmp_txid);
>> + nxip = snap->nxip;
>> + idx1 = idx2 = 0;
>> + while (idx1 < nxip)
>> + {
>> + if (snap->xip[idx1] != last)
>> + last = snap->xip[idx2++] = snap->xip[idx1];
>> + else
>> + snap->nxip--;
>> + idx1++;
>> + }
>> + }
>> }
>
> I think you need to do SET_VARSIZE also here. Alternative is to
> move SET_VARSIZE after sort_snapshot().
>
> And it seems the drop-double-txid logic should be added also to
> txid_snapshot_recv(). It seems weird to have it behave differently
> from txid_snapshot_in().
>

Thanks,

yes on both issues. Will create another patch.

Jan

--
Jan Wieck
Senior Software Engineer
http://slony.info

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-04-13 18:23:12 Re: [PATCH] Negative Transition Aggregate Functions (WIP)
Previous Message Tom Lane 2014-04-13 16:09:28 Re: test failure on latest source