synchronized snapshots

From: Joachim Wieland <joe(at)mcknight(dot)de>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: synchronized snapshots
Date: 2010-01-08 19:36:44
Message-ID: dc7b844e1001081136k12ae4eq6d1f7689ed1adfe6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The attached patch implements the idea of Heikki / Simon published in

http://archives.postgresql.org/pgsql-hackers/2009-11/msg00271.php

Since nobody objected to the idea in general, I have implemented it.

As this is not currently used anywhere it doesn't give immediate benefit, it
is however a prerequisite for a parallel version of pg_dump that quite some
people (including myself) seem to be interested in.

Here's the comment from the patch explaining it in more detail:

/*
* This function is for synchronization of snapshots: It can be called by
* new transactions to get the same snapshots. It's signature is
*
* pg_synchronize_snapshots(text, int, int);
*
* The first parameter is an identifier so that several groups can request
* synchronized snapshots concurrently.
*
* The second parameter is the number of backends that are expected to connect
* in the current group (i.e. same identifier).
*
* The third parameter is the timeout in milliseconds.
*
* Note that once we are holding the ProcArrayLock in shared mode we are
* severely hitting the usability of the database server: for example, nobody
* can commit nontrivial transactions during that time nor can you establish a
* new connection! This is why you need to be superuser to use this function.
*
* The idea is that from one connection you call for example
*
* pg_synchronize_snapshot('7bd0320c4ff9252716972e160fb33b8a', 4, 1000)
*
* and then have 1000ms to call with some other four (already connected)
* sessions
*
* BEGIN TRANSACTION;
* SELECT pg_synchronize_snapshot_taken('7bd0320c4ff9252716972e160fb33b8a');
*
* If all four pg_synchronize_snapshot_taken() calls return true and the
* function pg_synchronize_snapshot() returns true as well, you can go on and
* all four transactions now see the same snapshot (which in general is not the
* snapshot that the transaction saw that has initially called
* pg_synchronize_snapshot()).
*/

Thoughts?

Joachim

Attachment Content-Type Size
sync_snapshot.1.diff text/x-diff 11.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-01-08 19:45:05 Re: Setting oom_adj on linux?
Previous Message Alex Hunsaker 2010-01-08 19:30:44 Re: Setting oom_adj on linux?