*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.41 1999/06/10 14:17:06 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.42 1999/06/29 04:54:46 vadim Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
#include <commands/sequence.h>
#include <libpq/be-fsstubs.h>
+extern bool SharedBufferChanged;
+
static void AbortTransaction(void);
static void AtAbort_Cache(void);
static void AtAbort_Locks(void);
*/
xid = GetCurrentTransactionId();
- /* ----------------
+ /*
* flush the buffer manager pages. Note: if we have stable
* main memory, dirty shared buffers are not flushed
* plai 8/7/90
- * ----------------
*/
leak = BufferPoolCheckLeak();
- FlushBufferPool(!TransactionFlushEnabled());
- if (leak)
- ResetBufferPool();
- /* ----------------
- * have the transaction access methods record the status
- * of this transaction id in the pg_log / pg_time relations.
- * ----------------
+ /*
+ * If no one shared buffer was changed by this transaction then
+ * we don't flush shared buffers and don't record commit status.
*/
- TransactionIdCommit(xid);
+ if (SharedBufferChanged)
+ {
+ FlushBufferPool(!TransactionFlushEnabled());
+ if (leak)
+ ResetBufferPool();
+
+ /*
+ * have the transaction access methods record the status
+ * of this transaction id in the pg_log relation.
+ */
+ TransactionIdCommit(xid);
+
+ /*
+ * Now write the log info to the disk too.
+ */
+ leak = BufferPoolCheckLeak();
+ FlushBufferPool(!TransactionFlushEnabled());
+ }
- /* ----------------
- * Now write the log/time info to the disk too.
- * ----------------
- */
- leak = BufferPoolCheckLeak();
- FlushBufferPool(!TransactionFlushEnabled());
if (leak)
ResetBufferPool();
}
*/
xid = GetCurrentTransactionId();
- /* ----------------
- * have the transaction access methods record the status
- * of this transaction id in the pg_log / pg_time relations.
- * ----------------
+ /*
+ * Have the transaction access methods record the status of
+ * this transaction id in the pg_log relation. We skip it
+ * if no one shared buffer was changed by this transaction.
*/
- TransactionIdAbort(xid);
+ if (SharedBufferChanged)
+ TransactionIdAbort(xid);
- /* ----------------
- * flush the buffer manager pages. Note: if we have stable
- * main memory, dirty shared buffers are not flushed
- * plai 8/7/90
- * ----------------
- */
ResetBufferPool();
}
* ----------------
*/
s->state = TRANS_DEFAULT;
+ SharedBufferChanged = false; /* safest place to do it */
}
* ----------------
*/
s->state = TRANS_DEFAULT;
+ SharedBufferChanged = false; /* safest place to do it */
}
/* --------------------------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.55 1999/06/11 09:00:02 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.56 1999/06/29 04:54:47 vadim Exp $
*
*-------------------------------------------------------------------------
*/
extern long int BufferFlushCount;
extern long int LocalBufferFlushCount;
+/*
+ * It's used to avoid disk writes for read-only transactions
+ * (i.e. when no one shared buffer was changed by transaction).
+ * We set it to true in WriteBuffer/WriteNoReleaseBuffer when
+ * marking shared buffer as dirty. We set it to false in xact.c
+ * after transaction is committed/aborted.
+ */
+bool SharedBufferChanged = false;
+
static int WriteMode = BUFFER_LATE_WRITE; /* Delayed write is
* default */
bufHdr = &BufferDescriptors[buffer - 1];
+ SharedBufferChanged = true;
+
SpinAcquire(BufMgrLock);
Assert(bufHdr->refcount > 0);
bufHdr->flags |= (BM_DIRTY | BM_JUST_DIRTIED);
bufrel = RelationIdCacheGetRelation(bufHdr->tag.relId.relId);
Assert(bufrel != (Relation) NULL);
+ SharedBufferChanged = true;
+
/* To check if block content changed while flushing. - vadim 01/17/97 */
SpinAcquire(BufMgrLock);
bufHdr->flags &= ~BM_JUST_DIRTIED;
bufHdr = &BufferDescriptors[buffer - 1];
+ SharedBufferChanged = true;
+
SpinAcquire(BufMgrLock);
bufHdr->flags |= (BM_DIRTY | BM_JUST_DIRTIED);
SpinRelease(BufMgrLock);