Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit229d338

Browse files
committed
Use the new TimestampDifferenceExceeds API instead of timestamp_cmp_internal
and TimestampDifference, to make coding clearer. I think this should also fixthe failure to start workers in platforms with low resolution timers, asreported by Itagaki Takahiro.
1 parenta115bfe commit229d338

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

‎src/backend/postmaster/autovacuum.c

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.43 2007/05/0215:47:14 alvherre Exp $
13+
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.44 2007/05/0218:27:57 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -549,8 +549,6 @@ AutoVacLauncherMain(int argc, char *argv[])
549549

550550
if (can_launch&&AutoVacuumShmem->av_startingWorker!=INVALID_OFFSET)
551551
{
552-
longsecs;
553-
intusecs;
554552
WorkerInfoworker= (WorkerInfo)MAKE_PTR(AutoVacuumShmem->av_startingWorker);
555553

556554
if (current_time==0)
@@ -566,11 +564,8 @@ AutoVacLauncherMain(int argc, char *argv[])
566564
* startingWorker pointer before trying to connect; only low-level
567565
* problems, like fork() failure, can get us here.
568566
*/
569-
TimestampDifference(worker->wi_launchtime,current_time,
570-
&secs,&usecs);
571-
572-
/* ignore microseconds, as they cannot make any difference */
573-
if (secs>autovacuum_naptime)
567+
if (TimestampDifferenceExceeds(worker->wi_launchtime,current_time,
568+
autovacuum_naptime*1000))
574569
{
575570
LWLockRelease(AutovacuumLock);
576571
LWLockAcquire(AutovacuumLock,LW_EXCLUSIVE);
@@ -618,13 +613,13 @@ AutoVacLauncherMain(int argc, char *argv[])
618613
if (elem!=NULL)
619614
{
620615
avl_dbase*avdb=DLE_VAL(elem);
621-
longsecs;
622-
intusecs;
623-
624-
TimestampDifference(current_time,avdb->adl_next_worker,&secs,&usecs);
625616

626-
/* do we have to start a worker? */
627-
if (secs <=0&&usecs <=0)
617+
/*
618+
* launch a worker if next_worker is right now or it is in the
619+
* past
620+
*/
621+
if (TimestampDifferenceExceeds(avdb->adl_next_worker,
622+
current_time,0))
628623
launch_worker(current_time);
629624
}
630625
else
@@ -1037,22 +1032,15 @@ do_start_worker(void)
10371032

10381033
if (dbp->adl_datid==tmp->adw_datid)
10391034
{
1040-
TimestampTzcurr_plus_naptime;
1041-
TimestampTznext=dbp->adl_next_worker;
1042-
1043-
curr_plus_naptime=
1044-
TimestampTzPlusMilliseconds(current_time,
1045-
autovacuum_naptime*1000);
1046-
10471035
/*
1048-
*What we want hereifto skip ifnext_worker falls between
1036+
*Skip this databaseifitsnext_worker value falls between
10491037
* the current time and the current time plus naptime.
10501038
*/
1051-
if (timestamp_cmp_internal(current_time,next)>0)
1052-
skipit= false;
1053-
elseif (timestamp_cmp_internal(next,curr_plus_naptime)>0)
1054-
skipit= false;
1055-
else
1039+
if (TimestampDifferenceExceeds(current_time,
1040+
dbp->adl_next_worker,0)&&
1041+
!TimestampDifferenceExceeds(current_time,
1042+
dbp->adl_next_worker,
1043+
autovacuum_naptime*1000))
10561044
skipit= true;
10571045

10581046
break;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp