Re: POC: Cache data in GetSnapshotData() - Mailing list pgsql-hackers

From Andres Freund
Subject Re: POC: Cache data in GetSnapshotData()
Date
Msg-id 20160104085845.m5nrypvmmpea5nm7@alap3.anarazel.de
Whole thread Raw
In response to Re: POC: Cache data in GetSnapshotData()  (Mithun Cy <mithun.cy@enterprisedb.com>)
List pgsql-hackers
On 2015-12-19 22:47:30 -0800, Mithun Cy wrote:
> After some analysis I saw writing to shared memory to store shared snapshot
> is not protected under exclusive write lock, this leads to memory
> corruptions.
> I think until this is fixed measuring the performance will not be much
> useful.

I think at the very least the cache should be protected by a separate
lock, and that lock should be acquired with TryLock. I.e. the cache is
updated opportunistically. I'd go for an lwlock in the first iteration.

If that works nicely we can try to keep several 'snapshot slots' around,
and only lock one of them exclusively. With some care users of cached
snapshots can copy the snapshot, while another slot is updated in
parallel. But that's definitely not step 1.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: WIP: Covering + unique indexes.
Next
From: Amit Langote
Date:
Subject: Re: Multi-tenancy with RLS