shared storage adapt dual cluster about deploy and main standby only read

This commit is contained in:
shirley_zhengx
2023-02-28 15:32:46 +08:00
parent ebed50c1aa
commit 7a3380c19d
25 changed files with 663 additions and 119 deletions

View File

@ -134,7 +134,7 @@ typedef enum WalLevel {
/* Do we need to WAL-log information required only for Hot Standby and logical replication? */
#define XLogStandbyInfoActive() \
(g_instance.attr.attr_storage.wal_level >= WAL_LEVEL_HOT_STANDBY && \
!g_instance.attr.attr_storage.dms_attr.enable_dms)
(!g_instance.attr.attr_storage.dms_attr.enable_dms || SS_PRIMARY_STANDBY_CLUSTER_NORMAL))
/* Do we need to WAL-log information required only for logical replication? */
#define XLogLogicalInfoActive() (g_instance.attr.attr_storage.wal_level >= WAL_LEVEL_LOGICAL)
extern const char* DemoteModeDescs[];
@ -612,6 +612,9 @@ typedef struct XLogCtlData {
bool is_need_log_remain_segs;
XLogRecPtr remainCommitLsn;
/* streaming replication during pre-reading for dss */
XLogRecPtr xlogFlushPtrForPerRead;
slock_t info_lck; /* locks shared variables shown above */
} XLogCtlData;

View File

@ -314,6 +314,9 @@ struct XLogReaderState {
XLogRecPtr preReadStartPtr;
char* preReadBuf;
char* preReadBufOrigin;
/* streaming replication during pre-reading for dss */
XLogRecPtr xlogFlushPtrForPerRead;
/* last read segment, segment offset, TLI for data currently in readBuf */
XLogSegNo readSegNo;

View File

@ -89,6 +89,27 @@
(ENABLE_DMS && (g_instance.dms_cxt.SSClusterState == NODESTATE_STANDBY_WAITING || \
g_instance.dms_cxt.SSClusterState == NODESTATE_STANDBY_REDIRECT))
/* Mode in dorado hyperreplication and dms enabled as follow */
/* main standby which is runing normally, not in intermediate state */
#define SS_PRIMARY_CLUSTER_NORMAL_PRIMARY \
(ENABLE_DMS && (t_thrd.xlog_cxt.server_mode == PRIMARY_MODE) && \
(g_instance.attr.attr_common.cluster_run_mode == RUN_MODE_PRIMARY) && \
(g_instance.attr.attr_storage.xlog_file_path != 0))
/* main standby which is runing normally, not in intermediate state */
#define SS_STANDBY_CLUSTER_NORMAL_MAIN_STANDBY \
(ENABLE_DMS && (t_thrd.xlog_cxt.server_mode == STANDBY_MODE || \
t_thrd.postmaster_cxt.HaShmData->current_mode == STANDBY_MODE) && \
(g_instance.attr.attr_common.cluster_run_mode == RUN_MODE_STANDBY) && \
(g_instance.attr.attr_storage.xlog_file_path != 0))
/* main standby which is runing normally, not in intermediate state */
#define SS_PRIMARY_STANDBY_CLUSTER_NORMAL \
(ENABLE_DMS && ((g_instance.attr.attr_common.cluster_run_mode == RUN_MODE_PRIMARY) || \
(g_instance.attr.attr_common.cluster_run_mode == RUN_MODE_STANDBY)) && \
(g_instance.attr.attr_storage.xlog_file_path != 0))
/* DMS_BUF_NEED_LOAD */
#define BUF_NEED_LOAD 0x1
/* DMS_BUF_IS_LOADED */

View File

@ -37,7 +37,7 @@ typedef struct SSBroadcastCancelTrx {
int SSXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
XLogRecPtr targetRecPtr, char *readBuf, TimeLineID *readTLI, char* xlog_path);
bool SSReadXlogInternal(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, char *buf);
bool SSReadXlogInternal(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, XLogRecPtr targetRecPtr, char *buf);
XLogReaderState *SSXLogReaderAllocate(XLogPageReadCB pagereadfunc, void *private_data, Size alignedSize);
void SSGetXlogPath();
void SSSaveReformerCtrl();

View File

@ -220,7 +220,7 @@ extern bool get_addr_from_socket(int sock, struct sockaddr *saddr);
extern int get_ip_port_from_addr(char* sock_ip, int* port, struct sockaddr saddr);
#endif
const char *GetSSServerMode();
const char *GetSSServerMode(ServerMode mode);
bool SSIsServerModeReadOnly();
bool IsFromLocalAddr(Port* port);
extern bool IsMatchSocketAddr(const struct sockaddr* sock_addr, int compare_port);

View File

@ -105,8 +105,25 @@ typedef struct st_datadir_t {
dw_subdatadir_t dwDir;
} datadir_t;
void initDataPathStruct(bool enable_dss);
typedef struct DssOptions
{
bool enable_dss;
int instance_id;
const char *vgname;
char *vglog;
char *vgdata;
char *socketpath;
int primaryInstId;
} DssOptions;
typedef struct SSInstanceConfig
{
/* DSS conntct parameters */
DssOptions dss;
} SSInstanceConfig;
extern datadir_t g_datadir;
void initDataPathStruct(bool enable_dss);
#endif