mirror of
https://github.com/postgres/postgres.git
synced 2026-02-18 18:25:17 -05:00
Similar to what was fixed in commit 9915de6c1c for replication slots,
but this time it's related to replication origins: DROP SUBSCRIPTION
attempts to drop the replication origin, but that fails if the
replication worker process hasn't yet marked it unused. This causes
failures in the buildfarm:
ERROR: could not drop replication origin with OID 1, in use by PID 34069
Like the aforementioned commit, fix by having the process running DROP
SUBSCRIPTION sleep until the worker marks the the replication origin
struct as free. This uses a condition variable on each replication
origin shmem state struct, so that the session trying to drop can sleep
and expect to be awakened by the process keeping the origin open.
Also fix a SGML markup in the previous commit.
Discussion: https://postgr.es/m/20170808001433.rozlseaf4m2wkw3n@alvherre.pgsql
74 lines
2.3 KiB
C
74 lines
2.3 KiB
C
/*-------------------------------------------------------------------------
|
|
* origin.h
|
|
* Exports from replication/logical/origin.c
|
|
*
|
|
* Copyright (c) 2013-2017, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/replication/origin.h
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PG_ORIGIN_H
|
|
#define PG_ORIGIN_H
|
|
|
|
#include "fmgr.h"
|
|
#include "access/xlog.h"
|
|
#include "access/xlogdefs.h"
|
|
#include "access/xlogreader.h"
|
|
#include "catalog/pg_replication_origin.h"
|
|
|
|
typedef struct xl_replorigin_set
|
|
{
|
|
XLogRecPtr remote_lsn;
|
|
RepOriginId node_id;
|
|
bool force;
|
|
} xl_replorigin_set;
|
|
|
|
typedef struct xl_replorigin_drop
|
|
{
|
|
RepOriginId node_id;
|
|
} xl_replorigin_drop;
|
|
|
|
#define XLOG_REPLORIGIN_SET 0x00
|
|
#define XLOG_REPLORIGIN_DROP 0x10
|
|
|
|
#define InvalidRepOriginId 0
|
|
#define DoNotReplicateId PG_UINT16_MAX
|
|
|
|
extern PGDLLIMPORT RepOriginId replorigin_session_origin;
|
|
extern PGDLLIMPORT XLogRecPtr replorigin_session_origin_lsn;
|
|
extern PGDLLIMPORT TimestampTz replorigin_session_origin_timestamp;
|
|
|
|
/* API for querying & manipulating replication origins */
|
|
extern RepOriginId replorigin_by_name(char *name, bool missing_ok);
|
|
extern RepOriginId replorigin_create(char *name);
|
|
extern void replorigin_drop(RepOriginId roident, bool nowait);
|
|
extern bool replorigin_by_oid(RepOriginId roident, bool missing_ok,
|
|
char **roname);
|
|
|
|
/* API for querying & manipulating replication progress tracking */
|
|
extern void replorigin_advance(RepOriginId node,
|
|
XLogRecPtr remote_commit,
|
|
XLogRecPtr local_commit,
|
|
bool go_backward, bool wal_log);
|
|
extern XLogRecPtr replorigin_get_progress(RepOriginId node, bool flush);
|
|
|
|
extern void replorigin_session_advance(XLogRecPtr remote_commit,
|
|
XLogRecPtr local_commit);
|
|
extern void replorigin_session_setup(RepOriginId node);
|
|
extern void replorigin_session_reset(void);
|
|
extern XLogRecPtr replorigin_session_get_progress(bool flush);
|
|
|
|
/* Checkpoint/Startup integration */
|
|
extern void CheckPointReplicationOrigin(void);
|
|
extern void StartupReplicationOrigin(void);
|
|
|
|
/* WAL logging */
|
|
void replorigin_redo(XLogReaderState *record);
|
|
void replorigin_desc(StringInfo buf, XLogReaderState *record);
|
|
const char *replorigin_identify(uint8 info);
|
|
|
|
/* shared memory allocation */
|
|
extern Size ReplicationOriginShmemSize(void);
|
|
extern void ReplicationOriginShmemInit(void);
|
|
|
|
#endif /* PG_ORIGIN_H */
|