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 <signal.h>
16 
17 #include "access/xlogdefs.h"
19 #include "datatype/timestamp.h"
20 #include "storage/lock.h"
21 
22 typedef struct LogicalRepWorker
23 {
24  /* Time at which this worker was launched. */
26 
27  /* Indicates if this slot is used or free. */
28  bool in_use;
29 
30  /* Increased everytime the slot is taken by new worker. */
32 
33  /* Pointer to proc array. NULL if not running. */
35 
36  /* Database id to connect to. */
38 
39  /* User to use for connection (will be same as owner of subscription). */
41 
42  /* Subscription id for the worker. */
44 
45  /* Used for initial table synchronization. */
47  char relstate;
50 
51  /* Stats. */
58 
59 /* Memory context for cached variables in apply worker. */
61 
62 /* libpqreceiver connection */
63 extern struct WalReceiverConn *wrconn;
64 
65 /* Worker and subscription objects. */
68 
69 extern bool in_remote_transaction;
70 extern volatile sig_atomic_t got_SIGHUP;
71 extern volatile sig_atomic_t got_SIGTERM;
72 
73 extern void logicalrep_worker_attach(int slot);
74 extern LogicalRepWorker *logicalrep_worker_find(Oid subid, Oid relid,
75  bool only_running);
76 extern void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname,
77  Oid userid, Oid relid);
78 extern void logicalrep_worker_stop(Oid subid, Oid relid);
79 extern void logicalrep_worker_wakeup(Oid subid, Oid relid);
81 
82 extern int logicalrep_sync_worker_count(Oid subid);
83 
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:888
void logicalrep_worker_sighup(SIGNAL_ARGS)
Definition: launcher.c:635
int64 TimestampTz
Definition: timestamp.h:39
int logicalrep_sync_worker_count(Oid subid)
Definition: launcher.c:652
LogicalRepWorker * logicalrep_worker_find(Oid subid, Oid relid, bool only_running)
Definition: launcher.c:225
Subscription * MySubscription
Definition: worker.c:109
TimestampTz last_send_time
XLogRecPtr last_lsn
void logicalrep_worker_sigterm(SIGNAL_ARGS)
Definition: launcher.c:621
void invalidate_syncing_table_states(Datum arg, int cacheid, uint32 hashvalue)
Definition: tablesync.c:193
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:251
XLogRecPtr relstate_lsn
void logicalrep_worker_wakeup(Oid subid, Oid relid)
Definition: launcher.c:510
unsigned short uint16
Definition: c.h:267
char * LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
Definition: tablesync.c:751
XLogRecPtr reply_lsn
static bool am_tablesync_worker(void)
volatile sig_atomic_t got_SIGHUP
Definition: launcher.c:83
volatile sig_atomic_t got_SIGTERM
Definition: launcher.c:84
void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker)
Definition: launcher.c:526
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:410
void process_syncing_tables(XLogRecPtr current_lsn)
Definition: tablesync.c:466
TimestampTz launch_time
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:535
Definition: proc.h:94
LogicalRepWorker * MyLogicalRepWorker
Definition: launcher.c:63
TimestampTz reply_time