aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2014-12-03 11:53:02 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2014-12-03 11:53:02 -0300
commit73c986adde5d73a5e2555da9b5c8facedb146dcd (patch)
tree29ee4f6c800c3614cfd3316c7026e30e552e12a4 /doc/src
parent6597ec9be6a9ed50390f73235d6654ec32a0b944 (diff)
downloadpostgresql-73c986adde5d73a5e2555da9b5c8facedb146dcd.tar.gz
postgresql-73c986adde5d73a5e2555da9b5c8facedb146dcd.zip
Keep track of transaction commit timestamps
Transactions can now set their commit timestamp directly as they commit, or an external transaction commit timestamp can be fed from an outside system using the new function TransactionTreeSetCommitTsData(). This data is crash-safe, and truncated at Xid freeze point, same as pg_clog. This module is disabled by default because it causes a performance hit, but can be enabled in postgresql.conf requiring only a server restart. A new test in src/test/modules is included. Catalog version bumped due to the new subdirectory within PGDATA and a couple of new SQL functions. Authors: Álvaro Herrera and Petr Jelínek Reviewed to varying degrees by Michael Paquier, Andres Freund, Robert Haas, Amit Kapila, Fujii Masao, Jaime Casanova, Simon Riggs, Steven Singer, Peter Eisentraut
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/config.sgml14
-rw-r--r--doc/src/sgml/func.sgml39
-rw-r--r--doc/src/sgml/ref/pg_resetxlog.sgml19
-rw-r--r--doc/src/sgml/storage.sgml5
4 files changed, 76 insertions, 1 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index ab8c2637d75..e3713d3b490 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2673,6 +2673,20 @@ include_dir 'conf.d'
</listitem>
</varlistentry>
+ <varlistentry id="guc-track-commit-timestamp" xreflabel="track_commit_timestamp">
+ <term><varname>track_commit_timestamp</varname> (<type>bool</type>)</term>
+ <indexterm>
+ <primary><varname>track_commit_timestamp</> configuration parameter</primary>
+ </indexterm>
+ <listitem>
+ <para>
+ Record commit time of transactions. This parameter
+ can only be set in <filename>postgresql.conf</> file or on the server
+ command line. The default value is <literal>off</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</sect2>
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index baf81ee0404..62ec275a9e5 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15938,6 +15938,45 @@ SELECT collation for ('foo' COLLATE "de_DE");
For example <literal>10:20:10,14,15</literal> means
<literal>xmin=10, xmax=20, xip_list=10, 14, 15</literal>.
</para>
+
+ <para>
+ The functions shown in <xref linkend="functions-commit-timestamp">
+ provide information about transactions that have been already committed.
+ These functions mainly provide information about when the transactions
+ were committed. They only provide useful data when
+ <xref linkend="guc-track-commit-timestamp"> configuration option is enabled
+ and only for transactions that were committed after it was enabled.
+ </para>
+
+ <table id="functions-commit-timestamp">
+ <title>Committed transaction information</title>
+ <tgroup cols="3">
+ <thead>
+ <row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>
+ <indexterm><primary>pg_xact_commit_timestamp</primary></indexterm>
+ <literal><function>pg_xact_commit_timestamp(<parameter>xid</parameter>)</function></literal>
+ </entry>
+ <entry><type>timestamp with time zone</type></entry>
+ <entry>get commit timestamp of a transaction</entry>
+ </row>
+
+ <row>
+ <entry>
+ <indexterm><primary>pg_last_committed_xact</primary></indexterm>
+ <literal><function>pg_last_committed_xact()</function></literal>
+ </entry>
+ <entry><parameter>xid</> <type>xid</>, <parameter>timestamp</> <type>timestamp with time zone</></entry>
+ <entry>get transaction ID and commit timestamp of latest committed transaction</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
</sect1>
<sect1 id="functions-admin">
diff --git a/doc/src/sgml/ref/pg_resetxlog.sgml b/doc/src/sgml/ref/pg_resetxlog.sgml
index aba7185f355..59280f01cb1 100644
--- a/doc/src/sgml/ref/pg_resetxlog.sgml
+++ b/doc/src/sgml/ref/pg_resetxlog.sgml
@@ -22,6 +22,7 @@ PostgreSQL documentation
<refsynopsisdiv>
<cmdsynopsis>
<command>pg_resetxlog</command>
+ <arg choice="opt"><option>-c</option> <replaceable class="parameter">xid</replaceable>,<replaceable class="parameter">xid</replaceable></arg>
<arg choice="opt"><option>-f</option></arg>
<arg choice="opt"><option>-n</option></arg>
<arg choice="opt"><option>-o</option> <replaceable class="parameter">oid</replaceable></arg>
@@ -79,9 +80,12 @@ PostgreSQL documentation
<para>
The <option>-o</>, <option>-x</>, <option>-e</>,
<option>-m</>, <option>-O</>,
+ <option>-c</>
and <option>-l</>
options allow the next OID, next transaction ID, next transaction ID's
- epoch, next and oldest multitransaction ID, next multitransaction offset, and WAL
+ epoch, next and oldest multitransaction ID, next multitransaction offset,
+ oldest and newest transaction IDs for which the commit time can be retrieved,
+ and WAL
starting address values to be set manually. These are only needed when
<command>pg_resetxlog</command> is unable to determine appropriate values
by reading <filename>pg_control</>. Safe values can be determined as
@@ -130,6 +134,19 @@ PostgreSQL documentation
<listitem>
<para>
+ A safe value for the oldest transaction ID for which the commit time can
+ be retrieved (first part of <option>-c</>) can be determined by looking
+ for the numerically smallest file name in the directory
+ <filename>pg_committs</> under the data directory. Conversely, a safe
+ value for the newest transaction ID for which the commit time can be
+ retrieved (second part of <option>-c</>) can be determined by looking for
+ the numerically greatest file name in the same directory. As above, the
+ file names are in hexadecimal.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
The WAL starting address (<option>-l</>) should be
larger than any WAL segment file name currently existing in
the directory <filename>pg_xlog</> under the data directory.
diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml
index 920b5f0dc3b..cb76b98dc36 100644
--- a/doc/src/sgml/storage.sgml
+++ b/doc/src/sgml/storage.sgml
@@ -67,6 +67,11 @@ Item
</row>
<row>
+ <entry><filename>pg_commit_ts</></entry>
+ <entry>Subdirectory containing transaction commit timestamp data</entry>
+</row>
+
+<row>
<entry><filename>pg_clog</></entry>
<entry>Subdirectory containing transaction commit status data</entry>
</row>