Re: POC: Cache data in GetSnapshotData()

From: Andres Freund <andres(at)anarazel(dot)de>
To: Mithun Cy <mithun(dot)cy(at)enterprisedb(dot)com>
Cc: amit(dot)kapila16(at)gmail(dot)com, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: POC: Cache data in GetSnapshotData()
Date: 2016-01-04 08:58:45
Message-ID: 20160104085845.m5nrypvmmpea5nm7@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2016-01-04 09:34:01 Re: Multi-tenancy with RLS
Previous Message David Rowley 2016-01-04 08:49:39 Re: WIP: Covering + unique indexes.