mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-13 18:07:05 +08:00
Previously, we called fsync() after writing out individual pg_xact,
pg_multixact and pg_commit_ts pages due to cache pressure, leading to
regular I/O stalls in user backends and recovery. Collapse requests for
the same file into a single system call as part of the next checkpoint,
as we already did for relation files, using the infrastructure developed
by commit 3eb77eba. This can cause a significant improvement to
recovery performance, especially when it's otherwise CPU-bound.
Hoist ProcessSyncRequests() up into CheckPointGuts() to make it clearer
that it applies to all the SLRU mini-buffer-pools as well as the main
buffer pool. Rearrange things so that data collected in CheckpointStats
includes SLRU activity.
Also remove the Shutdown{CLOG,CommitTS,SUBTRANS,MultiXact}() functions,
because they were redundant after the shutdown checkpoint that
immediately precedes them. (I'm not sure if they were ever needed, but
they aren't now.)
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> (parts)
Tested-by: Jakub Wartak <Jakub.Wartak@tomtom.com>
Discussion: https://postgr.es/m/CA+hUKGLJ=84YT+NvhkEEDAuUtVHMfQ9i-N7k_o50JmQ6Rpj_OQ@mail.gmail.com
68 lines
2.0 KiB
C
68 lines
2.0 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* sync.h
|
|
* File synchronization management code.
|
|
*
|
|
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/storage/sync.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef SYNC_H
|
|
#define SYNC_H
|
|
|
|
#include "storage/relfilenode.h"
|
|
|
|
/*
|
|
* Type of sync request. These are used to manage the set of pending
|
|
* requests to call a sync handler's sync or unlink functions at the next
|
|
* checkpoint.
|
|
*/
|
|
typedef enum SyncRequestType
|
|
{
|
|
SYNC_REQUEST, /* schedule a call of sync function */
|
|
SYNC_UNLINK_REQUEST, /* schedule a call of unlink function */
|
|
SYNC_FORGET_REQUEST, /* forget all calls for a tag */
|
|
SYNC_FILTER_REQUEST /* forget all calls satisfying match fn */
|
|
} SyncRequestType;
|
|
|
|
/*
|
|
* Which set of functions to use to handle a given request. The values of
|
|
* the enumerators must match the indexes of the function table in sync.c.
|
|
*/
|
|
typedef enum SyncRequestHandler
|
|
{
|
|
SYNC_HANDLER_MD = 0,
|
|
SYNC_HANDLER_CLOG,
|
|
SYNC_HANDLER_COMMIT_TS,
|
|
SYNC_HANDLER_MULTIXACT_OFFSET,
|
|
SYNC_HANDLER_MULTIXACT_MEMBER,
|
|
SYNC_HANDLER_NONE
|
|
} SyncRequestHandler;
|
|
|
|
/*
|
|
* A tag identifying a file. Currently it has the members required for md.c's
|
|
* usage, but sync.c has no knowledge of the internal structure, and it is
|
|
* liable to change as required by future handlers.
|
|
*/
|
|
typedef struct FileTag
|
|
{
|
|
int16 handler; /* SyncRequestHandler value, saving space */
|
|
int16 forknum; /* ForkNumber, saving space */
|
|
RelFileNode rnode;
|
|
uint32 segno;
|
|
} FileTag;
|
|
|
|
extern void InitSync(void);
|
|
extern void SyncPreCheckpoint(void);
|
|
extern void SyncPostCheckpoint(void);
|
|
extern void ProcessSyncRequests(void);
|
|
extern void RememberSyncRequest(const FileTag *ftag, SyncRequestType type);
|
|
extern void EnableSyncRequestForwarding(void);
|
|
extern bool RegisterSyncRequest(const FileTag *ftag, SyncRequestType type,
|
|
bool retryOnError);
|
|
|
|
#endif /* SYNC_H */
|