pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <bruce@momjian.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Need Multixact Freezing Docs
Date: Fri, 5 Sep 2014 19:39:36 -0400
Message-ID: <20140905233936.GA20146@momjian.us> (raw)
In-Reply-To: <CA+TgmoYq_aoxCZOz6B0YsYSJwxccOd9CZ_Uv9Ry5M0ZphS2Nxw@mail.gmail.com>
References: <WM!a70b2681d2ac0ed55eb2d3eed44e6730e9c71b5fad8c5320503fde8b18a03fd98a6af6244821ca39d47c1d9e758c45ff!@asav-2.01.com>
	<534EC69B.9010107@agliodbs.com>
	<20140416203057.GQ5822@eldon.alvh.no-ip.org>
	<WM!fa9379a39fd015511ce3872138589081b6e688c26b67a6801364b609b26642096bfd329ce2cb7eb090da00879e59e525!@asav-3.01.com>
	<534EEA8E.5070407@agliodbs.com>
	<20140828160945.GQ7046@eldon.alvh.no-ip.org>
	<WM!ab5645a7cd6e67e13c84377c9d568b52e17cdb08a0e5ba356fd95d14e5fcf75f114940bb9868c8c1e23e1d58680d5795!@asav-3.01.com>
	<53FF5991.9060302@agliodbs.com>
	<20140903001859.GB14893@momjian.us>
	<CA+TgmoYq_aoxCZOz6B0YsYSJwxccOd9CZ_Uv9Ry5M0ZphS2Nxw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On Wed, Sep  3, 2014 at 05:17:17PM -0400, Robert Haas wrote:
> > I had a look at this and came upon a problem --- there is no multi-xid
> > SQL data type, and in fact the system catalogs that store mxid values
> > use xid, e.g.:
> >
> >          relminmxid     | xid       | not null
> >
> > With no mxid data type, there is no way to do function overloading to
> > cause age to call the mxid variant.
> >
> > Should we use an explicit mxid_age() function name?  Add an mxid data
> > type?
> 
> Maybe both.  But mxid_age() is probably the simpler way forward just to start.

OK, patch applied using mxid_age() and no new data type.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

mxid-age.diff (text/x-diff, 4.3K) download diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml new file mode 100644 index cf174f0..d692308 *** a/doc/src/sgml/maintenance.sgml --- b/doc/src/sgml/maintenance.sgml *************** HINT: Stop the postmaster and vacuum th *** 640,646 **** possible multixact ID still appearing in any tuple of that table. If this value is older than <xref linkend="guc-vacuum-multixact-freeze-table-age">, a whole-table ! scan is forced. Whole-table <command>VACUUM</> scans, regardless of what causes them, enable advancing the value for that table. Eventually, as all tables in all databases are scanned and their oldest multixact values are advanced, on-disk storage for older --- 640,651 ---- possible multixact ID still appearing in any tuple of that table. If this value is older than <xref linkend="guc-vacuum-multixact-freeze-table-age">, a whole-table ! scan is forced. <function>mxid_age()</> can be used on ! <structname>pg_class</>.<structfield>relminmxid</> to find its age. ! </para> ! ! <para> ! Whole-table <command>VACUUM</> scans, regardless of what causes them, enable advancing the value for that table. Eventually, as all tables in all databases are scanned and their oldest multixact values are advanced, on-disk storage for older diff --git a/src/backend/utils/adt/xid.c b/src/backend/utils/adt/xid.c new file mode 100644 index 602a9e5..ecb3cf5 *** a/src/backend/utils/adt/xid.c --- b/src/backend/utils/adt/xid.c *************** *** 16,21 **** --- 16,22 ---- #include <limits.h> + #include "access/multixact.h" #include "access/transam.h" #include "access/xact.h" #include "libpq/pqformat.h" *************** xid_age(PG_FUNCTION_ARGS) *** 100,105 **** --- 101,121 ---- PG_RETURN_INT32(INT_MAX); PG_RETURN_INT32((int32) (now - xid)); + } + + /* + * mxid_age - compute age of a multi XID (relative to latest stable mxid) + */ + Datum + mxid_age(PG_FUNCTION_ARGS) + { + TransactionId xid = PG_GETARG_TRANSACTIONID(0); + MultiXactId now = ReadNextMultiXactId(); + + if (!MultiXactIdIsValid(xid)) + PG_RETURN_INT32(INT_MAX); + + PG_RETURN_INT32((int32) (now - xid)); } /* diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h new file mode 100644 index e1b62a5..e0875b7 *** a/src/include/catalog/catversion.h --- b/src/include/catalog/catversion.h *************** *** 53,58 **** */ /* yyyymmddN */ ! #define CATALOG_VERSION_NO 201408281 #endif --- 53,58 ---- */ /* yyyymmddN */ ! #define CATALOG_VERSION_NO 201409021 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h new file mode 100644 index 5176ed0..09e138b *** a/src/include/catalog/pg_proc.h --- b/src/include/catalog/pg_proc.h *************** DATA(insert OID = 1180 ( abstime PG *** 1277,1282 **** --- 1277,1284 ---- DESCR("convert timestamp with time zone to abstime"); DATA(insert OID = 1181 ( age PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 23 "28" _null_ _null_ _null_ _null_ xid_age _null_ _null_ _null_ )); DESCR("age of a transaction ID, in transactions before current transaction"); + DATA(insert OID = 3218 ( mxid_age PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 23 "28" _null_ _null_ _null_ _null_ mxid_age _null_ _null_ _null_ )); + DESCR("age of a multi-transaction ID, in multi-transactions before current multi-transaction"); DATA(insert OID = 1188 ( timestamptz_mi PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1186 "1184 1184" _null_ _null_ _null_ _null_ timestamp_mi _null_ _null_ _null_ )); DATA(insert OID = 1189 ( timestamptz_pl_interval PGNSP PGUID 12 1 0 0 0 f f f f t f s 2 0 1184 "1184 1186" _null_ _null_ _null_ _null_ timestamptz_pl_interval _null_ _null_ _null_ )); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h new file mode 100644 index 78cc0a0..d88e7a3 *** a/src/include/utils/builtins.h --- b/src/include/utils/builtins.h *************** extern Datum xidrecv(PG_FUNCTION_ARGS); *** 845,850 **** --- 845,851 ---- extern Datum xidsend(PG_FUNCTION_ARGS); extern Datum xideq(PG_FUNCTION_ARGS); extern Datum xid_age(PG_FUNCTION_ARGS); + extern Datum mxid_age(PG_FUNCTION_ARGS); extern int xidComparator(const void *arg1, const void *arg2); extern Datum cidin(PG_FUNCTION_ARGS); extern Datum cidout(PG_FUNCTION_ARGS);

view thread (18+ messages)  latest in thread

Message-ID: <20140905233936.GA20146@momjian.us>
Permalink:  ../20140905233936.GA20146@momjian.us/
Also on:    postgresql.org/message-id/20140905233936.GA20146@momjian.us

 ·  · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: bruce@momjian.us, robertmhaas@gmail.com, josh@agliodbs.com, alvherre@2ndquadrant.com
  Subject: Re: Need Multixact Freezing Docs
  In-Reply-To: <20140905233936.GA20146@momjian.us>

* 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