recovery_init_sync_method
Read PG 18 manual ↗When set to fsync, which is the default, PostgreSQL will recursively open and synchronize all files in the data directory before crash recovery begins.
- Type
- enum
- Context
- sighup
- Measured default
- fsync
- Unit
- —
- Metadata snapshot
- 18
- Allowed values
- fsync, syncfs
Definition PG 18 manual
When set to fsync, which is the default, PostgreSQL will recursively open and synchronize all files in the data directory before crash recovery begins. The search for files will follow symbolic links for the WAL directory and each configured tablespace (but not any other symbolic links). This is intended to make sure that all WAL and data files are durably stored on disk before replaying changes. This applies whenever starting a database cluster that did not shut down cleanly, including copies created with pg_basebackup.
On Linux, syncfs may be used instead, to ask the operating system to synchronize the file systems that contain the data directory, the WAL files and each tablespace (but not any other file systems that may be reachable through symbolic links). This may be a lot faster than the fsync setting, because it doesn't need to open each file one by one. On the other hand, it may be slower if a file system is shared by other applications that modify a lot of files, since those files will also be written to disk. Furthermore, on versions of Linux before 5.8, I/O errors encountered while writing data to disk may not be reported to PostgreSQL, and relevant error messages may appear only in kernel logs.
This parameter can only be set in the postgresql.conf file or on the server command line.
Measured default history
| Version interval | Default |
|---|---|
| 14 – 19 | fsync |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
Sets the method for synchronizing the data directory before crash recovery. A configuration reload applies a new value; existing work already in flight is not retroactively changed.
Before crash recovery, PostgreSQL synchronizes the data directory so replay is not built on unflushed copied files. fsync walks files portably; where supported, syncfs can synchronize the containing filesystem more quickly but has a broader scope.
Monitor and change recovery_init_sync_method together with data_sync_retry, restart_after_crash, fsync. Validate on the relevant server role and real workload, then use its sighup context to choose session change, reload, or restart; a historical boot default is not the current effective value.
Operational considerations
Confusing the boot default of recovery_init_sync_method with its current effective value.
Ignoring its sighup context when deciding when it takes effect.
Changing several interacting settings at once and losing causal evidence.
Rolling out globally without testing the real failure or workload boundary.
Workload guidance
OLAP: Test separately under long queries, batch jobs, and peak concurrency rather than copying OLTP assumptions to analytical nodes.
OLTP: Change recovery_init_sync_method only from an explicit failure model and measured evidence. Validate in a session/test environment, deploy according to its context, and retain a rollback value.
SMALL: Keep the default without a concrete problem; small systems should not trade global compatibility or failure semantics for a marginal gain.
Version history 2
- PG 16 → 17changed
- PG 13 → 14added
Related entries
Further reading
Definition snapshot: english-manuals:9b7655460d313a843f79648985f… · English manual source