Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
49.2. Archive Module Callbacks
Prev UpChapter 49. Archive ModulesHome Next

49.2. Archive Module Callbacks#

The archive callbacks define the actual archiving behavior of the module. The server will call them as required to process each individual WAL file.

49.2.1. Startup Callback#

Thestartup_cb callback is called shortly after the module is loaded. This callback can be used to perform any additional initialization required. If the archive module has any state, it can usestate->private_data to store it.

typedef void (*ArchiveStartupCB) (ArchiveModuleState *state);

49.2.2. Check Callback#

Thecheck_configured_cb callback is called to determine whether the module is fully configured and ready to accept WAL files (e.g., its configuration parameters are set to valid values). If nocheck_configured_cb is defined, the server always assumes the module is configured.

typedef bool (*ArchiveCheckConfiguredCB) (ArchiveModuleState *state);

Iftrue is returned, the server will proceed with archiving the file by calling thearchive_file_cb callback. Iffalse is returned, archiving will not proceed, and the archiver will emit the following message to the server log:

WARNING:  archive_mode enabled, yet archiving is not configured

In the latter case, the server will periodically call this function, and archiving will proceed only when it returnstrue.

Note

When returningfalse, it may be useful to append some additional information to the generic warning message. To do that, provide a message to thearch_module_check_errdetail macro before returningfalse. Likeerrdetail(), this macro accepts a format string followed by an optional list of arguments. The resulting string will be emitted as theDETAIL line of the warning message.

49.2.3. Archive Callback#

Thearchive_file_cb callback is called to archive a single WAL file.

typedef bool (*ArchiveFileCB) (ArchiveModuleState *state, const char *file, const char *path);

Iftrue is returned, the server proceeds as if the file was successfully archived, which may include recycling or removing the original WAL file. Iffalse is returned or an error is thrown, the server will keep the original WAL file and retry archiving later.file will contain just the file name of the WAL file to archive, whilepath contains the full path of the WAL file (including the file name).

Note

Thearchive_file_cb callback is called in a short-lived memory context that will be reset between invocations. If you need longer-lived storage, create a memory context in the module'sstartup_cb callback.

49.2.4. Shutdown Callback#

Theshutdown_cb callback is called when the archiver process exits (e.g., after an error) or the value ofarchive_library changes. If noshutdown_cb is defined, no special action is taken in these situations. If the archive module has any state, this callback should free it to avoid leaks.

typedef void (*ArchiveShutdownCB) (ArchiveModuleState *state);


Prev Up Next
49.1. Initialization Functions Home Part VI. Reference
pdfepub
Go to PostgreSQL 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp