* Copyright (c) 2020 Huawei Technologies Co.,Ltd.
*
* openGauss is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* ---------------------------------------------------------------------------------------
*
* datareceiver.h
*
*
*
* IDENTIFICATION
* src/include/replication/datareceiver.h
*
* ---------------------------------------------------------------------------------------
*/
#ifndef _DATARECEIVER_H
#define _DATARECEIVER_H
#include "storage/latch.h"
#include "storage/spin.h"
#include "storage/custorage.h"
#include "pgtime.h"
#include "postgres.h"
#include "knl/knl_variable.h"
#include "replication/bcm.h"
#include "replication/dataqueuedefs.h"
#include "replication/walreceiver.h"
* MAXCONNINFO: maximum size of a connection string.
*
* XXX: Should this move to pg_config_manual.h?
*/
#define MAXCONNINFO 1024
#define DUMMY_STANDBY_DATADIR "base/dummy_standby"
* Values for DataRcv->dataRcvState.
*/
typedef enum {
DATARCV_STOPPED,
DATARCV_STARTING,
* initialized yet */
DATARCV_RUNNING,
DATARCV_STOPPING
} DataRcvState;
typedef struct DataRcvData {
* PID of currently active datareceiver process, its current state and
* start time (actually, the time at which it was requested to be
* started).
*/
ThreadId pid;
ThreadId writerPid;
int lwpId;
DataRcvState dataRcvState;
pg_time_t startTime;
bool isRuning;
* Time of send and receive of any message received.
*/
TimestampTz lastMsgSendTime;
TimestampTz lastMsgReceiptTime;
* Latest reported end of Data on the sender
*/
TimestampTz latestDataEndTime;
DataQueuePtr sendPosition;
DataQueuePtr receivePosition;
DataQueuePtr localWritePosition;
int dummyStandbySyncPercent;
* connection string; is used for datareceiver to connect with the primary.
*/
char conninfo[MAXCONNINFO];
ReplConnTarget conn_target;
Latch* datarcvWriterLatch;
slock_t mutex;
} DataRcvData;
typedef struct data_writer_rel_key {
RelFileNode node;
ForkNumber forkno;
int attid;
StorageEngine type;
} data_writer_rel_key;
typedef struct data_writer_rel {
data_writer_rel_key key;
Relation reln;
CUStorage* cuStorage;
} data_writer_rel;
extern bool dummy_data_writer_use_file;
extern void DataReceiverMain(void);
extern Size DataRcvShmemSize(void);
extern void DataRcvShmemInit(void);
extern bool DataRcvInProgress(void);
extern void ShutdownDataRcv(void);
extern void StartupDataStreaming(void);
extern void RequestDataStreaming(const char* conninfo, ReplConnTarget conn_target);
extern void InitDummyDataNum(void);
extern void WakeupDataRcvWriter(void);
extern void wakeupWalRcvWriter(void);
extern bool DataRcvWriterInProgress(void);
extern void DataRcvDataCleanup(void);
extern void walRcvDataCleanup(void);
extern void DataRcvWriterMain(void);
extern int DataRcvWrite(void);
extern void DataRcvSendReply(bool force, bool requestReply);
extern void SetDataRcvDummyStandbySyncPercent(int percent);
extern int GetDataRcvDummyStandbySyncPercent(void);
extern void SetDataRcvWriterPID(ThreadId tid);
extern void ProcessDataRcvInterrupts(void);
extern void CloseDataFile(void);
extern uint32 DoDataWrite(char* buf, uint32 nbytes);
#endif