Change PG_DELAY from msec to usec and use it consistenly rather than
select(). Add Win32 Sleep() for delay.
This commit is contained in:
parent
a76c86c7c1
commit
38081fd000
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.159 2004/01/07 18:56:24 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.160 2004/01/09 21:08:46 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Transaction aborts can now occur two ways:
|
* Transaction aborts can now occur two ways:
|
||||||
|
@ -561,13 +561,7 @@ RecordTransactionCommit(void)
|
||||||
*/
|
*/
|
||||||
if (CommitDelay > 0 && enableFsync &&
|
if (CommitDelay > 0 && enableFsync &&
|
||||||
CountActiveBackends() >= CommitSiblings)
|
CountActiveBackends() >= CommitSiblings)
|
||||||
{
|
PG_USLEEP(CommitDelay);
|
||||||
struct timeval delay;
|
|
||||||
|
|
||||||
delay.tv_sec = 0;
|
|
||||||
delay.tv_usec = CommitDelay;
|
|
||||||
(void) select(0, NULL, NULL, NULL, &delay);
|
|
||||||
}
|
|
||||||
|
|
||||||
XLogFlush(recptr);
|
XLogFlush(recptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.151 2004/01/07 18:56:27 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.152 2004/01/09 21:08:49 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -1031,9 +1031,7 @@ BufferBackgroundWriter(void)
|
||||||
* there was nothing to do at all.
|
* there was nothing to do at all.
|
||||||
*/
|
*/
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
PG_USLEEP(BgWriterDelay * 1000);
|
||||||
PG_DELAY(BgWriterDelay);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.23 2003/12/27 20:58:58 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.24 2004/01/09 21:08:49 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "storage/s_lock.h"
|
#include "storage/s_lock.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* s_lock_stuck() - complain about a stuck spinlock
|
* s_lock_stuck() - complain about a stuck spinlock
|
||||||
|
@ -84,7 +84,6 @@ s_lock(volatile slock_t *lock, const char *file, int line)
|
||||||
int spins = 0;
|
int spins = 0;
|
||||||
int delays = 0;
|
int delays = 0;
|
||||||
int cur_delay = MIN_DELAY_CSEC;
|
int cur_delay = MIN_DELAY_CSEC;
|
||||||
struct timeval delay;
|
|
||||||
|
|
||||||
while (TAS(lock))
|
while (TAS(lock))
|
||||||
{
|
{
|
||||||
|
@ -97,9 +96,7 @@ s_lock(volatile slock_t *lock, const char *file, int line)
|
||||||
if (++delays > NUM_DELAYS)
|
if (++delays > NUM_DELAYS)
|
||||||
s_lock_stuck(lock, file, line);
|
s_lock_stuck(lock, file, line);
|
||||||
|
|
||||||
delay.tv_sec = cur_delay / 100;
|
PG_USLEEP(cur_delay * 10000);
|
||||||
delay.tv_usec = (cur_delay % 100) * 10000;
|
|
||||||
(void) select(0, NULL, NULL, NULL, &delay);
|
|
||||||
|
|
||||||
#if defined(S_LOCK_TEST)
|
#if defined(S_LOCK_TEST)
|
||||||
fprintf(stdout, "*");
|
fprintf(stdout, "*");
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.142 2004/01/06 23:15:22 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.143 2004/01/09 21:08:50 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* some of the information in this file should be moved to
|
* some of the information in this file should be moved to
|
||||||
|
@ -75,34 +75,40 @@ extern volatile uint32 CritSectionCount;
|
||||||
extern void ProcessInterrupts(void);
|
extern void ProcessInterrupts(void);
|
||||||
|
|
||||||
#define CHECK_FOR_INTERRUPTS() \
|
#define CHECK_FOR_INTERRUPTS() \
|
||||||
do { \
|
do { \
|
||||||
if (InterruptPending) \
|
if (InterruptPending) \
|
||||||
ProcessInterrupts(); \
|
ProcessInterrupts(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define HOLD_INTERRUPTS() (InterruptHoldoffCount++)
|
#define HOLD_INTERRUPTS() (InterruptHoldoffCount++)
|
||||||
|
|
||||||
#define RESUME_INTERRUPTS() \
|
#define RESUME_INTERRUPTS() \
|
||||||
do { \
|
do { \
|
||||||
Assert(InterruptHoldoffCount > 0); \
|
Assert(InterruptHoldoffCount > 0); \
|
||||||
InterruptHoldoffCount--; \
|
InterruptHoldoffCount--; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define START_CRIT_SECTION() (CritSectionCount++)
|
#define START_CRIT_SECTION() (CritSectionCount++)
|
||||||
|
|
||||||
#define END_CRIT_SECTION() \
|
#define END_CRIT_SECTION() \
|
||||||
do { \
|
do { \
|
||||||
Assert(CritSectionCount > 0); \
|
Assert(CritSectionCount > 0); \
|
||||||
CritSectionCount--; \
|
CritSectionCount--; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define PG_DELAY(_msec) \
|
#define PG_USLEEP(_usec) \
|
||||||
{ \
|
do { \
|
||||||
|
#ifndef WIN32
|
||||||
|
/* This will overflow on systems with 32-bit ints for > ~2000 secs */ \
|
||||||
struct timeval delay; \
|
struct timeval delay; \
|
||||||
delay.tv_sec = (_msec) / 1000; \
|
\
|
||||||
delay.tv_usec = ((_msec) % 1000) * 1000; \
|
delay.tv_sec = (_usec) / 1000000; \
|
||||||
|
delay.tv_usec = ((_usec) % 1000000); \
|
||||||
(void) select(0, NULL, NULL, NULL, &delay); \
|
(void) select(0, NULL, NULL, NULL, &delay); \
|
||||||
}
|
#else
|
||||||
|
Sleep(_usec < 500) ? 1 : (_usec+500)/ 1000);
|
||||||
|
#endif
|
||||||
|
} while(0)
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* globals.h -- *
|
* globals.h -- *
|
||||||
|
|
Loading…
Reference in New Issue