Re: fixing old_snapshot_threshold's time->xid mapping - Mailing list pgsql-hackers

From Robert Haas
Subject Re: fixing old_snapshot_threshold's time->xid mapping
Date
Msg-id CA+TgmoZsiQ_6BLNN4LMVYV21GoaQmF=T3Qxjd=4EC_WkEL2b_Q@mail.gmail.com
Whole thread Raw
In response to Re: fixing old_snapshot_threshold's time->xid mapping  (Dilip Kumar <dilipbalaut@gmail.com>)
Responses Re: fixing old_snapshot_threshold's time->xid mapping  (Dilip Kumar <dilipbalaut@gmail.com>)
List pgsql-hackers
On Mon, Apr 20, 2020 at 12:10 AM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> I have started reviewing these patches.  I think, the fixes looks right to me.
>
> + LWLockAcquire(OldSnapshotTimeMapLock, LW_SHARED);
> + mapping->head_offset = oldSnapshotControl->head_offset;
> + mapping->head_timestamp = oldSnapshotControl->head_timestamp;
> + mapping->count_used = oldSnapshotControl->count_used;
> + for (int i = 0; i < OLD_SNAPSHOT_TIME_MAP_ENTRIES; ++i)
> + mapping->xid_by_minute[i] = oldSnapshotControl->xid_by_minute[i];
> + LWLockRelease(OldSnapshotTimeMapLock);
>
> I think memcpy would be a better choice instead of looping it for all
> the entries, since we are doing this under a lock?

When I did it that way, it complained about "const" and I couldn't
immediately figure out how to fix it.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: new heapcheck contrib module
Next
From: Robert Haas
Date:
Subject: Re: design for parallel backup