zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Wal receiver进程描述结构

进程 结构 描述 WAL receiver
2023-06-13 09:12:02 时间

WalReceiver进程的描述结构WalRcvData,仅当作记录

typedef struct
{
  pid_t    pid;//当前walreciver进程的pid
  WalRcvState walRcvState;//标记进程状态
  pg_time_t  startTime;//RequestXLogStream函数调用的开始时间

  //startup进程第一次启动walreceiver进程时,是流复制需要的开始位置
  XLogRecPtr  receiveStart;//拉取日志的起始位置,文件对齐了,也就是从段文件头开始
  TimeLineID  receiveStartTLI;//拉取日志的时间线
  /*receiver进程第一次启动时,设置为receiveStart和receiveStartTLI,后续每次接收的日志刷盘时更新*/
  XLogRecPtr  receivedUpto;
  TimeLineID  receivedTLI;
  //第一次启动时,拉取日志的起始位置
  XLogRecPtr  latestChunkStart;

  /*
   * Time of send and receive of any message received.
   */
  TimestampTz lastMsgSendTime;
  TimestampTz lastMsgReceiptTime;

  /*
   * Latest reported end of WAL on the sender
   */
  XLogRecPtr  latestWalEnd;
  TimestampTz latestWalEndTime;
  //连接信息:PrimaryConnInfo<---primary_conninfo
  char    conninfo[MAXCONNINFO];

  /*
   * Host name (this can be a host name, an IP address, or a directory path)
   * and port number of the active replication connection.
   */
  char    sender_host[NI_MAXHOST];
  int      sender_port;
  //复制槽名:PrimarySlotName <--- primary_slot_name
  char    slotname[NAMEDATALEN];

  /* set true once conninfo is ready to display (obfuscated pwds etc) */
  bool    ready_to_display;

  /*
   * Latch used by startup process to wake up walreceiver after telling it
   * where to start streaming (after setting receiveStart and
   * receiveStartTLI), and also to tell it to send apply feedback to the
   * primary whenever specially marked commit records are applied. This is
   * normally mapped to procLatch when walreceiver is running.
   */
  Latch     *latch;

  slock_t    mutex;      /* locks shared variables shown above */

  /*
   * force walreceiver reply?  This doesn't need to be locked; memory
   * barriers for ordering are sufficient.  But we do need atomic fetch and
   * store semantics, so use sig_atomic_t.
   */
  sig_atomic_t force_reply;  /* used as a bool */
}
typedef enum
{
  WALRCV_STOPPED,        /* stopped and mustn't start up again */
  WALRCV_STARTING,      /* launched, but the process hasn't
                 * initialized yet */
  WALRCV_STREAMING,      /* walreceiver is streaming */
  WALRCV_WAITING,        /* stopped streaming, waiting for orders */
  WALRCV_RESTARTING,      /* asked to restart streaming */
  WALRCV_STOPPING        /* requested to stop, but still running */
} WalRcvState;