Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XQ36a-0008Ar-TI for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Sep 2014 23:39:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XQ36a-0006uv-D6 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Sep 2014 23:39:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XQ36Z-0006ug-AO for pgsql-hackers@postgresql.org; Fri, 05 Sep 2014 23:39:47 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XQ36U-0001K6-VD for pgsql-hackers@postgresql.org; Fri, 05 Sep 2014 23:39:46 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1XQ36O-0005Sq-56; Fri, 05 Sep 2014 19:39:36 -0400 Date: Fri, 5 Sep 2014 19:39:36 -0400 From: Bruce Momjian To: Robert Haas Cc: Josh Berkus , Alvaro Herrera , "pgsql-hackers@postgresql.org" Subject: Re: Need Multixact Freezing Docs Message-ID: <20140905233936.GA20146@momjian.us> References: <534EC69B.9010107@agliodbs.com> <20140416203057.GQ5822@eldon.alvh.no-ip.org> <534EEA8E.5070407@agliodbs.com> <20140828160945.GQ7046@eldon.alvh.no-ip.org> <53FF5991.9060302@agliodbs.com> <20140903001859.GB14893@momjian.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0OAP2g/MAC+5xKAE" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -3.6 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. + --0OAP2g/MAC+5xKAE Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mxid-age.diff" 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 , a whole-table ! scan is forced. Whole-table 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 , a whole-table ! scan is forced. mxid_age() can be used on ! pg_class.relminmxid to find its age. ! ! ! ! Whole-table 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 + #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); --0OAP2g/MAC+5xKAE Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --0OAP2g/MAC+5xKAE--