public inbox for [email protected]help / color / mirror / Atom feed
Incorrect description of xmax and xip in functions docs 9+ messages / 2 participants [nested] [flat]
* Incorrect description of xmax and xip in functions docs @ 2008-09-05 15:14 Simon Riggs <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Simon Riggs @ 2008-09-05 15:14 UTC (permalink / raw) To: pgsql-docs http://developer.postgresql.org/pgdocs/postgres/functions-info.html xip_list is described as "Active txids at the time of the snapshot... " This is incorrect. The xip_list is the list of transactions that are in progress *and* less than xmax. There may be transactions in progress with an xid higher than xmax. This will happen frequently in fact. This is because xmax is defined as the highest/latest completed xid, not the highest running xid. Note that there is no way to discover the list of running xids at the time of the snapshot, from the data we hold about snapshots. Nor can the snapshot data be used to monitor the number of transactions in progress. Anyone disagree? If not, I'll patch. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2008-09-05 15:31 Simon Riggs <[email protected]> parent: Simon Riggs <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Simon Riggs @ 2008-09-05 15:31 UTC (permalink / raw) To: pgsql-docs On Fri, 2008-09-05 at 16:14 +0100, Simon Riggs wrote: > http://developer.postgresql.org/pgdocs/postgres/functions-info.html > > xip_list is described as > > "Active txids at the time of the snapshot... " > > > This is incorrect. The xip_list is the list of transactions that are in > progress *and* less than xmax. There may be transactions in progress > with an xid higher than xmax. This will happen frequently in fact. This > is because xmax is defined as the highest/latest completed xid, not the > highest running xid. > > Note that there is no way to discover the list of running xids at the > time of the snapshot, from the data we hold about snapshots. Nor can the > snapshot data be used to monitor the number of transactions in progress. > > Anyone disagree? If not, I'll patch. My rewording would be: "Active txids at the time of the snapshot. The list includes only those active txids between xmin and xmax; there may be active txids higher than xmax. A txid that is xmin <= txid < xmax and not in this list was already completed at the time of the snapshot, and thus either visible or dead according to its commit status. The list does not include txids of subtransactions." And for txid_visible_in_snapshot() comment added: "Function should not be used with subtransaction xids. It is possible that this function will return a true result for a subtransaction xid that was actually still in progress at the time of the snapshot". -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2008-09-07 01:31 Bruce Momjian <[email protected]> parent: Simon Riggs <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Bruce Momjian @ 2008-09-07 01:31 UTC (permalink / raw) To: Simon Riggs <[email protected]>; +Cc: pgsql-docs Simon Riggs wrote: > > On Fri, 2008-09-05 at 16:14 +0100, Simon Riggs wrote: > > http://developer.postgresql.org/pgdocs/postgres/functions-info.html > > > > xip_list is described as > > > > "Active txids at the time of the snapshot... " > > > > > > This is incorrect. The xip_list is the list of transactions that are in > > progress *and* less than xmax. There may be transactions in progress > > with an xid higher than xmax. This will happen frequently in fact. This > > is because xmax is defined as the highest/latest completed xid, not the > > highest running xid. > > > > Note that there is no way to discover the list of running xids at the > > time of the snapshot, from the data we hold about snapshots. Nor can the > > snapshot data be used to monitor the number of transactions in progress. > > > > Anyone disagree? If not, I'll patch. > > My rewording would be: > "Active txids at the time of the snapshot. The list includes only those > active txids between xmin and xmax; there may be active txids higher > than xmax. A txid that is xmin <= txid < xmax and not in this list was > already completed at the time of the snapshot, and thus either visible > or dead according to its commit status. The list does not include txids > of subtransactions." Applied, and attached. > And for txid_visible_in_snapshot() comment added: > "Function should not be used with subtransaction xids. It is possible > that this function will return a true result for a subtransaction xid > that was actually still in progress at the time of the snapshot". I think the cleaner solution is to throw an appropriate error if a subtransaction xid is used, rather than adding documentation. -- Bruce Momjian <[email protected]> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + Attachments: [text/x-diff] /rtmp/diff (1.4K, 2-%2Frtmp%2Fdiff) download | inline diff: Index: doc/src/sgml/func.sgml =================================================================== RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v retrieving revision 1.444 diff -c -c -r1.444 func.sgml *** doc/src/sgml/func.sgml 6 Sep 2008 00:01:21 -0000 1.444 --- doc/src/sgml/func.sgml 7 Sep 2008 01:27:44 -0000 *************** *** 12006,12016 **** <row> <entry><type>xip_list</type></entry> <entry> ! Active txids at the time of the snapshot. All of them are between ! <literal>xmin</> and <literal>xmax</>. A txid that is ! <literal>xmin <= txid < xmax</literal> and not in this list was ! already completed at the time of the snapshot, and thus either visible ! or dead according to its commit status. </entry> </row> --- 12006,12019 ---- <row> <entry><type>xip_list</type></entry> <entry> ! Active txids at the time of the snapshot. The list ! includes only those active txids between <literal>xmin</> ! and <literal>xmax</>; there might be active txids higher ! than xmax. A txid that is <literal>xmin <= txid < ! xmax</literal> and not in this list was already completed ! at the time of the snapshot, and thus either visible or ! dead according to its commit status. The list does not ! include txids of subtransactions. </entry> </row> ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2008-09-07 11:14 Simon Riggs <[email protected]> parent: Bruce Momjian <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Simon Riggs @ 2008-09-07 11:14 UTC (permalink / raw) To: Bruce Momjian <[email protected]>; +Cc: pgsql-docs On Sat, 2008-09-06 at 21:31 -0400, Bruce Momjian wrote: > Applied, and attached. Thanks. > > And for txid_visible_in_snapshot() comment added: > > "Function should not be used with subtransaction xids. It is possible > > that this function will return a true result for a subtransaction xid > > that was actually still in progress at the time of the snapshot". > > I think the cleaner solution is to throw an appropriate error if a > subtransaction xid is used, rather than adding documentation. Or maybe check subtrans for it, as it really should be doing. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2008-09-07 12:31 Bruce Momjian <[email protected]> parent: Simon Riggs <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Bruce Momjian @ 2008-09-07 12:31 UTC (permalink / raw) To: Simon Riggs <[email protected]>; +Cc: pgsql-docs Simon Riggs wrote: > > On Sat, 2008-09-06 at 21:31 -0400, Bruce Momjian wrote: > > Applied, and attached. > > Thanks. > > > > And for txid_visible_in_snapshot() comment added: > > > "Function should not be used with subtransaction xids. It is possible > > > that this function will return a true result for a subtransaction xid > > > that was actually still in progress at the time of the snapshot". > > > > I think the cleaner solution is to throw an appropriate error if a > > subtransaction xid is used, rather than adding documentation. > > Or maybe check subtrans for it, as it really should be doing. Yea, that's what I meant. You can't be sure everyone is going to read the documentation but they are sure to see the function results or error message. -- Bruce Momjian <[email protected]> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2008-09-08 06:56 Simon Riggs <[email protected]> parent: Bruce Momjian <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Simon Riggs @ 2008-09-08 06:56 UTC (permalink / raw) To: Bruce Momjian <[email protected]>; +Cc: pgsql-docs On Sun, 2008-09-07 at 08:31 -0400, Bruce Momjian wrote: > Simon Riggs wrote: > > > > On Sat, 2008-09-06 at 21:31 -0400, Bruce Momjian wrote: > > > Applied, and attached. > > > > Thanks. > > > > > > And for txid_visible_in_snapshot() comment added: > > > > "Function should not be used with subtransaction xids. It is possible > > > > that this function will return a true result for a subtransaction xid > > > > that was actually still in progress at the time of the snapshot". > > > > > > I think the cleaner solution is to throw an appropriate error if a > > > subtransaction xid is used, rather than adding documentation. > > > > Or maybe check subtrans for it, as it really should be doing. > > Yea, that's what I meant. You can't be sure everyone is going to read > the documentation but they are sure to see the function results or error > message. In fact, neither is possible. We cannot assume subtrans is available on the system on which the check is made, neither can we identify which xids are subtransactions and which are not. The only way is to document it. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2009-01-08 01:30 Bruce Momjian <[email protected]> parent: Simon Riggs <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Bruce Momjian @ 2009-01-08 01:30 UTC (permalink / raw) To: Simon Riggs <[email protected]>; +Cc: pgsql-docs; Jan Wieck <[email protected]> Simon Riggs wrote: > > On Sun, 2008-09-07 at 08:31 -0400, Bruce Momjian wrote: > > Simon Riggs wrote: > > > > > > On Sat, 2008-09-06 at 21:31 -0400, Bruce Momjian wrote: > > > > Applied, and attached. > > > > > > Thanks. > > > > > > > > And for txid_visible_in_snapshot() comment added: > > > > > "Function should not be used with subtransaction xids. It is possible > > > > > that this function will return a true result for a subtransaction xid > > > > > that was actually still in progress at the time of the snapshot". > > > > > > > > I think the cleaner solution is to throw an appropriate error if a > > > > subtransaction xid is used, rather than adding documentation. > > > > > > Or maybe check subtrans for it, as it really should be doing. > > > > Yea, that's what I meant. You can't be sure everyone is going to read > > the documentation but they are sure to see the function results or error > > message. > > In fact, neither is possible. We cannot assume subtrans is available on > the system on which the check is made, neither can we identify which > xids are subtransactions and which are not. > > The only way is to document it. Sorry, I am just getting back to this. Why would we not know if something is a subtransaction or if subtransactions are supported? Are you assuming txid_visible_in_snapshot() will be used on different servers? What are these txid_* functions for anyway? -- Bruce Momjian <[email protected]> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2009-01-08 08:19 Simon Riggs <[email protected]> parent: Bruce Momjian <[email protected]> 0 siblings, 1 reply; 9+ messages in thread From: Simon Riggs @ 2009-01-08 08:19 UTC (permalink / raw) To: Bruce Momjian <[email protected]>; +Cc: pgsql-docs; Jan Wieck <[email protected]> On Wed, 2009-01-07 at 20:30 -0500, Bruce Momjian wrote: > > The only way is to document it. > > Sorry, I am just getting back to this. Why would we not know if > something is a subtransaction or if subtransactions are supported? Are > you assuming txid_visible_in_snapshot() will be used on different > servers? What are these txid_* functions for anyway? You can derive a snapshot and export it using txid_current_snapshot(). http://developer.postgresql.org/pgdocs/postgres/functions-info.html You can then check whether an xid is in that snapshot by running txid_visible_in_snapshot(). However, the check is done assuming that the xid you are checking is a top-level xid and the answer you get is either yes or no. There is no allowance made that the xid supplied as a parameter value may have been a subtrans of one of the top-level xids listed. So the answer *ought* to have been true, whereas the function will always return false. We cannot extend txid_visible_in_snapshot() to answer correctly because that information is not held within the snapshot datatype, nor is it held in regular snapshots currently. So the only way to handle this is to document the limited scope of the answer this function provides. -- Simon Riggs www.2ndQuadrant.com PostgreSQL Training, Services and Support ^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: Incorrect description of xmax and xip in functions docs @ 2009-01-08 14:46 Bruce Momjian <[email protected]> parent: Simon Riggs <[email protected]> 0 siblings, 0 replies; 9+ messages in thread From: Bruce Momjian @ 2009-01-08 14:46 UTC (permalink / raw) To: Simon Riggs <[email protected]>; +Cc: pgsql-docs; Jan Wieck <[email protected]> Simon Riggs wrote: > > On Wed, 2009-01-07 at 20:30 -0500, Bruce Momjian wrote: > > > > The only way is to document it. > > > > Sorry, I am just getting back to this. Why would we not know if > > something is a subtransaction or if subtransactions are supported? Are > > you assuming txid_visible_in_snapshot() will be used on different > > servers? What are these txid_* functions for anyway? > > You can derive a snapshot and export it using txid_current_snapshot(). > http://developer.postgresql.org/pgdocs/postgres/functions-info.html > > You can then check whether an xid is in that snapshot by running > txid_visible_in_snapshot(). However, the check is done assuming that the > xid you are checking is a top-level xid and the answer you get is either > yes or no. > > There is no allowance made that the xid supplied as a parameter value > may have been a subtrans of one of the top-level xids listed. So the > answer *ought* to have been true, whereas the function will always > return false. > > We cannot extend txid_visible_in_snapshot() to answer correctly because > that information is not held within the snapshot datatype, nor is it > held in regular snapshots currently. So the only way to handle this is > to document the limited scope of the answer this function provides. Thank you for the clarification; I know understand. Patch attached and applied. -- Bruce Momjian <[email protected]> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + Attachments: [text/x-diff] /rtmp/diff (1.0K, 2-%2Frtmp%2Fdiff) download | inline diff: Index: doc/src/sgml/func.sgml =================================================================== RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v retrieving revision 1.468 diff -c -c -r1.468 func.sgml *** doc/src/sgml/func.sgml 8 Jan 2009 00:44:18 -0000 1.468 --- doc/src/sgml/func.sgml 8 Jan 2009 14:45:57 -0000 *************** *** 12473,12479 **** <row> <entry><literal><function>txid_visible_in_snapshot</function>(<parameter>bigint</parameter>, <parameter>txid_snapshot</parameter>)</literal></entry> <entry><type>boolean</type></entry> ! <entry>is transaction ID visible in snapshot?</entry> </row> </tbody> </tgroup> --- 12473,12479 ---- <row> <entry><literal><function>txid_visible_in_snapshot</function>(<parameter>bigint</parameter>, <parameter>txid_snapshot</parameter>)</literal></entry> <entry><type>boolean</type></entry> ! <entry>is transaction ID visible in snapshot? (do not use with subtransaction ids)</entry> </row> </tbody> </tgroup> ^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2009-01-08 14:46 UTC | newest] Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2008-09-05 15:14 Incorrect description of xmax and xip in functions docs Simon Riggs <[email protected]> 2008-09-05 15:31 ` Simon Riggs <[email protected]> 2008-09-07 01:31 ` Bruce Momjian <[email protected]> 2008-09-07 11:14 ` Simon Riggs <[email protected]> 2008-09-07 12:31 ` Bruce Momjian <[email protected]> 2008-09-08 06:56 ` Simon Riggs <[email protected]> 2009-01-08 01:30 ` Bruce Momjian <[email protected]> 2009-01-08 08:19 ` Simon Riggs <[email protected]> 2009-01-08 14:46 ` Bruce Momjian <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox