PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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 "access/xlogdefs.h"
17 #include "datatype/timestamp.h"
18 #include "storage/lock.h"
19 
20 typedef struct LogicalRepWorker
21 {
22  /* Pointer to proc array. NULL if not running. */
24 
25  /* Database id to connect to. */
27 
28  /* User to use for connection (will be same as owner of subscription). */
30 
31  /* Subscription id for the worker. */
33 
34  /* Used for initial table synchronization. */
36  char relstate;
39 
40  /* Stats. */
47 
48 /* Memory context for cached variables in apply worker. */
50 
51 /* libpqreceiver connection */
52 extern struct WalReceiverConn *wrconn;
53 
54 /* Worker and subscription objects. */
57 
58 extern bool in_remote_transaction;
59 extern bool got_SIGTERM;
60 
61 extern void logicalrep_worker_attach(int slot);
62 extern LogicalRepWorker *logicalrep_worker_find(Oid subid, Oid relid,
63  bool only_running);
64 extern void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname,
65  Oid userid, Oid relid);
66 extern void logicalrep_worker_stop(Oid subid, Oid relid);
67 extern void logicalrep_worker_wakeup(Oid subid, Oid relid);
69 
70 extern int logicalrep_sync_worker_count(Oid subid);
71 
73 extern char *LogicalRepSyncTableStart(XLogRecPtr *origin_startpos);
74 void process_syncing_tables(XLogRecPtr current_lsn);
75 void invalidate_syncing_table_states(Datum arg, int cacheid,
76  uint32 hashvalue);
77 
78 static inline bool
80 {
81  return OidIsValid(MyLogicalRepWorker->relid);
82 }
83 
84 #endif /* WORKER_INTERNAL_H */
int slock_t
Definition: s_lock.h:888
int64 TimestampTz
Definition: timestamp.h:39
int logicalrep_sync_worker_count(Oid subid)
Definition: launcher.c:508
LogicalRepWorker * logicalrep_worker_find(Oid subid, Oid relid, bool only_running)
Definition: launcher.c:207
Subscription * MySubscription
Definition: worker.c:109
TimestampTz last_send_time
XLogRecPtr last_lsn
void logicalrep_worker_sigterm(SIGNAL_ARGS)
Definition: launcher.c:495
void invalidate_syncing_table_states(Datum arg, int cacheid, uint32 hashvalue)
Definition: tablesync.c:185
struct LogicalRepWorker LogicalRepWorker
struct WalReceiverConn * wrconn
Definition: worker.c:107
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:538
void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid, Oid relid)
Definition: launcher.c:233
XLogRecPtr relstate_lsn
void logicalrep_worker_wakeup(Oid subid, Oid relid)
Definition: launcher.c:420
char * LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
Definition: tablesync.c:693
XLogRecPtr reply_lsn
static bool am_tablesync_worker(void)
void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker)
Definition: launcher.c:436
unsigned int uint32
Definition: c.h:268
MemoryContext ApplyCacheContext
Definition: worker.c:105
uintptr_t Datum
Definition: postgres.h:372
void logicalrep_worker_stop(Oid subid, Oid relid)
Definition: launcher.c:328
void process_syncing_tables(XLogRecPtr current_lsn)
Definition: tablesync.c:412
TimestampTz last_recv_time
#define SIGNAL_ARGS
Definition: c.h:1079
uint64 XLogRecPtr
Definition: xlogdefs.h:21
bool in_remote_transaction
Definition: worker.c:112
void * arg
void logicalrep_worker_attach(int slot)
Definition: launcher.c:445
Definition: proc.h:89
LogicalRepWorker * MyLogicalRepWorker
Definition: launcher.c:62
bool got_SIGTERM
Definition: launcher.c:78
TimestampTz reply_time