diff options
Diffstat (limited to 'src/backend/access/transam')
| -rw-r--r-- | src/backend/access/transam/transam.c | 4 | ||||
| -rw-r--r-- | src/backend/access/transam/varsup.c | 12 | ||||
| -rw-r--r-- | src/backend/access/transam/xact.c | 96 | ||||
| -rw-r--r-- | src/backend/access/transam/xlog.c | 75 |
4 files changed, 95 insertions, 92 deletions
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index c4ca0c7071b..3d3816430af 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.53 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.54 2002/09/04 20:31:13 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -27,7 +27,7 @@ * Flag indicating that we are bootstrapping. * * Transaction ID generation is disabled during bootstrap; we just use - * BootstrapTransactionId. Also, the transaction ID status-check routines + * BootstrapTransactionId. Also, the transaction ID status-check routines * are short-circuited; they claim that BootstrapTransactionId has already * committed, allowing tuples already inserted to be seen immediately. * ---------------- diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 4b8e76085bb..6453bad761c 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.50 2002/06/11 13:40:50 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.51 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -68,12 +68,12 @@ GetNewTransactionId(void) * might see a partially-set xid here. But holding both locks at once * would be a nasty concurrency hit (and in fact could cause a * deadlock against GetSnapshotData). So for now, assume atomicity. - * Note that readers of PGPROC xid field should be careful to fetch the - * value only once, rather than assume they can read it multiple times - * and get the same answer each time. + * Note that readers of PGPROC xid field should be careful to fetch + * the value only once, rather than assume they can read it multiple + * times and get the same answer each time. * - * A solution to the atomic-store problem would be to give each PGPROC its - * own spinlock used only for fetching/storing that PGPROC's xid. + * A solution to the atomic-store problem would be to give each PGPROC + * its own spinlock used only for fetching/storing that PGPROC's xid. * (SInvalLock would then mean primarily that PROCs couldn't be added/ * removed while holding the lock.) */ diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 1c1121e3e11..fd401e963e2 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.131 2002/08/30 22:18:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.132 2002/09/04 20:31:13 momjian Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -265,7 +265,6 @@ SetTransactionFlushEnabled(bool state) { TransactionFlushState = (state == true); } - #endif @@ -421,7 +420,7 @@ CommandCounterIncrement(void) TransactionState s = CurrentTransactionState; s->commandId += 1; - if (s->commandId == FirstCommandId) /* check for overflow */ + if (s->commandId == FirstCommandId) /* check for overflow */ elog(ERROR, "You may only have 2^32-1 commands per transaction"); /* Propagate new command ID into query snapshots, if set */ @@ -517,8 +516,8 @@ void RecordTransactionCommit(void) { /* - * If we made neither any XLOG entries nor any temp-rel updates, - * we can omit recording the transaction commit at all. + * If we made neither any XLOG entries nor any temp-rel updates, we + * can omit recording the transaction commit at all. */ if (MyXactMadeXLogEntry || MyXactMadeTempRelUpdate) { @@ -531,10 +530,10 @@ RecordTransactionCommit(void) START_CRIT_SECTION(); /* - * We only need to log the commit in xlog if the transaction made any - * transaction-controlled XLOG entries. (Otherwise, its XID appears - * nowhere in permanent storage, so no one else will ever care if it - * committed.) + * We only need to log the commit in xlog if the transaction made + * any transaction-controlled XLOG entries. (Otherwise, its XID + * appears nowhere in permanent storage, so no one else will ever + * care if it committed.) */ if (MyLastRecPtr.xrecoff != 0) { @@ -560,20 +559,20 @@ RecordTransactionCommit(void) } /* - * We must flush our XLOG entries to disk if we made any XLOG entries, - * whether in or out of transaction control. For example, if we - * reported a nextval() result to the client, this ensures that any - * XLOG record generated by nextval will hit the disk before we report - * the transaction committed. + * We must flush our XLOG entries to disk if we made any XLOG + * entries, whether in or out of transaction control. For + * example, if we reported a nextval() result to the client, this + * ensures that any XLOG record generated by nextval will hit the + * disk before we report the transaction committed. */ if (MyXactMadeXLogEntry) { /* * Sleep before flush! So we can flush more than one commit - * records per single fsync. (The idea is some other backend may - * do the XLogFlush while we're sleeping. This needs work still, - * because on most Unixen, the minimum select() delay is 10msec or - * more, which is way too long.) + * records per single fsync. (The idea is some other backend + * may do the XLogFlush while we're sleeping. This needs work + * still, because on most Unixen, the minimum select() delay + * is 10msec or more, which is way too long.) * * We do not sleep if enableFsync is not turned on, nor if there * are fewer than CommitSiblings other backends with active @@ -593,13 +592,14 @@ RecordTransactionCommit(void) } /* - * We must mark the transaction committed in clog if its XID appears - * either in permanent rels or in local temporary rels. We test - * this by seeing if we made transaction-controlled entries *OR* - * local-rel tuple updates. Note that if we made only the latter, - * we have not emitted an XLOG record for our commit, and so in the - * event of a crash the clog update might be lost. This is okay - * because no one else will ever care whether we committed. + * We must mark the transaction committed in clog if its XID + * appears either in permanent rels or in local temporary rels. + * We test this by seeing if we made transaction-controlled + * entries *OR* local-rel tuple updates. Note that if we made + * only the latter, we have not emitted an XLOG record for our + * commit, and so in the event of a crash the clog update might be + * lost. This is okay because no one else will ever care whether + * we committed. */ if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate) TransactionIdCommit(xid); @@ -628,6 +628,7 @@ AtCommit_Cache(void) * Clean up the relation cache. */ AtEOXact_RelationCache(true); + /* * Make catalog changes visible to all backends. */ @@ -698,8 +699,8 @@ RecordTransactionAbort(void) { /* * If we made neither any transaction-controlled XLOG entries nor any - * temp-rel updates, we can omit recording the transaction abort at all. - * No one will ever care that it aborted. + * temp-rel updates, we can omit recording the transaction abort at + * all. No one will ever care that it aborted. */ if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate) { @@ -716,11 +717,12 @@ RecordTransactionAbort(void) START_CRIT_SECTION(); /* - * We only need to log the abort in XLOG if the transaction made any - * transaction-controlled XLOG entries. (Otherwise, its XID appears - * nowhere in permanent storage, so no one else will ever care if it - * committed.) We do not flush XLOG to disk in any case, since the - * default assumption after a crash would be that we aborted, anyway. + * We only need to log the abort in XLOG if the transaction made + * any transaction-controlled XLOG entries. (Otherwise, its XID + * appears nowhere in permanent storage, so no one else will ever + * care if it committed.) We do not flush XLOG to disk in any + * case, since the default assumption after a crash would be that + * we aborted, anyway. */ if (MyLastRecPtr.xrecoff != 0) { @@ -1165,8 +1167,8 @@ StartTransactionCommand(bool preventChain) TransactionState s = CurrentTransactionState; /* - * Remember if caller wants to prevent autocommit-off chaining. - * This is only allowed if not already in a transaction block. + * Remember if caller wants to prevent autocommit-off chaining. This + * is only allowed if not already in a transaction block. */ suppressChain = preventChain; if (preventChain && s->blockState != TBLOCK_DEFAULT) @@ -1260,16 +1262,18 @@ CommitTransactionCommand(bool forceCommit) { /* * If we aren't in a transaction block, and we are doing - * autocommit, just do our usual transaction commit. But - * if we aren't doing autocommit, start a transaction block - * automatically by switching to INPROGRESS state. (We handle - * this choice here, and not earlier, so that an explicit BEGIN - * issued in autocommit-off mode won't issue strange warnings.) + * autocommit, just do our usual transaction commit. But if + * we aren't doing autocommit, start a transaction block + * automatically by switching to INPROGRESS state. (We handle + * this choice here, and not earlier, so that an explicit + * BEGIN issued in autocommit-off mode won't issue strange + * warnings.) * - * Autocommit mode is forced by either a true forceCommit parameter - * to me, or a true preventChain parameter to the preceding - * StartTransactionCommand call. This is needed so that commands - * like VACUUM can ensure that the right things happen. + * Autocommit mode is forced by either a true forceCommit + * parameter to me, or a true preventChain parameter to the + * preceding StartTransactionCommand call. This is needed so + * that commands like VACUUM can ensure that the right things + * happen. */ case TBLOCK_DEFAULT: if (autocommit || forceCommit || suppressChain) @@ -1442,9 +1446,9 @@ BeginTransactionBlock(void) s->blockState = TBLOCK_BEGIN; /* - * do begin processing. NOTE: if you put anything here, check that - * it behaves properly in both autocommit-on and autocommit-off modes. - * In the latter case we will already have done some work in the new + * do begin processing. NOTE: if you put anything here, check that it + * behaves properly in both autocommit-on and autocommit-off modes. In + * the latter case we will already have done some work in the new * transaction. */ diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d2955d40584..0ff60292e68 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.105 2002/09/02 02:47:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.106 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,13 +131,13 @@ bool InRecovery = false; * * Note that XLOG records inserted outside transaction control are not * reflected into MyLastRecPtr. They do, however, cause MyXactMadeXLogEntry - * to be set true. The latter can be used to test whether the current xact + * to be set true. The latter can be used to test whether the current xact * made any loggable changes (including out-of-xact changes, such as * sequence updates). * * When we insert/update/delete a tuple in a temporary relation, we do not * make any XLOG record, since we don't care about recovering the state of - * the temp rel after a crash. However, we will still need to remember + * the temp rel after a crash. However, we will still need to remember * whether our transaction committed or aborted in that case. So, we must * set MyXactMadeTempRelUpdate true to indicate that the XID will be of * interest later. @@ -151,7 +151,7 @@ bool MyXactMadeTempRelUpdate = false; /* * ProcLastRecPtr points to the start of the last XLOG record inserted by the * current backend. It is updated for all inserts, transaction-controlled - * or not. ProcLastRecEnd is similar but points to end+1 of last record. + * or not. ProcLastRecEnd is similar but points to end+1 of last record. */ static XLogRecPtr ProcLastRecPtr = {0, 0}; @@ -162,7 +162,7 @@ XLogRecPtr ProcLastRecEnd = {0, 0}; * (which is almost but not quite the same as a pointer to the most recent * CHECKPOINT record). We update this from the shared-memory copy, * XLogCtl->Insert.RedoRecPtr, whenever we can safely do so (ie, when we - * hold the Insert lock). See XLogInsert for details. We are also allowed + * hold the Insert lock). See XLogInsert for details. We are also allowed * to update from XLogCtl->Insert.RedoRecPtr if we hold the info_lck; * see GetRedoRecPtr. */ @@ -766,7 +766,7 @@ begin:; /* * We do not acquire SInvalLock here because of possible deadlock. * Anyone who wants to inspect other procs' logRec must acquire - * WALInsertLock, instead. A better solution would be a per-PROC + * WALInsertLock, instead. A better solution would be a per-PROC * spinlock, but no time for that before 7.2 --- tgl 12/19/01. */ MyProc->logRec = RecPtr; @@ -1283,26 +1283,27 @@ XLogFlush(XLogRecPtr record) /* * If we still haven't flushed to the request point then we have a - * problem; most likely, the requested flush point is past end of XLOG. - * This has been seen to occur when a disk page has a corrupted LSN. + * problem; most likely, the requested flush point is past end of + * XLOG. This has been seen to occur when a disk page has a corrupted + * LSN. * * Formerly we treated this as a PANIC condition, but that hurts the * system's robustness rather than helping it: we do not want to take * down the whole system due to corruption on one data page. In - * particular, if the bad page is encountered again during recovery then - * we would be unable to restart the database at all! (This scenario - * has actually happened in the field several times with 7.1 releases. - * Note that we cannot get here while InRedo is true, but if the bad - * page is brought in and marked dirty during recovery then + * particular, if the bad page is encountered again during recovery + * then we would be unable to restart the database at all! (This + * scenario has actually happened in the field several times with 7.1 + * releases. Note that we cannot get here while InRedo is true, but if + * the bad page is brought in and marked dirty during recovery then * CreateCheckpoint will try to flush it at the end of recovery.) * * The current approach is to ERROR under normal conditions, but only - * WARNING during recovery, so that the system can be brought up even if - * there's a corrupt LSN. Note that for calls from xact.c, the ERROR - * will be promoted to PANIC since xact.c calls this routine inside a - * critical section. However, calls from bufmgr.c are not within - * critical sections and so we will not force a restart for a bad LSN - * on a data page. + * WARNING during recovery, so that the system can be brought up even + * if there's a corrupt LSN. Note that for calls from xact.c, the + * ERROR will be promoted to PANIC since xact.c calls this routine + * inside a critical section. However, calls from bufmgr.c are not + * within critical sections and so we will not force a restart for a + * bad LSN on a data page. */ if (XLByteLT(LogwrtResult.Flush, record)) elog(InRecovery ? WARNING : ERROR, @@ -1565,7 +1566,7 @@ PreallocXlogFiles(XLogRecPtr endptr) XLByteToPrevSeg(endptr, _logId, _logSeg); if ((endptr.xrecoff - 1) % XLogSegSize >= - (uint32) (0.75 * XLogSegSize)) + (uint32) (0.75 * XLogSegSize)) { NextLogSeg(_logId, _logSeg); use_existent = true; @@ -1618,8 +1619,8 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr) /* * Before deleting the file, see if it can be recycled as * a future log segment. We allow recycling segments up - * to XLOGfileslop segments beyond the current - * XLOG location. + * to XLOGfileslop segments beyond the current XLOG + * location. */ if (InstallXLogFileSegment(endlogId, endlogSeg, path, true, XLOGfileslop, @@ -2196,7 +2197,7 @@ ReadControlFile(void) if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) elog(PANIC, "The database cluster was initialized with CATALOG_VERSION_NO %d,\n" - "\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n" + "\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n" "\tIt looks like you need to initdb.", ControlFile->catalog_version_no, CATALOG_VERSION_NO); if (ControlFile->blcksz != BLCKSZ) @@ -2221,7 +2222,7 @@ ReadControlFile(void) if (ControlFile->funcMaxArgs != FUNC_MAX_ARGS) elog(PANIC, - "The database cluster was initialized with FUNC_MAX_ARGS %d,\n" + "The database cluster was initialized with FUNC_MAX_ARGS %d,\n" "\tbut the backend was compiled with FUNC_MAX_ARGS %d.\n" "\tIt looks like you need to recompile or initdb.", ControlFile->funcMaxArgs, FUNC_MAX_ARGS); @@ -2235,21 +2236,21 @@ ReadControlFile(void) #else if (ControlFile->enableIntTimes != FALSE) elog(PANIC, - "The database cluster was initialized with HAVE_INT64_TIMESTAMP\n" - "\tbut the backend was compiled without HAVE_INT64_TIMESTAMP.\n" + "The database cluster was initialized with HAVE_INT64_TIMESTAMP\n" + "\tbut the backend was compiled without HAVE_INT64_TIMESTAMP.\n" "\tIt looks like you need to recompile or initdb."); #endif if (ControlFile->localeBuflen != LOCALE_NAME_BUFLEN) elog(PANIC, "The database cluster was initialized with LOCALE_NAME_BUFLEN %d,\n" - "\tbut the backend was compiled with LOCALE_NAME_BUFLEN %d.\n" + "\tbut the backend was compiled with LOCALE_NAME_BUFLEN %d.\n" "\tIt looks like you need to initdb.", ControlFile->localeBuflen, LOCALE_NAME_BUFLEN); if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL) elog(PANIC, - "The database cluster was initialized with LC_COLLATE '%s',\n" + "The database cluster was initialized with LC_COLLATE '%s',\n" "\twhich is not recognized by setlocale().\n" "\tIt looks like you need to initdb.", ControlFile->lc_collate); @@ -3019,19 +3020,19 @@ CreateCheckPoint(bool shutdown) } /* - * Get UNDO record ptr - this is oldest of PGPROC->logRec values. We do - * this while holding insert lock to ensure that we won't miss any + * Get UNDO record ptr - this is oldest of PGPROC->logRec values. We + * do this while holding insert lock to ensure that we won't miss any * about-to-commit transactions (UNDO must include all xacts that have * commits after REDO point). * * XXX temporarily ifdef'd out to avoid three-way deadlock condition: * GetUndoRecPtr needs to grab SInvalLock to ensure that it is looking - * at a stable set of proc records, but grabbing SInvalLock while holding - * WALInsertLock is no good. GetNewTransactionId may cause a WAL record - * to be written while holding XidGenLock, and GetSnapshotData needs to - * get XidGenLock while holding SInvalLock, so there's a risk of deadlock. - * Need to find a better solution. See pgsql-hackers discussion of - * 17-Dec-01. + * at a stable set of proc records, but grabbing SInvalLock while + * holding WALInsertLock is no good. GetNewTransactionId may cause a + * WAL record to be written while holding XidGenLock, and + * GetSnapshotData needs to get XidGenLock while holding SInvalLock, + * so there's a risk of deadlock. Need to find a better solution. See + * pgsql-hackers discussion of 17-Dec-01. */ #ifdef NOT_USED checkPoint.undo = GetUndoRecPtr(); @@ -3298,9 +3299,7 @@ assign_xlog_sync_method(const char *method, bool doit, bool interactive) } #endif else - { return NULL; - } if (!doit) return method; |
