Re: tracking commit timestamps

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Anssi Kääriäinen <anssi(dot)kaariainen(at)thl(dot)fi>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Petr Jelinek <petr(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Jaime Casanova <jaime(at)2ndquadrant(dot)com>
Subject: Re: tracking commit timestamps
Date: 2014-11-05 16:30:51
Message-ID: 20141105163051.GX28295@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-www

On 2014-11-05 10:23:15 -0600, Jim Nasby wrote:
>
>
> On 11/5/14, 6:10 AM, Michael Paquier wrote:
> > In addition, I wonder if this feature would be misused. Record
> > transaction ids to a table to find out commit order (use case could be
> > storing historical row versions for example). Do a dump and restore on
> > another cluster, and all the transaction ids are completely meaningless
> > to the system.
> >
> >I think you are forgetting the fact to be able to take a consistent dump using an exported snapshot. In this case the commit order may not be that meaningless..
>
> Anssi's point is that you can't use xmin because it can change, but I think anyone working with this feature would understand that.
>
> > Having the ability to record commit order into an audit table would be
> > extremely welcome, but as is, this feature doesn't provide it.
> >
> >That's something that can actually be achieved with this feature if
> >the SQL interface is able to query all the timestamps in a xid range
> >with for example a background worker that tracks this data
> >periodically. Now the thing is as well: how much timestamp history do
> >we want to keep? The patch truncating SLRU files with frozenID may
> >cover a sufficient range...

> Except that commit time is not guaranteed unique *even on a single
> system*. That's my whole point. If we're going to bother with all the
> commit time machinery it seems really silly to provide a way to
> uniquely order every commit.

Well. I think that's the misunderstanding here. That's absolutely not
what committs is supposed to be used for. For the replication stream
you'd hopefully use logical decoding. That gives you the transaction
data exactly in commit order.

> Clearly trying to uniquely order commits across multiple systems is a
> far larger problem, and I'm not suggesting we attempt that. But for a
> single system AIUI all we need to do is expose the LSN of each commit
> record and that will give you the exact and unique order in which
> transactions committed.

I don't think that's something you should attempt. That's what logical
decoding is for. Hence I see little point in exposing the LSN that way.

Where I think committs is useful is a method for analyzing and resolving
conflicts between multiple systems. In that case you likely can't use
the LSN for anything as it won't be very meaningful. If you get
conflicts below the accuracy of the timestamps you better use another
deterministic method of resolving them - BDR e.g. compares the system
identifier, timeline id, database oid, and a user defined name. While
enforcing that those aren't the same between systems.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2014-11-05 16:34:40 Re: tracking commit timestamps
Previous Message Kevin Grittner 2014-11-05 16:27:18 Re: Time to remove dummy autocommit GUC?

Browse pgsql-www by date

  From Date Subject
Next Message Jim Nasby 2014-11-05 16:34:40 Re: tracking commit timestamps
Previous Message Jim Nasby 2014-11-05 16:23:15 Re: tracking commit timestamps