Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/backend/replication/slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
#include "utils/builtins.h"
#include "utils/guc_hooks.h"
#include "utils/varlena.h"
#include "replication/logical_slots_store.h"

/* NEON: Hook for storing logical slot state - implemented by neon extension */
logical_slots_store_hook_type logical_slots_store_hook = NULL;

/*
* Replication slot on-disk data structure.
Expand Down Expand Up @@ -2182,6 +2186,12 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
slot->last_saved_confirmed_flush = cp.slotdata.confirmed_flush;
SpinLockRelease(&slot->mutex);

/*
* NEON: Store to external storage while holding io_in_progress_lock.
*/
if (logical_slots_store_hook != NULL)
logical_slots_store_hook(dir, &cp.slotdata);

LWLockRelease(&slot->io_in_progress_lock);
}

Expand Down
24 changes: 24 additions & 0 deletions src/include/replication/logical_slots_store.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*-------------------------------------------------------------------------
*
* logical_slots_store.h
* Logical replication slot state persistence
*
* IDENTIFICATION
* src/include/replication/logical_slots_store.h
*
*-------------------------------------------------------------------------
*/
#ifndef LOGICAL_SLOTS_STORE_H
#define LOGICAL_SLOTS_STORE_H

#include "replication/slot.h"

/* Hook for storing logical slot state */
typedef void (*logical_slots_store_hook_type) (const char *dir, ReplicationSlotPersistentData *saved_data);
extern PGDLLIMPORT logical_slots_store_hook_type logical_slots_store_hook;

/* Extension function - called by the hook */
extern void store_logical_slots_state(const char *dir, ReplicationSlotPersistentData *saved_data);

#endif /* LOGICAL_SLOTS_STORE_H */