diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c new file mode 100644 index ed1f56a..ccdf38f *** a/src/backend/storage/lmgr/s_lock.c --- b/src/backend/storage/lmgr/s_lock.c *************** s_lock(volatile slock_t *lock, const cha *** 81,101 **** * so minutes. It seems better to fix the total number of tries (and thus * the probability of unintended failure) than to fix the total time * spent. - * - * The pg_usleep() delays are measured in milliseconds because 1 msec is a - * common resolution limit at the OS level for newer platforms. On older - * platforms the resolution limit is usually 10 msec, in which case the - * total delay before timeout will be a bit more. */ #define MIN_SPINS_PER_DELAY 10 #define MAX_SPINS_PER_DELAY 1000 #define NUM_DELAYS 1000 ! #define MIN_DELAY_MSEC 1 ! #define MAX_DELAY_MSEC 1000 int spins = 0; int delays = 0; ! int cur_delay = 0; while (TAS_SPIN(lock)) { --- 81,96 ---- * so minutes. It seems better to fix the total number of tries (and thus * the probability of unintended failure) than to fix the total time * spent. */ #define MIN_SPINS_PER_DELAY 10 #define MAX_SPINS_PER_DELAY 1000 #define NUM_DELAYS 1000 ! #define MIN_DELAY_USEC 1000L ! #define MAX_DELAY_USEC 1000000L int spins = 0; int delays = 0; ! long cur_delay = 0; while (TAS_SPIN(lock)) { *************** s_lock(volatile slock_t *lock, const cha *** 109,117 **** s_lock_stuck(lock, file, line); if (cur_delay == 0) /* first time to delay? */ ! cur_delay = MIN_DELAY_MSEC; ! pg_usleep(cur_delay * 1000L); #if defined(S_LOCK_TEST) fprintf(stdout, "*"); --- 104,112 ---- s_lock_stuck(lock, file, line); if (cur_delay == 0) /* first time to delay? */ ! cur_delay = MIN_DELAY_USEC; ! pg_usleep(cur_delay); #if defined(S_LOCK_TEST) fprintf(stdout, "*"); *************** s_lock(volatile slock_t *lock, const cha *** 119,129 **** #endif /* increase delay by a random fraction between 1X and 2X */ ! cur_delay += (int) (cur_delay * ((double) random() / (double) MAX_RANDOM_VALUE) + 0.5); /* wrap back to minimum delay when max is exceeded */ ! if (cur_delay > MAX_DELAY_MSEC) ! cur_delay = MIN_DELAY_MSEC; spins = 0; } --- 114,124 ---- #endif /* increase delay by a random fraction between 1X and 2X */ ! cur_delay += (long) (cur_delay * ((double) random() / (double) MAX_RANDOM_VALUE) + 0.5); /* wrap back to minimum delay when max is exceeded */ ! if (cur_delay > MAX_DELAY_USEC) ! cur_delay = MIN_DELAY_USEC; spins = 0; }