aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-07-02 12:58:34 +0900
committerMichael Paquier <michael@paquier.xyz>2021-07-02 12:58:34 +0900
commit70685385d70f8da73ab189a72f46311091ff09be (patch)
tree1cb15731a32d333b6e30a700dbe94283aa83bcd8 /src
parenta2595e039c4745d82f361ea15d692cac114575cc (diff)
downloadpostgresql-70685385d70f8da73ab189a72f46311091ff09be.tar.gz
postgresql-70685385d70f8da73ab189a72f46311091ff09be.zip
Use WaitLatch() instead of pg_usleep() at end-of-vacuum truncation
This has the advantage to make a process more responsive when the postmaster dies, even if the wait time was rather limited as there was only a 50ms timeout here. Another advantage of this change is for monitoring, as we gain a new wait event for the end-of-vacuum truncation. Author: Bharath Rupireddy Reviewed-by: Aleksander Alekseev, Thomas Munro, Michael Paquier Discussion: https://postgr.es/m/CALj2ACU4AdPCq6NLfcA-ZGwX7pPCK5FgEj-CAU0xCKzkASSy_A@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/heap/vacuumlazy.c6
-rw-r--r--src/backend/utils/activity/wait_event.c3
-rw-r--r--src/include/utils/wait_event.h3
3 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 44f198398c1..2c04b69221f 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -3236,7 +3236,11 @@ lazy_truncate_heap(LVRelState *vacrel)
return;
}
- pg_usleep(VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL * 1000L);
+ (void) WaitLatch(MyLatch,
+ WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
+ VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL,
+ WAIT_EVENT_VACUUM_TRUNCATE);
+ ResetLatch(MyLatch);
}
/*
diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c
index 6baf67740c7..ef7e6bfb779 100644
--- a/src/backend/utils/activity/wait_event.c
+++ b/src/backend/utils/activity/wait_event.c
@@ -485,6 +485,9 @@ pgstat_get_wait_timeout(WaitEventTimeout w)
case WAIT_EVENT_VACUUM_DELAY:
event_name = "VacuumDelay";
break;
+ case WAIT_EVENT_VACUUM_TRUNCATE:
+ event_name = "VacuumTruncate";
+ break;
/* no default case, so that compiler will warn */
}
diff --git a/src/include/utils/wait_event.h b/src/include/utils/wait_event.h
index 6c6ec2e7118..6007827b445 100644
--- a/src/include/utils/wait_event.h
+++ b/src/include/utils/wait_event.h
@@ -140,7 +140,8 @@ typedef enum
WAIT_EVENT_PG_SLEEP,
WAIT_EVENT_RECOVERY_APPLY_DELAY,
WAIT_EVENT_RECOVERY_RETRIEVE_RETRY_INTERVAL,
- WAIT_EVENT_VACUUM_DELAY
+ WAIT_EVENT_VACUUM_DELAY,
+ WAIT_EVENT_VACUUM_TRUNCATE
} WaitEventTimeout;
/* ----------