Skip to content

Commit 3a66581

Browse files
committed
Prevent log_replication_commands from causing SQL commands to be logged.
Commit 7c4f524 allowed walsender to execute normal SQL commands to support table sync feature in logical replication. Previously while log_statement caused such SQL commands to be logged, log_replication_commands caused them to be logged, too. That is, such SQL commands were logged twice unexpectedly when those settings were both enabled. This commit forces log_replication_commands to log only replication commands, to prevent normal SQL commands from being logged twice. Author: Masahiko Sawada Reviewed-by: Kyotaro Horiguchi Reported-by: Fujii Masao Discussion: http://postgr.es/m/CAHGQGwFDWh_Qr-q_GEMpD+qH=vYPMdVqw=ZOSY3kX_Pna9R9SA@mail.gmail.com
1 parent 88b0a31 commit 3a66581

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/backend/replication/walsender.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,14 +1368,6 @@ exec_replication_command(const char *cmd_string)
13681368
MemoryContext cmd_context;
13691369
MemoryContext old_context;
13701370

1371-
/*
1372-
* Log replication command if log_replication_commands is enabled. Even
1373-
* when it's disabled, log the command with DEBUG1 level for backward
1374-
* compatibility.
1375-
*/
1376-
ereport(log_replication_commands ? LOG : DEBUG1,
1377-
(errmsg("received replication command: %s", cmd_string)));
1378-
13791371
/*
13801372
* CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot until the next
13811373
* command arrives. Clean up the old stuff if there's anything.
@@ -1399,6 +1391,16 @@ exec_replication_command(const char *cmd_string)
13991391

14001392
cmd_node = replication_parse_result;
14011393

1394+
/*
1395+
* Log replication command if log_replication_commands is enabled. Even
1396+
* when it's disabled, log the command with DEBUG1 level for backward
1397+
* compatibility. Note that SQL commands are not logged here, and will be
1398+
* logged later if log_statement is enabled.
1399+
*/
1400+
if (cmd_node->type != T_SQLCmd)
1401+
ereport(log_replication_commands ? LOG : DEBUG1,
1402+
(errmsg("received replication command: %s", cmd_string)));
1403+
14021404
/*
14031405
* CREATE_REPLICATION_SLOT ... LOGICAL exports a snapshot. If it was
14041406
* called outside of transaction the snapshot should be cleared here.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy