PostgreSQL Source Code  git master
worker_internal.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * worker_internal.h
4  * Internal headers shared by logical replication workers.
5  *
6  * Portions Copyright (c) 2016-2021, PostgreSQL Global Development Group
7  *
8  * src/include/replication/worker_internal.h
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef WORKER_INTERNAL_H
13 #define WORKER_INTERNAL_H
14 
15 #include <signal.h>
16 
17 #include "access/xlogdefs.h"
19 #include "datatype/timestamp.h"
20 #include "storage/lock.h"
21 #include "storage/spin.h"
22 
23 
24 typedef struct LogicalRepWorker
25 {
26  /* Time at which this worker was launched. */
28 
29  /* Indicates if this slot is used or free. */
30  bool in_use;
31 
32  /* Increased every time the slot is taken by new worker. */
34 
35  /* Pointer to proc array. NULL if not running. */
37 
38  /* Database id to connect to. */
40 
41  /* User to use for connection (will be same as owner of subscription). */
43 
44  /* Subscription id for the worker. */
46 
47  /* Used for initial table synchronization. */
49  char relstate;
52 
53  /* Stats. */
60 
61 /* Main memory context for apply worker. Permanent during worker lifetime. */
63 
64 /* libpqreceiver connection */
65 extern struct WalReceiverConn *wrconn;
66 
67 /* Worker and subscription objects. */
70 
71 extern bool in_remote_transaction;
72 
73 extern void logicalrep_worker_attach(int slot);
75  bool only_running);
76 extern List *logicalrep_workers_find(Oid subid, bool only_running);
77 extern void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname,
78  Oid userid, Oid relid);
83 
85 
86 extern char *LogicalRepSyncTableStart(XLogRecPtr *origin_startpos);
87 void process_syncing_tables(XLogRecPtr current_lsn);
88 void invalidate_syncing_table_states(Datum arg, int cacheid,
89  uint32 hashvalue);
90 
91 static inline bool
93 {
94  return OidIsValid(MyLogicalRepWorker->relid);
95 }
96 
97 #endif /* WORKER_INTERNAL_H */
int slock_t
Definition: s_lock.h:934
int64 TimestampTz
Definition: timestamp.h:39
int logicalrep_sync_worker_count(Oid subid)
Definition: launcher.c:724
LogicalRepWorker * logicalrep_worker_find(Oid subid, Oid relid, bool only_running)
Definition: launcher.c:235
Subscription * MySubscription
Definition: worker.c:161
TimestampTz last_send_time
XLogRecPtr last_lsn
void invalidate_syncing_table_states(Datum arg, int cacheid, uint32 hashvalue)
Definition: tablesync.c:257
struct LogicalRepWorker LogicalRepWorker
struct WalReceiverConn * wrconn
Definition: worker.c:159
unsigned int Oid
Definition: postgres_ext.h:31
NameData subname
#define OidIsValid(objectId)
Definition: c.h:698
List * logicalrep_workers_find(Oid subid, bool only_running)
Definition: launcher.c:263
void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid, Oid relid)
Definition: launcher.c:286
XLogRecPtr relstate_lsn
void logicalrep_worker_wakeup(Oid subid, Oid relid)
Definition: launcher.c:598
unsigned short uint16
Definition: c.h:428
char * LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
Definition: tablesync.c:819
XLogRecPtr reply_lsn
static bool am_tablesync_worker(void)
void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker)
Definition: launcher.c:618
unsigned int uint32
Definition: c.h:429
MemoryContext ApplyContext
Definition: worker.c:154
uintptr_t Datum
Definition: postgres.h:367
void logicalrep_worker_stop(Oid subid, Oid relid)
Definition: launcher.c:456
void process_syncing_tables(XLogRecPtr current_lsn)
Definition: tablesync.c:529
TimestampTz launch_time
TimestampTz last_recv_time
uint64 XLogRecPtr
Definition: xlogdefs.h:21
bool in_remote_transaction
Definition: worker.c:164
void * arg
void logicalrep_worker_stop_at_commit(Oid subid, Oid relid)
Definition: launcher.c:553
void logicalrep_worker_attach(int slot)
Definition: launcher.c:629
Definition: proc.h:121
Definition: pg_list.h:50
LogicalRepWorker * MyLogicalRepWorker
Definition: launcher.c:57
TimestampTz reply_time