Skip to content

Commit 37de60d

Browse files
knizhnikKonstantin Knizhnik
andauthored
Do not wallog AUX files at replica (#517)
Co-authored-by: Konstantin Knizhnik <[email protected]>
1 parent 9ad2f3c commit 37de60d

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/backend/access/heap/rewriteheap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,11 @@ static void
759759
wallog_mapping_file(char const* path, int fd)
760760
{
761761
char prefix[MAXPGPATH];
762+
763+
/* Do not wallog AUX file at replica */
764+
if (!XLogInsertAllowed())
765+
return;
766+
762767
snprintf(prefix, sizeof(prefix), "neon-file:%s", path);
763768
if (fd < 0)
764769
{

src/backend/replication/logical/snapbuild.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,10 +1775,13 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
17751775
(errcode_for_file_access(),
17761776
errmsg("could not open file \"%s\": %m", tmppath)));
17771777

1778-
/* NEON specific: persist snapshot in storage using logical message */
1779-
snprintf(prefix, sizeof(prefix), "neon-file:%s", path);
1780-
LogLogicalMessage(prefix, (char *) ondisk, needed_length, false, true);
1781-
1778+
/* Do not wallog AUX file at replica */
1779+
if (XLogInsertAllowed())
1780+
{
1781+
/* NEON specific: persist snapshot in storage using logical message */
1782+
snprintf(prefix, sizeof(prefix), "neon-file:%s", path);
1783+
LogLogicalMessage(prefix, (char *) ondisk, needed_length, false, true);
1784+
}
17821785
errno = 0;
17831786
pgstat_report_wait_start(WAIT_EVENT_SNAPBUILD_WRITE);
17841787
if ((write(fd, ondisk, needed_length)) != needed_length)
@@ -2141,10 +2144,13 @@ CheckPointSnapBuild(void)
21412144
{
21422145
elog(DEBUG1, "removing snapbuild snapshot %s", path);
21432146

2144-
/* NEON specific: delete file from storage using logical message */
2145-
snprintf(prefix, sizeof(prefix), "neon-file:%s", path);
2146-
LogLogicalMessage(prefix, NULL, 0, false, true);
2147-
2147+
/* Do not wallog AUX file at replica */
2148+
if (XLogInsertAllowed())
2149+
{
2150+
/* NEON specific: delete file from storage using logical message */
2151+
snprintf(prefix, sizeof(prefix), "neon-file:%s", path);
2152+
LogLogicalMessage(prefix, NULL, 0, false, true);
2153+
}
21482154
/*
21492155
* It's not particularly harmful, though strange, if we can't
21502156
* remove the file here. Don't prevent the checkpoint from

src/backend/replication/slot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ ReplicationSlotDropPtr(ReplicationSlot *slot)
899899
sprintf(path, "pg_replslot/%s", NameStr(slot->data.name));
900900
sprintf(tmppath, "pg_replslot/%s.tmp", NameStr(slot->data.name));
901901

902-
if (SlotIsLogical(slot))
902+
if (SlotIsLogical(slot) && XLogInsertAllowed())
903903
{
904904
/* NEON specific: delete slot from storage using logical message */
905905
char prefix[MAXPGPATH];
@@ -2087,7 +2087,7 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
20872087
ReplicationSlotOnDiskChecksummedSize);
20882088
FIN_CRC32C(cp.checksum);
20892089

2090-
if (SlotIsLogical(slot) && cp.slotdata.restart_lsn != InvalidXLogRecPtr)
2090+
if (SlotIsLogical(slot) && XLogInsertAllowed() && cp.slotdata.restart_lsn != InvalidXLogRecPtr)
20912091
{
20922092
/* NEON specific: persist slot in storage using logical message */
20932093
char prefix[MAXPGPATH];

0 commit comments

Comments
 (0)