From: Nishant, Fnu <nishantf@amazon.com>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Nasby, Jim <nasbyj@amazon.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Maxim Boguk <maxim.boguk@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: Jeremy Finzel <finzelj@gmail.com>
Subject: Re: found xmin from before relfrozenxid on pg_catalog.pg_authid
Date: Tue, 29 May 2018 18:06:12 +0000
Message-ID: <8CF9E2FB-B73B-4C66-8E56-529A162D47CC@amazon.com> (raw)
In-Reply-To: <20180528195732.pl7pt77itacsfw6m@alap3.anarazel.de>
References: <20180524211311.tnswfnjwnii54htx@alvherre.pgsql>
<20180525203736.crkbg36muzxrjj5e@alap3.anarazel.de>
<15665.1527284857@sss.pgh.pa.us>
<20180525220531.43ia22l2d3jspbng@alap3.anarazel.de>
<20180526204506.ql5pesq6t2jbpuy5@alap3.anarazel.de>
<842C9FB7-B9FB-43B9-AF28-9C5324F23ED8@amazon.com>
<D670D841-C88B-4D28-B852-16ABBDBA5F88@anarazel.de>
<10046.1527441741@sss.pgh.pa.us>
<20180527200006.hbwa2h7nfuunmnza@alap3.anarazel.de>
<5AA972C7-DF64-4EAF-8828-A21AE05E18CB@amazon.com>
<20180528195732.pl7pt77itacsfw6m@alap3.anarazel.de>
Hi,
> To achieve this we can allocate Form_pg_class structures (for shared
> relations… a small number) on shared memory.
But why would this be necessary / a good idea? Even if we decided it
were, it seems like it'd end up being quite invasive. But I doubt it's
a good plan, because relcache entries want / need to be updated
differently in the transaction that does the changes (as it needs to see
the effect of catalog changes before commit) than other sessions (which
only should see them after commit).
It will be a good idea as, we can avoid maintaining file (creation/deletion/updation) for period of engine running and we do not need to invalidate other backend cache.
For transaction(which change catalog), we can allocate a new private Form_pg_class structure and do operations on it and update shared structure post commit.
Routine roughly will be-
1) A backend having a relcache entry for a shared rel where rd_rel part points to shared memory structure.
Rel->rd_rel is storing a shared memory pointer.
2) Wants to update the entry...allocate a new private structure and memcpy the shared content to this new memory and point rd_rel to private memory
Rel->rd_rel is storing a pointer to process specific structure.
3) Transaction committed and we copy the private memory content to shared memory area and point rd_rel again to shared memory.
4) free private memory.
5) Other backends do not do any invalidation but still get the latest updated values.
Why is this good idea?
Lets take an example (assuming we have 1000 postgres backends running).
With shared memory scheme-
Operation wise, for a transaction, we allocate/free once (private memory allocation) and memcpy data to and fro (from shared to private and back to shared)...
Overall memory footprint 1 shared copy and 1 private only when updating.
No file creation/deletion/updation.
With current file scheme-
Operation wise, for a transaction, we use private cache but we need to invalidate 1000 other caches( which will be atleast 1000 memcpy and allocate/free) and may involve reading back in page of pg_class.
Overall memory footprint 1000 private copies.
We have to create/delete/update init file and synchronize around it.
Having said that we may not worry about transaction for updating all values...(I think relfrozenxid can be updated by a CAS operation ...still thinking on it).
-Nishant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: nishantf@amazon.com, andres@anarazel.de, tgl@sss.pgh.pa.us, nasbyj@amazon.com, alvherre@2ndquadrant.com, pgsql-hackers@postgresql.org, maxim.boguk@gmail.com, pg@bowt.ie, finzelj@gmail.com
Subject: Re: found xmin from before relfrozenxid on pg_catalog.pg_authid
In-Reply-To: <8CF9E2FB-B73B-4C66-8E56-529A162D47CC@amazon.com>
References: <20180524211311.tnswfnjwnii54htx@alvherre.pgsql> <20180525203736.crkbg36muzxrjj5e@alap3.anarazel.de> <15665.1527284857@sss.pgh.pa.us> <20180525220531.43ia22l2d3jspbng@alap3.anarazel.de> <20180526204506.ql5pesq6t2jbpuy5@alap3.anarazel.de> <842C9FB7-B9FB-43B9-AF28-9C5324F23ED8@amazon.com> <D670D841-C88B-4D28-B852-16ABBDBA5F88@anarazel.de> <10046.1527441741@sss.pgh.pa.us> <20180527200006.hbwa2h7nfuunmnza@alap3.anarazel.de> <5AA972C7-DF64-4EAF-8828-A21AE05E18CB@amazon.com> <20180528195732.pl7pt77itacsfw6m@alap3.anarazel.de> <8CF9E2FB-B73B-4C66-8E56-529A162D47CC@amazon.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox