Merge pull request #3271 from taosdata/master
Merge from master into develop
This commit is contained in:
commit
5b42f5d586
|
@ -115,7 +115,7 @@ int tsdbDropTable(TSDB_REPO_T *pRepo, STableId tableId);
|
|||
int tsdbUpdateTableTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg);
|
||||
TSKEY tsdbGetTableLastKey(TSDB_REPO_T *repo, uint64_t uid);
|
||||
|
||||
uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_t eindex, int32_t *size);
|
||||
uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_t eindex, int64_t *size);
|
||||
|
||||
// the TSDB repository info
|
||||
typedef struct STsdbRepoInfo {
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef struct {
|
|||
if name is provided(name[0] is not zero), get the named file at the specified index. If not there, return
|
||||
zero. If it is there, set the size to file size, and return file magic number. Index shall not be updated.
|
||||
*/
|
||||
typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion);
|
||||
typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion);
|
||||
|
||||
// get the wal file from index or after
|
||||
// return value, -1: error, 1:more wal files, 0:last WAL. if name[0]==0, no WAL file
|
||||
|
|
|
@ -224,7 +224,7 @@ void sdbUpdateMnodeRoles() {
|
|||
mnodeUpdateMnodeEpSet();
|
||||
}
|
||||
|
||||
static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion) {
|
||||
static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion) {
|
||||
sdbUpdateMnodeRoles();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ typedef struct {
|
|||
uint32_t magic;
|
||||
uint32_t index;
|
||||
uint64_t fversion;
|
||||
int32_t size;
|
||||
int64_t size;
|
||||
} SFileInfo;
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -108,8 +108,7 @@ static void syncModuleInitFunc() {
|
|||
tstrncpy(tsNodeFqdn, tsLocalFqdn, sizeof(tsNodeFqdn));
|
||||
}
|
||||
|
||||
void *syncStart(const SSyncInfo *pInfo)
|
||||
{
|
||||
void *syncStart(const SSyncInfo *pInfo) {
|
||||
const SSyncCfg *pCfg = &pInfo->syncCfg;
|
||||
|
||||
SSyncNode *pNode = (SSyncNode *) calloc(sizeof(SSyncNode), 1);
|
||||
|
@ -189,8 +188,7 @@ void *syncStart(const SSyncInfo *pInfo)
|
|||
return pNode;
|
||||
}
|
||||
|
||||
void syncStop(void *param)
|
||||
{
|
||||
void syncStop(void *param) {
|
||||
SSyncNode * pNode = param;
|
||||
SSyncPeer *pPeer;
|
||||
|
||||
|
@ -215,8 +213,7 @@ void syncStop(void *param)
|
|||
syncDecNodeRef(pNode);
|
||||
}
|
||||
|
||||
int32_t syncReconfig(void *param, const SSyncCfg *pNewCfg)
|
||||
{
|
||||
int32_t syncReconfig(void *param, const SSyncCfg *pNewCfg) {
|
||||
SSyncNode * pNode = param;
|
||||
int i, j;
|
||||
|
||||
|
@ -283,8 +280,7 @@ int32_t syncReconfig(void *param, const SSyncCfg *pNewCfg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t syncForwardToPeer(void *param, void *data, void *mhandle, int qtype)
|
||||
{
|
||||
int32_t syncForwardToPeer(void *param, void *data, void *mhandle, int qtype) {
|
||||
SSyncNode * pNode = param;
|
||||
SSyncPeer * pPeer;
|
||||
SSyncHead *pSyncHead;
|
||||
|
@ -334,8 +330,7 @@ int32_t syncForwardToPeer(void *param, void *data, void *mhandle, int qtype)
|
|||
return code;
|
||||
}
|
||||
|
||||
void syncConfirmForward(void *param, uint64_t version, int32_t code)
|
||||
{
|
||||
void syncConfirmForward(void *param, uint64_t version, int32_t code) {
|
||||
SSyncNode *pNode = param;
|
||||
if (pNode == NULL) return;
|
||||
if (pNode->quorum <= 1) return;
|
||||
|
@ -387,8 +382,7 @@ void syncRecover(void *param) {
|
|||
pthread_mutex_unlock(&(pNode->mutex));
|
||||
}
|
||||
|
||||
int syncGetNodesRole(void *param, SNodesRole *pNodesRole)
|
||||
{
|
||||
int syncGetNodesRole(void *param, SNodesRole *pNodesRole) {
|
||||
SSyncNode *pNode = param;
|
||||
|
||||
pNodesRole->selfIndex = pNode->selfIndex;
|
||||
|
@ -400,8 +394,7 @@ int syncGetNodesRole(void *param, SNodesRole *pNodesRole)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void syncAddArbitrator(SSyncNode *pNode)
|
||||
{
|
||||
static void syncAddArbitrator(SSyncNode *pNode) {
|
||||
SSyncPeer *pPeer = pNode->peerInfo[TAOS_SYNC_MAX_REPLICA];
|
||||
|
||||
// if not configured, return right away
|
||||
|
@ -456,13 +449,11 @@ static void syncDecNodeRef(SSyncNode *pNode)
|
|||
}
|
||||
}
|
||||
|
||||
void syncAddPeerRef(SSyncPeer *pPeer)
|
||||
{
|
||||
void syncAddPeerRef(SSyncPeer *pPeer) {
|
||||
atomic_add_fetch_8(&pPeer->refCount, 1);
|
||||
}
|
||||
|
||||
int syncDecPeerRef(SSyncPeer *pPeer)
|
||||
{
|
||||
int syncDecPeerRef(SSyncPeer *pPeer) {
|
||||
if (atomic_sub_fetch_8(&pPeer->refCount, 1) == 0) {
|
||||
syncDecNodeRef(pPeer->pSyncNode);
|
||||
|
||||
|
@ -475,8 +466,7 @@ int syncDecPeerRef(SSyncPeer *pPeer)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void syncClosePeerConn(SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncClosePeerConn(SSyncPeer *pPeer) {
|
||||
taosTmrStopA(&pPeer->timer);
|
||||
taosClose(pPeer->syncFd);
|
||||
if (pPeer->peerFd >= 0) {
|
||||
|
@ -485,8 +475,7 @@ static void syncClosePeerConn(SSyncPeer *pPeer)
|
|||
}
|
||||
}
|
||||
|
||||
static void syncRemovePeer(SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncRemovePeer(SSyncPeer *pPeer) {
|
||||
sInfo("%s, it is removed", pPeer->id);
|
||||
|
||||
pPeer->ip = 0;
|
||||
|
@ -494,8 +483,7 @@ static void syncRemovePeer(SSyncPeer *pPeer)
|
|||
syncDecPeerRef(pPeer);
|
||||
}
|
||||
|
||||
static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo)
|
||||
{
|
||||
static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo) {
|
||||
uint32_t ip = taosGetIpFromFqdn(pInfo->nodeFqdn);
|
||||
if (ip == -1) return NULL;
|
||||
|
||||
|
@ -525,8 +513,7 @@ static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo)
|
|||
return pPeer;
|
||||
}
|
||||
|
||||
void syncBroadcastStatus(SSyncNode *pNode)
|
||||
{
|
||||
void syncBroadcastStatus(SSyncNode *pNode) {
|
||||
SSyncPeer *pPeer;
|
||||
|
||||
for (int i = 0; i < pNode->replica; ++i) {
|
||||
|
@ -537,14 +524,14 @@ void syncBroadcastStatus(SSyncNode *pNode)
|
|||
}
|
||||
|
||||
static void syncResetFlowCtrl(SSyncNode *pNode) {
|
||||
|
||||
for (int i = 0; i < pNode->replica; ++i) {
|
||||
pNode->peerInfo[i]->numOfRetrieves = 0;
|
||||
}
|
||||
|
||||
if (pNode->notifyFlowCtrl)
|
||||
if (pNode->notifyFlowCtrl) {
|
||||
(*pNode->notifyFlowCtrl)(pNode->ahandle, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void syncChooseMaster(SSyncNode *pNode) {
|
||||
SSyncPeer *pPeer;
|
||||
|
@ -665,8 +652,7 @@ static int syncValidateMaster(SSyncPeer *pPeer) {
|
|||
return code;
|
||||
}
|
||||
|
||||
static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus peersStatus[], int8_t newRole)
|
||||
{
|
||||
static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus peersStatus[], int8_t newRole) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
int8_t peerOldRole = pPeer->role;
|
||||
int8_t selfOldRole = nodeRole;
|
||||
|
@ -740,16 +726,14 @@ static void syncRestartPeer(SSyncPeer *pPeer) {
|
|||
taosTmrReset(syncCheckPeerConnection, tsSyncTimer * 1000, pPeer, syncTmrCtrl, &pPeer->timer);
|
||||
}
|
||||
|
||||
void syncRestartConnection(SSyncPeer *pPeer)
|
||||
{
|
||||
void syncRestartConnection(SSyncPeer *pPeer) {
|
||||
if (pPeer->ip == 0) return;
|
||||
|
||||
syncRestartPeer(pPeer);
|
||||
syncCheckRole(pPeer, NULL, TAOS_SYNC_ROLE_OFFLINE);
|
||||
}
|
||||
|
||||
static void syncProcessSyncRequest(char *msg, SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncProcessSyncRequest(char *msg, SSyncPeer *pPeer) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
sDebug("%s, sync-req is received", pPeer->id);
|
||||
|
||||
|
@ -784,8 +768,7 @@ static void syncProcessSyncRequest(char *msg, SSyncPeer *pPeer)
|
|||
}
|
||||
}
|
||||
|
||||
static void syncNotStarted(void *param, void *tmrId)
|
||||
{
|
||||
static void syncNotStarted(void *param, void *tmrId) {
|
||||
SSyncPeer *pPeer = param;
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
|
||||
|
@ -805,8 +788,7 @@ static void syncTryRecoverFromMaster(void *param, void *tmrId) {
|
|||
pthread_mutex_unlock(&(pNode->mutex));
|
||||
}
|
||||
|
||||
static void syncRecoverFromMaster(SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncRecoverFromMaster(SSyncPeer *pPeer) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
|
||||
if (nodeSStatus != TAOS_SYNC_STATUS_INIT) {
|
||||
|
@ -842,8 +824,7 @@ static void syncRecoverFromMaster(SSyncPeer *pPeer)
|
|||
return;
|
||||
}
|
||||
|
||||
static void syncProcessFwdResponse(char *cont, SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncProcessFwdResponse(char *cont, SSyncPeer *pPeer) {
|
||||
SSyncNode * pNode = pPeer->pSyncNode;
|
||||
SFwdRsp *pFwdRsp = (SFwdRsp *) cont;
|
||||
SSyncFwds *pSyncFwds = pNode->pSyncFwds;
|
||||
|
@ -864,9 +845,7 @@ static void syncProcessFwdResponse(char *cont, SSyncPeer *pPeer)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static void syncProcessForwardFromPeer(char *cont, SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncProcessForwardFromPeer(char *cont, SSyncPeer *pPeer) {
|
||||
SSyncNode * pNode = pPeer->pSyncNode;
|
||||
SWalHead *pHead = (SWalHead *)cont;
|
||||
|
||||
|
@ -886,8 +865,7 @@ static void syncProcessForwardFromPeer(char *cont, SSyncPeer *pPeer)
|
|||
return;
|
||||
}
|
||||
|
||||
static void syncProcessPeersStatusMsg(char *cont, SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncProcessPeersStatusMsg(char *cont, SSyncPeer *pPeer) {
|
||||
SSyncNode * pNode = pPeer->pSyncNode;
|
||||
SPeersStatus *pPeersStatus = (SPeersStatus *)cont;
|
||||
|
||||
|
@ -925,8 +903,7 @@ static int syncReadPeerMsg(SSyncPeer *pPeer, SSyncHead *pHead, char *cont) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int syncProcessPeerMsg(void *param, void *buffer)
|
||||
{
|
||||
static int syncProcessPeerMsg(void *param, void *buffer) {
|
||||
SSyncPeer * pPeer = param;
|
||||
SSyncHead head;
|
||||
char *cont = (char *)buffer;
|
||||
|
@ -955,8 +932,7 @@ static int syncProcessPeerMsg(void *param, void *buffer)
|
|||
|
||||
#define statusMsgLen sizeof(SSyncHead)+sizeof(SPeersStatus)+sizeof(SPeerStatus)*TAOS_SYNC_MAX_REPLICA
|
||||
|
||||
static void syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack)
|
||||
{
|
||||
static void syncSendPeersStatusMsgToPeer(SSyncPeer *pPeer, char ack) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
char msg[statusMsgLen] = {0};
|
||||
|
||||
|
@ -1026,8 +1002,7 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) {
|
|||
}
|
||||
}
|
||||
|
||||
static void syncCheckPeerConnection(void *param, void *tmrId)
|
||||
{
|
||||
static void syncCheckPeerConnection(void *param, void *tmrId) {
|
||||
SSyncPeer *pPeer = param;
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
|
||||
|
@ -1039,8 +1014,7 @@ static void syncCheckPeerConnection(void *param, void *tmrId)
|
|||
pthread_mutex_unlock(&(pNode->mutex));
|
||||
}
|
||||
|
||||
static void syncCreateRestoreDataThread(SSyncPeer *pPeer)
|
||||
{
|
||||
static void syncCreateRestoreDataThread(SSyncPeer *pPeer) {
|
||||
taosTmrStopA(&pPeer->timer);
|
||||
|
||||
pthread_attr_t thattr;
|
||||
|
@ -1061,8 +1035,7 @@ static void syncCreateRestoreDataThread(SSyncPeer *pPeer)
|
|||
}
|
||||
}
|
||||
|
||||
static void syncProcessIncommingConnection(int connFd, uint32_t sourceIp)
|
||||
{
|
||||
static void syncProcessIncommingConnection(int connFd, uint32_t sourceIp) {
|
||||
char ipstr[24];
|
||||
int i;
|
||||
|
||||
|
@ -1139,8 +1112,7 @@ static void syncProcessBrokenLink(void *param) {
|
|||
syncDecNodeRef(pNode);
|
||||
}
|
||||
|
||||
static void syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle)
|
||||
{
|
||||
static void syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle) {
|
||||
SSyncFwds *pSyncFwds = pNode->pSyncFwds;
|
||||
uint64_t time = taosGetTimestampMs();
|
||||
|
||||
|
@ -1162,8 +1134,7 @@ static void syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle)
|
|||
sDebug("vgId:%d, fwd info is saved, ver:%" PRIu64 " fwds:%d ", pNode->vgId, version, pSyncFwds->fwds);
|
||||
}
|
||||
|
||||
static void syncRemoveConfirmedFwdInfo(SSyncNode *pNode)
|
||||
{
|
||||
static void syncRemoveConfirmedFwdInfo(SSyncNode *pNode) {
|
||||
SSyncFwds *pSyncFwds = pNode->pSyncFwds;
|
||||
|
||||
int fwds = pSyncFwds->fwds;
|
||||
|
@ -1180,8 +1151,7 @@ static void syncRemoveConfirmedFwdInfo(SSyncNode *pNode)
|
|||
}
|
||||
}
|
||||
|
||||
static void syncProcessFwdAck(SSyncNode *pNode, SFwdInfo *pFwdInfo, int32_t code)
|
||||
{
|
||||
static void syncProcessFwdAck(SSyncNode *pNode, SFwdInfo *pFwdInfo, int32_t code) {
|
||||
int confirm = 0;
|
||||
if (pFwdInfo->code == 0) pFwdInfo->code = code;
|
||||
|
||||
|
@ -1202,8 +1172,7 @@ static void syncProcessFwdAck(SSyncNode *pNode, SFwdInfo *pFwdInfo, int32_t code
|
|||
}
|
||||
}
|
||||
|
||||
static void syncMonitorFwdInfos(void *param, void *tmrId)
|
||||
{
|
||||
static void syncMonitorFwdInfos(void *param, void *tmrId) {
|
||||
SSyncNode *pNode = param;
|
||||
SSyncFwds *pSyncFwds = pNode->pSyncFwds;
|
||||
uint64_t time = taosGetTimestampMs();
|
||||
|
@ -1222,6 +1191,3 @@ static void syncMonitorFwdInfos(void *param, void *tmrId)
|
|||
|
||||
pNode->pFwdTimer = taosTmrStart(syncMonitorFwdInfos, 300, pNode, syncTmrCtrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, uint32_t sindex, uint32_t eind
|
|||
char fname[TSDB_FILENAME_LEN*3] = {0};
|
||||
uint32_t magic;
|
||||
uint64_t fversion;
|
||||
int32_t size;
|
||||
int64_t size;
|
||||
uint32_t index = sindex;
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
|
||||
|
@ -48,8 +48,7 @@ static void syncRemoveExtraFile(SSyncPeer *pPeer, uint32_t sindex, uint32_t eind
|
|||
}
|
||||
}
|
||||
|
||||
static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion)
|
||||
{
|
||||
static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
SFileInfo minfo; memset(&minfo, 0, sizeof(minfo)); /* = {0}; */ // master file info
|
||||
SFileInfo sinfo; memset(&sinfo, 0, sizeof(sinfo)); /* = {0}; */ // slave file info
|
||||
|
@ -113,7 +112,7 @@ static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion)
|
|||
close(dfd);
|
||||
if (ret<0) break;
|
||||
|
||||
sDebug("%s, %s is received, size:%d", pPeer->id, minfo.name, minfo.size);
|
||||
sDebug("%s, %s is received, size:%" PRId64, pPeer->id, minfo.name, minfo.size);
|
||||
|
||||
}
|
||||
|
||||
|
@ -130,8 +129,7 @@ static int syncRestoreFile(SSyncPeer *pPeer, uint64_t *fversion)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int syncRestoreWal(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncRestoreWal(SSyncPeer *pPeer) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
int ret, code = -1;
|
||||
|
||||
|
@ -172,8 +170,7 @@ static char *syncProcessOneBufferedFwd(SSyncPeer *pPeer, char *offset)
|
|||
return offset;
|
||||
}
|
||||
|
||||
static int syncProcessBufferedFwd(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncProcessBufferedFwd(SSyncPeer *pPeer) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
SRecvBuffer *pRecv = pNode->pRecv;
|
||||
int forwards = 0;
|
||||
|
@ -201,8 +198,7 @@ static int syncProcessBufferedFwd(SSyncPeer *pPeer)
|
|||
return pRecv->code;
|
||||
}
|
||||
|
||||
int syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead)
|
||||
{
|
||||
int syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
SRecvBuffer *pRecv = pNode->pRecv;
|
||||
|
||||
|
@ -222,8 +218,7 @@ int syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead)
|
|||
return pRecv->code;
|
||||
}
|
||||
|
||||
static void syncCloseRecvBuffer(SSyncNode *pNode)
|
||||
{
|
||||
static void syncCloseRecvBuffer(SSyncNode *pNode) {
|
||||
if (pNode->pRecv) {
|
||||
taosTFree(pNode->pRecv->buffer);
|
||||
}
|
||||
|
@ -231,8 +226,7 @@ static void syncCloseRecvBuffer(SSyncNode *pNode)
|
|||
taosTFree(pNode->pRecv);
|
||||
}
|
||||
|
||||
static int syncOpenRecvBuffer(SSyncNode *pNode)
|
||||
{
|
||||
static int syncOpenRecvBuffer(SSyncNode *pNode) {
|
||||
syncCloseRecvBuffer(pNode);
|
||||
|
||||
SRecvBuffer *pRecv = calloc(sizeof(SRecvBuffer), 1);
|
||||
|
@ -253,8 +247,7 @@ static int syncOpenRecvBuffer(SSyncNode *pNode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int syncRestoreDataStepByStep(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncRestoreDataStepByStep(SSyncPeer *pPeer) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
nodeSStatus = TAOS_SYNC_STATUS_FILE;
|
||||
uint64_t fversion = 0;
|
||||
|
@ -292,8 +285,7 @@ static int syncRestoreDataStepByStep(SSyncPeer *pPeer)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void *syncRestoreData(void *param)
|
||||
{
|
||||
void *syncRestoreData(void *param) {
|
||||
SSyncPeer *pPeer = (SSyncPeer *)param;
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
|
||||
|
@ -326,4 +318,3 @@ void *syncRestoreData(void *param)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#include "tsync.h"
|
||||
#include "syncInt.h"
|
||||
|
||||
static int syncAddIntoWatchList(SSyncPeer *pPeer, char *name)
|
||||
{
|
||||
static int syncAddIntoWatchList(SSyncPeer *pPeer, char *name) {
|
||||
sDebug("%s, start to monitor:%s", pPeer->id, name);
|
||||
|
||||
if (pPeer->notifyFd <= 0) {
|
||||
|
@ -70,8 +69,7 @@ static int syncAddIntoWatchList(SSyncPeer *pPeer, char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int syncAreFilesModified(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncAreFilesModified(SSyncPeer *pPeer) {
|
||||
if (pPeer->notifyFd <= 0) return 0;
|
||||
|
||||
char buf[2048];
|
||||
|
@ -99,8 +97,7 @@ static int syncAreFilesModified(SSyncPeer *pPeer)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int syncRetrieveFile(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncRetrieveFile(SSyncPeer *pPeer) {
|
||||
SSyncNode * pNode = pPeer->pSyncNode;
|
||||
SFileInfo fileInfo;
|
||||
SFileAck fileAck;
|
||||
|
@ -154,7 +151,7 @@ static int syncRetrieveFile(SSyncPeer *pPeer)
|
|||
close(sfd);
|
||||
if (ret < 0) break;
|
||||
|
||||
sDebug("%s, %s is sent, size:%d", pPeer->id, name, fileInfo.size);
|
||||
sDebug("%s, %s is sent, size:%" PRId64, pPeer->id, name, fileInfo.size);
|
||||
fileInfo.index++;
|
||||
|
||||
// check if processed files are modified
|
||||
|
@ -170,8 +167,7 @@ static int syncRetrieveFile(SSyncPeer *pPeer)
|
|||
|
||||
/* if only a partial record is read out, set the IN_MODIFY flag in event,
|
||||
so upper layer will reload the file to get a complete record */
|
||||
static int syncReadOneWalRecord(int sfd, SWalHead *pHead, uint32_t *pEvent)
|
||||
{
|
||||
static int syncReadOneWalRecord(int sfd, SWalHead *pHead, uint32_t *pEvent) {
|
||||
int ret;
|
||||
|
||||
ret = read(sfd, pHead, sizeof(SWalHead));
|
||||
|
@ -196,8 +192,7 @@ static int syncReadOneWalRecord(int sfd, SWalHead *pHead, uint32_t *pEvent)
|
|||
return sizeof(SWalHead) + pHead->len;
|
||||
}
|
||||
|
||||
static int syncMonitorLastWal(SSyncPeer *pPeer, char *name)
|
||||
{
|
||||
static int syncMonitorLastWal(SSyncPeer *pPeer, char *name) {
|
||||
pPeer->watchNum = 0;
|
||||
taosClose(pPeer->notifyFd);
|
||||
pPeer->notifyFd = inotify_init1(IN_NONBLOCK);
|
||||
|
@ -224,8 +219,7 @@ static int syncMonitorLastWal(SSyncPeer *pPeer, char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t syncCheckLastWalChanges(SSyncPeer *pPeer, uint32_t *pEvent)
|
||||
{
|
||||
static uint32_t syncCheckLastWalChanges(SSyncPeer *pPeer, uint32_t *pEvent) {
|
||||
char buf[2048];
|
||||
int len = read(pPeer->notifyFd, buf, sizeof(buf));
|
||||
if (len < 0 && errno != EAGAIN) {
|
||||
|
@ -248,8 +242,7 @@ static uint32_t syncCheckLastWalChanges(SSyncPeer *pPeer, uint32_t *pEvent)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversion, int64_t offset, uint32_t *pEvent)
|
||||
{
|
||||
static int syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversion, int64_t offset, uint32_t *pEvent) {
|
||||
SWalHead *pHead = (SWalHead *) malloc(640000);
|
||||
int code = -1;
|
||||
int32_t bytes = 0;
|
||||
|
@ -263,7 +256,10 @@ static int syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversion,
|
|||
while (1) {
|
||||
int wsize = syncReadOneWalRecord(sfd, pHead, pEvent);
|
||||
if (wsize < 0) break;
|
||||
if (wsize == 0) { code = 0; break; }
|
||||
if (wsize == 0) {
|
||||
code = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
sDebug("%s, last wal is forwarded, ver:%" PRIu64, pPeer->id, pHead->version);
|
||||
int ret = taosWriteMsg(pPeer->syncFd, pHead, wsize);
|
||||
|
@ -286,8 +282,7 @@ static int syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversion,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index)
|
||||
{
|
||||
static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
int code = -1;
|
||||
char fname[TSDB_FILENAME_LEN * 2]; // full path to wal file
|
||||
|
@ -352,10 +347,14 @@ static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index)
|
|||
if (code < 0) break;
|
||||
if (pPeer->sversion >= fversion && fversion > 0) break;
|
||||
|
||||
index++; wname[0] = 0;
|
||||
index++;
|
||||
wname[0] = 0;
|
||||
code = (*pNode->getWalInfo)(pNode->ahandle, wname, &index);
|
||||
if (code < 0) break;
|
||||
if ( wname[0] == 0 ) {code = 0; break;}
|
||||
if (wname[0] == 0) {
|
||||
code = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// current last wal is closed, there is a new one
|
||||
sDebug("%s, last wal is closed, try new one", pPeer->id);
|
||||
|
@ -366,8 +365,7 @@ static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int syncRetrieveWal(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncRetrieveWal(SSyncPeer *pPeer) {
|
||||
SSyncNode * pNode = pPeer->pSyncNode;
|
||||
char fname[TSDB_FILENAME_LEN * 3];
|
||||
char wname[TSDB_FILENAME_LEN * 2];
|
||||
|
@ -425,8 +423,7 @@ static int syncRetrieveWal(SSyncPeer *pPeer)
|
|||
return code;
|
||||
}
|
||||
|
||||
static int syncRetrieveDataStepByStep(SSyncPeer *pPeer)
|
||||
{
|
||||
static int syncRetrieveDataStepByStep(SSyncPeer *pPeer) {
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
|
||||
SFirstPkt firstPkt;
|
||||
|
@ -462,8 +459,7 @@ static int syncRetrieveDataStepByStep(SSyncPeer *pPeer)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void *syncRetrieveData(void *param)
|
||||
{
|
||||
void *syncRetrieveData(void *param) {
|
||||
SSyncPeer * pPeer = (SSyncPeer *)param;
|
||||
SSyncNode *pNode = pPeer->pSyncNode;
|
||||
taosBlockSIGPIPE();
|
||||
|
|
|
@ -48,8 +48,7 @@ static void *taosProcessTcpData(void *param);
|
|||
static SThreadObj *taosGetTcpThread(SPoolObj *pPool);
|
||||
static void taosStopPoolThread(SThreadObj* pThread);
|
||||
|
||||
void *taosOpenTcpThreadPool(SPoolInfo *pInfo)
|
||||
{
|
||||
void *taosOpenTcpThreadPool(SPoolInfo *pInfo) {
|
||||
pthread_attr_t thattr;
|
||||
|
||||
SPoolObj *pPool = calloc(sizeof(SPoolObj), 1);
|
||||
|
@ -89,8 +88,7 @@ void *taosOpenTcpThreadPool(SPoolInfo *pInfo)
|
|||
return pPool;
|
||||
}
|
||||
|
||||
void taosCloseTcpThreadPool(void *param)
|
||||
{
|
||||
void taosCloseTcpThreadPool(void *param) {
|
||||
SPoolObj *pPool = (SPoolObj *)param;
|
||||
SThreadObj *pThread;
|
||||
|
||||
|
@ -107,8 +105,7 @@ void taosCloseTcpThreadPool(void *param)
|
|||
uDebug("%p TCP pool is closed", pPool);
|
||||
}
|
||||
|
||||
void *taosAllocateTcpConn(void *param, void *pPeer, int connFd)
|
||||
{
|
||||
void *taosAllocateTcpConn(void *param, void *pPeer, int connFd) {
|
||||
struct epoll_event event;
|
||||
SPoolObj *pPool = (SPoolObj *)param;
|
||||
|
||||
|
@ -145,8 +142,7 @@ void *taosAllocateTcpConn(void *param, void *pPeer, int connFd)
|
|||
return pConn;
|
||||
}
|
||||
|
||||
void taosFreeTcpConn(void *param)
|
||||
{
|
||||
void taosFreeTcpConn(void *param) {
|
||||
SConnObj * pConn = (SConnObj *)param;
|
||||
SThreadObj *pThread = pConn->pThread;
|
||||
|
||||
|
|
|
@ -150,8 +150,7 @@ static void arbProcessBrokenLink(void *param) {
|
|||
taosTFree(pNode);
|
||||
}
|
||||
|
||||
static int arbProcessPeerMsg(void *param, void *buffer)
|
||||
{
|
||||
static int arbProcessPeerMsg(void *param, void *buffer) {
|
||||
SNodeConn * pNode = param;
|
||||
SSyncHead head;
|
||||
int bytes = 0;
|
||||
|
@ -174,7 +173,6 @@ static int arbProcessPeerMsg(void *param, void *buffer)
|
|||
}
|
||||
|
||||
static void arbSignalHandler(int32_t signum, siginfo_t *sigInfo, void *context) {
|
||||
|
||||
struct sigaction act = {{0}};
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTERM, &act, NULL);
|
||||
|
@ -186,4 +184,3 @@ static void arbSignalHandler(int32_t signum, siginfo_t *sigInfo, void *context)
|
|||
// inform main thread to exit
|
||||
tsem_post(&tsArbSem);
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ void processRequestMsg(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
|||
taosWriteQitem(qhandle, TAOS_QTYPE_RPC, pTemp);
|
||||
}
|
||||
|
||||
uint32_t getFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion)
|
||||
uint32_t getFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion)
|
||||
{
|
||||
uint32_t magic;
|
||||
struct stat fstat;
|
||||
|
|
|
@ -475,7 +475,7 @@ int tsdbUpdateFileHeader(SFile* pFile);
|
|||
int tsdbEncodeSFileInfo(void** buf, const STsdbFileInfo* pInfo);
|
||||
void* tsdbDecodeSFileInfo(void* buf, STsdbFileInfo* pInfo);
|
||||
void tsdbRemoveFileGroup(STsdbRepo* pRepo, SFileGroup* pFGroup);
|
||||
void tsdbGetFileInfoImpl(char* fname, uint32_t* magic, int32_t* size);
|
||||
void tsdbGetFileInfoImpl(char* fname, uint32_t* magic, int64_t* size);
|
||||
void tsdbGetFidKeyRange(int daysPerFile, int8_t precision, int fileId, TSKEY *minKey, TSKEY *maxKey);
|
||||
|
||||
// ------------------ tsdbRWHelper.c
|
||||
|
|
|
@ -424,7 +424,7 @@ void tsdbRemoveFileGroup(STsdbRepo *pRepo, SFileGroup *pFGroup) {
|
|||
}
|
||||
}
|
||||
|
||||
void tsdbGetFileInfoImpl(char *fname, uint32_t *magic, int32_t *size) {
|
||||
void tsdbGetFileInfoImpl(char *fname, uint32_t *magic, int64_t *size) {
|
||||
char buf[TSDB_FILE_HEAD_SIZE] = "\0";
|
||||
uint32_t version = 0;
|
||||
STsdbFileInfo info = {0};
|
||||
|
@ -445,7 +445,7 @@ void tsdbGetFileInfoImpl(char *fname, uint32_t *magic, int32_t *size) {
|
|||
close(fd);
|
||||
|
||||
*magic = info.magic;
|
||||
*size = (int32_t)offset;
|
||||
*size = offset;
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ int32_t tsdbInsertData(TSDB_REPO_T *repo, SSubmitMsg *pMsg, SShellSubmitRspMsg *
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_t eindex, int32_t *size) {
|
||||
uint32_t tsdbGetFileInfo(TSDB_REPO_T *repo, char *name, uint32_t *index, uint32_t eindex, int64_t *size) {
|
||||
STsdbRepo *pRepo = (STsdbRepo *)repo;
|
||||
// STsdbMeta *pMeta = pRepo->tsdbMeta;
|
||||
STsdbFileH *pFileH = pRepo->tsdbFileH;
|
||||
|
|
|
@ -58,7 +58,7 @@ int tdKVStoreStartCommit(SKVStore *pStore);
|
|||
int tdUpdateKVStoreRecord(SKVStore *pStore, uint64_t uid, void *cont, int contLen);
|
||||
int tdDropKVStoreRecord(SKVStore *pStore, uint64_t uid);
|
||||
int tdKVStoreEndCommit(SKVStore *pStore);
|
||||
void tsdbGetStoreInfo(char *fname, uint32_t *magic, int32_t *size);
|
||||
void tsdbGetStoreInfo(char *fname, uint32_t *magic, int64_t *size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ int tdKVStoreEndCommit(SKVStore *pStore) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tsdbGetStoreInfo(char *fname, uint32_t *magic, int32_t *size) {
|
||||
void tsdbGetStoreInfo(char *fname, uint32_t *magic, int64_t *size) {
|
||||
char buf[TD_KVSTORE_HEADER_SIZE] = "\0";
|
||||
SStoreInfo info = {0};
|
||||
|
||||
|
@ -349,7 +349,7 @@ void tsdbGetStoreInfo(char *fname, uint32_t *magic, int32_t *size) {
|
|||
close(fd);
|
||||
|
||||
*magic = info.magic;
|
||||
*size = (int32_t)offset;
|
||||
*size = offset;
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode);
|
|||
static int32_t vnodeSaveVersion(SVnodeObj *pVnode);
|
||||
static int32_t vnodeReadVersion(SVnodeObj *pVnode);
|
||||
static int vnodeProcessTsdbStatus(void *arg, int status);
|
||||
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion);
|
||||
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion);
|
||||
static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index);
|
||||
static void vnodeNotifyRole(void *ahandle, int8_t role);
|
||||
static void vnodeCtrlFlow(void *handle, int32_t mseconds);
|
||||
|
@ -290,6 +290,8 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
|
|||
pVnode->sync = syncStart(&syncInfo);
|
||||
|
||||
if (pVnode->sync == NULL) {
|
||||
vError("vgId:%d, failed to open sync module, replica:%d reason:%s", pVnode->vgId, pVnode->syncCfg.replica,
|
||||
tstrerror(terrno));
|
||||
vnodeCleanUp(pVnode);
|
||||
return terrno;
|
||||
}
|
||||
|
@ -536,7 +538,7 @@ static int vnodeProcessTsdbStatus(void *arg, int status) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion) {
|
||||
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int64_t *size, uint64_t *fversion) {
|
||||
SVnodeObj *pVnode = ahandle;
|
||||
*fversion = pVnode->fversion;
|
||||
return tsdbGetFileInfo(pVnode->tsdb, name, index, eindex, size);
|
||||
|
|
|
@ -32,10 +32,16 @@ system sh/cfg.sh -n dnode2 -c http -v 1
|
|||
system sh/cfg.sh -n dnode3 -c http -v 1
|
||||
system sh/cfg.sh -n dnode4 -c http -v 1
|
||||
|
||||
|
||||
# for crash_gen
|
||||
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2
|
||||
system sh/cfg.sh -n dnode1 -c rpcMaxTime -v 101
|
||||
system sh/cfg.sh -n dnode1 -c cache -v 2
|
||||
system sh/cfg.sh -n dnode1 -c keep -v 36500
|
||||
system sh/cfg.sh -n dnode1 -c walLevel -v 2
|
||||
|
||||
|
||||
# for windows
|
||||
|
||||
system sh/cfg.sh -n dnode1 -c firstEp -v 152.136.17.116:6030
|
||||
system sh/cfg.sh -n dnode1 -c secondEp -v 152.136.17.116:6030
|
||||
system sh/cfg.sh -n dnode1 -c serverPort -v 6030
|
||||
|
|
Loading…
Reference in New Issue