2 49.2. Archive Module Callbacks #
4 49.2.1. Startup Callback
6 49.2.3. Archive Callback
7 49.2.4. Shutdown Callback
9 The archive callbacks define the actual archiving behavior of the
10 module. The server will call them as required to process each
13 49.2.1. Startup Callback #
15 The startup_cb callback is called shortly after the module is loaded.
16 This callback can be used to perform any additional initialization
17 required. If the archive module has any state, it can use
18 state->private_data to store it.
19 typedef void (*ArchiveStartupCB) (ArchiveModuleState *state);
21 49.2.2. Check Callback #
23 The check_configured_cb callback is called to determine whether the
24 module is fully configured and ready to accept WAL files (e.g., its
25 configuration parameters are set to valid values). If no
26 check_configured_cb is defined, the server always assumes the module is
28 typedef bool (*ArchiveCheckConfiguredCB) (ArchiveModuleState *state);
30 If true is returned, the server will proceed with archiving the file by
31 calling the archive_file_cb callback. If false is returned, archiving
32 will not proceed, and the archiver will emit the following message to
34 WARNING: archive_mode enabled, yet archiving is not configured
36 In the latter case, the server will periodically call this function,
37 and archiving will proceed only when it returns true.
41 When returning false, it may be useful to append some additional
42 information to the generic warning message. To do that, provide a
43 message to the arch_module_check_errdetail macro before returning
44 false. Like errdetail(), this macro accepts a format string followed by
45 an optional list of arguments. The resulting string will be emitted as
46 the DETAIL line of the warning message.
48 49.2.3. Archive Callback #
50 The archive_file_cb callback is called to archive a single WAL file.
51 typedef bool (*ArchiveFileCB) (ArchiveModuleState *state, const char *file, cons
54 If true is returned, the server proceeds as if the file was
55 successfully archived, which may include recycling or removing the
56 original WAL file. If false is returned or an error is thrown, the
57 server will keep the original WAL file and retry archiving later. file
58 will contain just the file name of the WAL file to archive, while path
59 contains the full path of the WAL file (including the file name).
63 The archive_file_cb callback is called in a short-lived memory context
64 that will be reset between invocations. If you need longer-lived
65 storage, create a memory context in the module's startup_cb callback.
67 49.2.4. Shutdown Callback #
69 The shutdown_cb callback is called when the archiver process exits
70 (e.g., after an error) or the value of archive_library changes. If no
71 shutdown_cb is defined, no special action is taken in these situations.
72 If the archive module has any state, this callback should free it to
74 typedef void (*ArchiveShutdownCB) (ArchiveModuleState *state);