Skip to content

Commit

Permalink
Cherry-pick from V16: Undo walloging replorgin file on checkpoint (#472)
Browse files Browse the repository at this point in the history
* Undo walloging replorgin file on checkpoint

* Remove inserted break statement from more recent version of Postgres

* Remove unintended changes

* Undo unused include

---------

Co-authored-by: Konstantin Knizhnik <[email protected]>
  • Loading branch information
2 people authored and MMeent committed Sep 4, 2024
1 parent fe6eb33 commit 9156d63
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/backend/replication/logical/origin.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
#include "nodes/execnodes.h"
#include "pgstat.h"
#include "replication/logical.h"
#include "replication/message.h"
#include "replication/origin.h"
#include "replication/slot.h"
#include "storage/condition_variable.h"
Expand Down Expand Up @@ -580,14 +579,10 @@ CheckPointReplicationOrigin(void)
int i;
uint32 magic = REPLICATION_STATE_MAGIC;
pg_crc32c crc;
char *buf;
size_t chkp_size;

if (max_replication_slots == 0)
return;

buf = palloc(sizeof(magic) + max_replication_slots*sizeof(ReplicationStateOnDisk) + sizeof(crc));

INIT_CRC32C(crc);

/* make sure no old temp file is remaining */
Expand Down Expand Up @@ -621,9 +616,6 @@ CheckPointReplicationOrigin(void)
errmsg("could not write to file \"%s\": %m",
tmppath)));
}
memcpy(buf, &magic, sizeof magic);
chkp_size = sizeof(magic);

COMP_CRC32C(crc, &magic, sizeof(magic));

/* prevent concurrent creations/drops */
Expand Down Expand Up @@ -666,8 +658,6 @@ CheckPointReplicationOrigin(void)
errmsg("could not write to file \"%s\": %m",
tmppath)));
}
memcpy(buf + chkp_size, &disk_state, sizeof(disk_state));
chkp_size += sizeof(disk_state);

COMP_CRC32C(crc, &disk_state, sizeof(disk_state));
}
Expand All @@ -687,16 +677,6 @@ CheckPointReplicationOrigin(void)
errmsg("could not write to file \"%s\": %m",
tmppath)));
}
if (chkp_size != sizeof(magic)) /* has some valid origins */
{
memcpy(buf + chkp_size, &crc, sizeof crc);
chkp_size += sizeof(crc);

/* NEON specific: persist snapshot in storage using logical message */
LogLogicalMessage("neon-file:pg_logical/replorigin_checkpoint", buf,
chkp_size, false, true);
}
pfree(buf);

if (CloseTransientFile(tmpfd) != 0)
ereport(PANIC,
Expand Down

0 comments on commit 9156d63

Please sign in to comment.