When a PolarDB for PostgreSQL cluster restarts or shuts down unexpectedly, the shared buffer pool is cleared and reinitialized — a cold start. Recovering from a cold start requires replaying Write-Ahead Logging (WAL) logs and reloading data from disk, which delays cluster availability and causes performance jitter after restart.
The Persistent Buffer Pool (PBP) feature eliminates cold starts by preserving the shared buffer pool across restarts. The cluster starts warm, with cached data immediately available, reducing fault recovery time and stabilizing performance after restart.
Supported versions
PBP is available for the following versions of PolarDB for PostgreSQL:
-
PostgreSQL 14 (minor engine version 2.0.14.5.2.0 or later)
-
PostgreSQL 11 (minor engine version 2.0.11.2.1.0 or later)
To check your minor engine version, run SHOW polardb_version; or view the version in the console. If your cluster does not meet the version requirement, upgrade the minor engine version.
How it works
A PolarDB for PostgreSQL cluster uses three types of memory:
-
Shared buffer pool: A large pre-allocated shared memory segment. Offsets determine the usage ranges for functional modules.
-
Dynamic shared memory areas: Shared memory for inter-process parallel computing; can be dynamically expanded.
-
Process Global Area: Memory private to each process, consisting of Memory Context and memory directly controlled by logic.
The following figure shows how memory is divided.
The shared buffer pool consumes the most memory in a cluster and directly affects performance. In native PostgreSQL, the buffer pool is cleared on every restart or unexpected shutdown. PBP solves this by converting a portion of the shared buffer pool into a pod-level lifecycle segment. Buffer pool pages and buffer descriptors are placed into this persistent segment; other memory components retain an instance-level lifecycle.
-
Pod-level lifecycle: PolarDB for PostgreSQL runs on Kubernetes. Shared memory with a pod-level lifecycle is not destroyed when the cluster shuts down, so the buffer pool persists across restarts.
-
Instance-level lifecycle: Shared memory that is cleared when the cluster shuts down or restarts after an abnormal shutdown.
The following figure shows how memory is organized with PBP enabled.
When PBP is unavailable
The buffer pool from a previous run cannot always be reused. Availability is checked at two levels: the entire buffer pool, and individual pages within it.
Cluster-level checks
The PBP as a whole is discarded on restart if any of the following conditions are true:
-
The cluster specifications have changed, requiring a buffer pool of a different size.
-
The PBP was not created by the current cluster.
-
The control information stored in the PBP is invalid.
Page-level checks
Even when the overall PBP is valid, individual pages are skipped if any of the following conditions are true:
-
The page contains uncommitted transactions.
-
The buffer descriptor for the page is invalid.
-
The page contains an invalid Log Sequence Number (LSN).
-
The page properties are incorrect or invalid.
For example, a page with an X lock held by a process before shutdown cannot be reused — no process is available after restart to release the lock. After startup, PolarDB for PostgreSQL traverses all pages in the buffer pool to reclaim those that cannot be reused.
The following figure shows the full set of availability checks.
Performance benefits
Starting warm lets the cluster serve cached data immediately after restart — during both fault recovery and normal business workloads. The following figure shows an example of the performance improvement.
Fault recovery
In a simulated abnormal shutdown scenario where 2,093 MB of logs were replayed:
| Log replay duration | Fault recovery duration | |
|---|---|---|
| PBP disabled | 598s | 746s |
| PBP enabled | 68s | 294s |
The following figure shows the recovery time comparison.
Performance stability after restart
The following figure compares performance before and after a restart with PBP enabled.
Enable PBP
Set the following parameter to enable PBP:
polar_enable_persisted_buffer_pool = ON
A cluster restart is required for this change to take effect.