mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Implement COMMIT_SIBLINGS parameter to allow pre-commit delay to occur
only if at least N other backends currently have open transactions. This is not a great deal of intelligence about whether a delay might be profitable ... but it beats no intelligence at all. Note that the default COMMIT_DELAY is still zero --- this new code does nothing unless that setting is changed. Also, mark ENABLEFSYNC as a system-wide setting. It's no longer safe to allow that to be set per-backend, since we may be relying on some other backend's fsync to have synced the WAL log.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.97 2001/02/18 04:50:43 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.98 2001/02/26 00:50:07 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Transaction aborts can now occur two ways:
|
||||
@ -157,6 +157,7 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "access/nbtree.h"
|
||||
#include "access/xact.h"
|
||||
#include "catalog/heap.h"
|
||||
#include "catalog/index.h"
|
||||
#include "commands/async.h"
|
||||
@ -177,8 +178,6 @@
|
||||
|
||||
extern bool SharedBufferChanged;
|
||||
|
||||
void RecordTransactionCommit(void);
|
||||
|
||||
static void AbortTransaction(void);
|
||||
static void AtAbort_Cache(void);
|
||||
static void AtAbort_Locks(void);
|
||||
@ -216,12 +215,14 @@ TransactionStateData CurrentTransactionStateData = {
|
||||
|
||||
TransactionState CurrentTransactionState = &CurrentTransactionStateData;
|
||||
|
||||
/*
|
||||
* User-tweakable parameters
|
||||
*/
|
||||
int DefaultXactIsoLevel = XACT_READ_COMMITTED;
|
||||
int XactIsoLevel;
|
||||
|
||||
#include "access/xlogutils.h"
|
||||
|
||||
int CommitDelay = 0; /* in microseconds */
|
||||
int CommitDelay = 0; /* precommit delay in microseconds */
|
||||
int CommitSiblings = 5; /* number of concurrent xacts needed to sleep */
|
||||
|
||||
static void (*_RollbackFunc)(void*) = NULL;
|
||||
static void *_RollbackData = NULL;
|
||||
@ -687,10 +688,15 @@ RecordTransactionCommit()
|
||||
* Sleep before commit! 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 however, because on most Unixen, the minimum
|
||||
* 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
|
||||
* transactions.
|
||||
*/
|
||||
if (CommitDelay > 0)
|
||||
if (CommitDelay > 0 && enableFsync &&
|
||||
CountActiveBackends() >= CommitSiblings)
|
||||
{
|
||||
struct timeval delay;
|
||||
|
||||
|
Reference in New Issue
Block a user