mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Add GUC to enable logging of replication commands.
Previously replication commands like IDENTIFY_COMMAND were not logged even when log_statements is set to all. Some users who want to audit all types of statements were not satisfied with this situation. To address the problem, this commit adds new GUC log_replication_commands. If it's enabled, all replication commands are logged in the server log. There are many ways to allow us to enable that logging. For example, we can extend log_statement so that replication commands are logged when it's set to all. But per discussion in the community, we reached the consensus to add separate GUC for that. Reviewed by Ian Barwick, Robert Haas and Heikki Linnakangas.
This commit is contained in:
@@ -108,6 +108,7 @@ bool am_db_walsender = false; /* Connected to a database? */
|
||||
int max_wal_senders = 0; /* the maximum number of concurrent walsenders */
|
||||
int wal_sender_timeout = 60 * 1000; /* maximum time to send one
|
||||
* WAL data message */
|
||||
bool log_replication_commands = false;
|
||||
|
||||
/*
|
||||
* State for WalSndWakeupRequest
|
||||
@@ -1267,14 +1268,20 @@ exec_replication_command(const char *cmd_string)
|
||||
MemoryContext cmd_context;
|
||||
MemoryContext old_context;
|
||||
|
||||
/*
|
||||
* Log replication command if log_replication_commands is enabled.
|
||||
* Even when it's disabled, log the command with DEBUG1 level for
|
||||
* backward compatibility.
|
||||
*/
|
||||
ereport(log_replication_commands ? LOG : DEBUG1,
|
||||
(errmsg("received replication command: %s", cmd_string)));
|
||||
|
||||
/*
|
||||
* CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot until the next
|
||||
* command arrives. Clean up the old stuff if there's anything.
|
||||
*/
|
||||
SnapBuildClearExportedSnapshot();
|
||||
|
||||
elog(DEBUG1, "received replication command: %s", cmd_string);
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
cmd_context = AllocSetContextCreate(CurrentMemoryContext,
|
||||
|
Reference in New Issue
Block a user