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 /* Main memory context for apply worker. Permanent during worker lifetime. */
61 
62 /* libpqreceiver connection */
63 extern struct WalReceiverConn *wrconn;
64 
65 /* Worker and subscription objects. */
68 
69 extern bool in_remote_transaction;
70 
71 extern void logicalrep_worker_attach(int slot);
72 extern LogicalRepWorker *logicalrep_worker_find(Oid subid, Oid relid,
73  bool only_running);
74 extern void logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname,
75  Oid userid, Oid relid);
76 extern void logicalrep_worker_stop(Oid subid, Oid relid);
77 extern void logicalrep_worker_wakeup(Oid subid, Oid relid);
79 
80 extern int logicalrep_sync_worker_count(Oid subid);
81 
82 extern char *LogicalRepSyncTableStart(XLogRecPtr *origin_startpos);
83 void process_syncing_tables(XLogRecPtr current_lsn);
84 void invalidate_syncing_table_states(Datum arg, int cacheid,
85  uint32 hashvalue);
86 
87 static inline bool
89 {
90  return OidIsValid(MyLogicalRepWorker->relid);
91 }
92 
93 #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:655
LogicalRepWorker * logicalrep_worker_find(Oid subid, Oid relid, bool only_running)
Definition: launcher.c:229
Subscription * MySubscription
Definition: worker.c:111
TimestampTz last_send_time
XLogRecPtr last_lsn
void invalidate_syncing_table_states(Datum arg, int cacheid, uint32 hashvalue)
Definition: tablesync.c:258
struct LogicalRepWorker LogicalRepWorker
struct WalReceiverConn * wrconn
Definition: worker.c:109
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:256
XLogRecPtr relstate_lsn
void logicalrep_worker_wakeup(Oid subid, Oid relid)
Definition: launcher.c:521
unsigned short uint16
Definition: c.h:267
char * LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
Definition: tablesync.c:789
XLogRecPtr reply_lsn
static bool am_tablesync_worker(void)
void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker)
Definition: launcher.c:537
unsigned int uint32
Definition: c.h:268
MemoryContext ApplyContext
Definition: worker.c:107
uintptr_t Datum
Definition: postgres.h:372
void logicalrep_worker_stop(Oid subid, Oid relid)
Definition: launcher.c:415
void process_syncing_tables(XLogRecPtr current_lsn)
Definition: tablesync.c:518
TimestampTz launch_time
TimestampTz last_recv_time
uint64 XLogRecPtr
Definition: xlogdefs.h:21
bool in_remote_transaction
Definition: worker.c:114
void * arg
void logicalrep_worker_attach(int slot)
Definition: launcher.c:546
Definition: proc.h:94
LogicalRepWorker * MyLogicalRepWorker
Definition: launcher.c:63
TimestampTz reply_time