Improve XLOG_NO_TRAN related comments
The following patch improves XLOG_NO_TRAN related comments per discussion.
Regards,
Qingqing
---
Index: backend/access/transam/clog.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/clog.c,v
retrieving revision 1.36
diff -c -r1.36 clog.c
*** backend/access/transam/clog.c 6 Dec 2005 23:08:32 -0000 1.36
--- backend/access/transam/clog.c 24 Dec 2005 21:51:12 -0000
***************
*** 370,378 ****
/*
* Write a ZEROPAGE xlog record
*
! * Note: xlog record is marked as outside transaction control, since we
! * want it to be redone whether the invoking transaction commits or not.
! * (Besides which, this is normally done just before entering a transaction.)
*/
static void
WriteZeroPageXlogRec(int pageno)
--- 370,376 ----
/*
* Write a ZEROPAGE xlog record
*
! * Note: This is normally done just before entering a transaction.
*/
static void
WriteZeroPageXlogRec(int pageno)
Index: backend/access/transam/multixact.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/multixact.c,v
retrieving revision 1.15
diff -c -r1.15 multixact.c
*** backend/access/transam/multixact.c 6 Dec 2005 23:08:32 -0000 1.15
--- backend/access/transam/multixact.c 24 Dec 2005 21:51:12 -0000
***************
*** 1797,1805 ****
/*
* Write an xlog record reflecting the zeroing of either a MEMBERs or
* OFFSETs page (info shows which)
- *
- * Note: xlog record is marked as outside transaction control, since we
- * want it to be redone whether the invoking transaction commits or not.
*/
static void
WriteMZeroPageXlogRec(int pageno, uint8 info)
--- 1797,1802 ----
Index: backend/access/transam/xact.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xact.c,v
retrieving revision 1.216
diff -c -r1.216 xact.c
*** backend/access/transam/xact.c 22 Nov 2005 18:17:07 -0000 1.216
--- backend/access/transam/xact.c 24 Dec 2005 21:51:12 -0000
***************
*** 690,697 ****
* 2004-08-10.
*
* (If it made no transaction-controlled XLOG entries, its XID appears
! * nowhere in permanent storage, so no one else will ever care if it
! * committed; so it doesn't matter if we lose the commit flag.)
*
* Note we only need a shared lock.
*/
--- 690,697 ----
* 2004-08-10.
*
* (If it made no transaction-controlled XLOG entries, its XID appears
! * nowhere in permanent data storage, so no one else will ever care if
! * it committed; so it doesn't matter if we lose the commit flag.)
*
* Note we only need a shared lock.
*/
Index: backend/storage/smgr/smgr.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v
retrieving revision 1.94
diff -c -r1.94 smgr.c
*** backend/storage/smgr/smgr.c 22 Nov 2005 18:17:21 -0000 1.94
--- backend/storage/smgr/smgr.c 24 Dec 2005 21:51:12 -0000
***************
*** 364,374 ****
if (isRedo)
return;
! /*
! * Make a non-transactional XLOG entry showing the file creation. It's
! * non-transactional because we should replay it whether the transaction
! * commits or not; if not, the file will be dropped at abort time.
! */
xlrec.rnode = reln->smgr_rnode;
rdata.data = (char *) &xlrec;
--- 364,370 ----
if (isRedo)
return;
! /* Make a non-transactional XLOG entry showing the file creation */
xlrec.rnode = reln->smgr_rnode;
rdata.data = (char *) &xlrec;
***************
*** 622,633 ****
if (!isTemp)
{
! /*
! * Make a non-transactional XLOG entry showing the file truncation.
! * It's non-transactional because we should replay it whether the
! * transaction commits or not; the underlying file change is certainly
! * not reversible.
! */
XLogRecPtr lsn;
XLogRecData rdata;
xl_smgr_truncate xlrec;
--- 618,624 ----
if (!isTemp)
{
! /* Make a non-transactional XLOG entry showing the file truncation */
XLogRecPtr lsn;
XLogRecData rdata;
xl_smgr_truncate xlrec;
Index: include/access/xlog.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/access/xlog.h,v
retrieving revision 1.69
diff -c -r1.69 xlog.h
*** include/access/xlog.h 15 Oct 2005 02:49:42 -0000 1.69
--- include/access/xlog.h 24 Dec 2005 21:51:13 -0000
***************
*** 78,84 ****
/*
* Sometimes we log records which are out of transaction control.
! * Rmgr may "or" XLOG_NO_TRAN into info passed to XLogInsert to indicate this.
*/
#define XLOG_NO_TRAN XLR_INFO_MASK
--- 78,90 ----
/*
* Sometimes we log records which are out of transaction control.
! *
! * Note: The non-transaction-controlled distinction is really not very
! * useful. Vadim put it in originally because he may want to go to a
! * REDO/UNDO approach, in which it would've been important to tell the
! * difference (i.e., REDO always), but we never did that and probably
! * never will. We've preserved the distinction because it seemed worthwhile
! * from the standpoint of documentation and logical clarity.
*/
#define XLOG_NO_TRAN XLR_INFO_MASK
Qingqing Zhou <zhouqq@cs.toronto.edu> writes:
The following patch improves XLOG_NO_TRAN related comments per discussion.
Removing these comments entirely, without changing the code they explain,
doesn't strike me as an improvement.
regards, tom lane
On Sat, 24 Dec 2005, Tom Lane wrote:
Removing these comments entirely, without changing the code they explain,
doesn't strike me as an improvement.
Well, I still kept the XLOG_NO_TRAN and collect repeated comments to
xlog.h where it is defined.
Regards,
Qingqing
On Sat, 24 Dec 2005, Tom Lane wrote:
Removing these comments entirely, without changing the code they explain,
doesn't strike me as an improvement.
I just checked if we can remove XLOG_NO_TRAN happily, and the conclusion
is that it could bring some benefits (though not much) to our system. The
key is the CheckpointStartLock lock. If we remove XLOG_NO_TRAN, then even
statement like this will block/wait checkpoint:
SELECT nextval('serial');
Of course, we can add a test in XLogInsert() to solve this problem like
this:
no_tran == ((rmid == RM_XLOG_ID) || (rmid == RM_SEQ_ID) || ...)
But the better way is leave XLOG_NO_TRAN for now till we find a way to
avoid CheckpointStartLock lock.
Regards,
Qingqing
Qingqing Zhou <zhouqq@cs.toronto.edu> writes:
On Sat, 24 Dec 2005, Tom Lane wrote:
Removing these comments entirely, without changing the code they explain,
doesn't strike me as an improvement.
I just checked if we can remove XLOG_NO_TRAN happily, and the conclusion
is that it could bring some benefits (though not much) to our system. The
key is the CheckpointStartLock lock.
Hm. Perhaps we could keep the current behavior and re-document
XLOG_NO_TRAN as meaning that the xlog record does not involve the
insertion of our XID into permanent storage.
regards, tom lane