未验证 提交 5e060605 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #5147 from taosdata/feature/linux

Feature/linux
......@@ -64,7 +64,7 @@ typedef struct {
#define tfsclose(fd) close(fd)
#define tfsremove(pf) remove(TFILE_NAME(pf))
#define tfscopy(sf, df) taosCopy(TFILE_NAME(sf), TFILE_NAME(df))
#define tfsrename(sf, df) rename(TFILE_NAME(sf), TFILE_NAME(df))
#define tfsrename(sf, df) taosRename(TFILE_NAME(sf), TFILE_NAME(df))
void tfsInitFile(TFILE *pf, int level, int id, const char *bname);
bool tfsIsSameFile(const TFILE *pf1, const TFILE *pf2);
......
......@@ -25,8 +25,8 @@ extern "C" {
// TAOS_OS_FUNC_DIR
void taosRemoveDir(char *rootDir);
int taosMkDir(const char *pathname, mode_t mode);
void taosRename(char* oldName, char *newName);
void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays);
int32_t taosRename(char* oldName, char *newName);
int32_t taosCompressFile(char *srcFileName, char *destFileName);
#ifdef __cplusplus
......
......@@ -69,6 +69,8 @@ extern "C" {
#define TAOS_OS_FUNC_FILE_GETTMPFILEPATH
#define TAOS_OS_FUNC_FILE_FTRUNCATE
#define TAOS_OS_FUNC_DIR
#define TAOS_OS_FUNC_MATH
#define SWAP(a, b, c) \
do { \
......
......@@ -51,19 +51,22 @@ int taosMkDir(const char *path, mode_t mode) {
return code;
}
void taosRename(char* oldName, char *newName) {
// if newName in not empty, rename return fail.
// the newName must be empty or does not exist
#ifdef WINDOWS
remove(newName);
#endif
if (rename(oldName, newName)) {
#ifndef TAOS_OS_FUNC_DIR
int32_t taosRename(char* oldName, char *newName) {
int32_t code = rename(oldName, newName);
if (code < 0) {
uError("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
} else {
uInfo("successfully to rename file %s to %s", oldName, newName);
uTrace("successfully to rename file %s to %s", oldName, newName);
}
return code;
}
#endif
void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) {
DIR *dir = opendir(rootDir);
if (dir == NULL) return;
......
......@@ -160,7 +160,6 @@ int32_t taosFtruncate(int32_t fd, int64_t l_size) {
return 0;
}
int fsync(int filedes) {
if (filedes < 0) {
errno = EBADF;
......@@ -172,3 +171,14 @@ int fsync(int filedes) {
return FlushFileBuffers(h);
}
int32_t taosRename(char* oldName, char *newName) {
int32_t code = MoveFileEx(oldName, newName, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
if (code < 0) {
uError("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
} else {
uTrace("successfully to rename file %s to %s", oldName, newName);
}
return code;
}
\ No newline at end of file
......@@ -741,11 +741,14 @@ static SSyncPeer *syncCheckMaster(SSyncNode *pNode) {
if (pTemp->role != TAOS_SYNC_ROLE_MASTER) continue;
if (masterIndex < 0) {
masterIndex = index;
sDebug("vgId:%d, peer:%s is master, index:%d", pNode->vgId, pTemp->id, index);
} else { // multiple masters, it shall not happen
if (masterIndex == pNode->selfIndex) {
sError("%s, peer is master, work as slave instead", pTemp->id);
nodeRole = TAOS_SYNC_ROLE_SLAVE;
(*pNode->notifyRoleFp)(pNode->vgId, nodeRole);
} else {
sError("vgId:%d, peer:%s is master too, masterIndex:%d index:%d", pNode->vgId, pTemp->id, masterIndex, index);
}
}
}
......@@ -833,7 +836,7 @@ static void syncCheckRole(SSyncPeer *pPeer, SPeerStatus* peersStatus, int8_t new
}
if (oldPeerRole != newPeerRole || nodeRole != oldSelfRole) {
sDebug("vgId:%d, roles changed, broadcast status", pNode->vgId);
sDebug("vgId:%d, roles changed, broadcast status, replica:%d", pNode->vgId, pNode->replica);
syncBroadcastStatus(pNode);
}
......@@ -860,8 +863,12 @@ static void syncRestartPeer(SSyncPeer *pPeer) {
void syncRestartConnection(SSyncPeer *pPeer) {
if (pPeer->ip == 0) return;
if (syncAcquirePeer(pPeer->rid) == NULL) return;
syncRestartPeer(pPeer);
syncCheckRole(pPeer, NULL, TAOS_SYNC_ROLE_OFFLINE);
syncReleasePeer(pPeer);
}
static void syncProcessSyncRequest(char *msg, SSyncPeer *pPeer) {
......
......@@ -131,6 +131,11 @@ static int32_t syncProcessBufferedFwd(SSyncPeer *pPeer) {
SRecvBuffer *pRecv = pNode->pRecv;
int32_t forwards = 0;
if (pRecv == NULL) {
sError("%s, recv buffer is null, restart connect", pPeer->id);
return -1;
}
sDebug("%s, number of buffered forwards:%d", pPeer->id, pRecv->forwards);
char *offset = pRecv->buffer;
......@@ -179,6 +184,7 @@ int32_t syncSaveIntoBuffer(SSyncPeer *pPeer, SWalHead *pHead) {
static void syncCloseRecvBuffer(SSyncNode *pNode) {
if (pNode->pRecv) {
sDebug("vgId:%d, recv buffer:%p is freed", pNode->vgId, pNode->pRecv);
tfree(pNode->pRecv->buffer);
}
......@@ -203,6 +209,7 @@ static int32_t syncOpenRecvBuffer(SSyncNode *pNode) {
pNode->pRecv = pRecv;
sDebug("vgId:%d, recv buffer:%p is created", pNode->vgId, pNode->pRecv);
return 0;
}
......
......@@ -395,7 +395,7 @@ static int tsdbSaveFSStatus(SFSStatus *pStatus, int vid) {
}
(void)close(fd);
(void)rename(tfname, cfname);
(void)taosRename(tfname, cfname);
taosTZfree(pBuf);
return 0;
......
......@@ -39,7 +39,7 @@ int32_t walRenew(void *handle) {
if (tfValid(pWal->tfd)) {
tfClose(pWal->tfd);
wDebug("vgId:%d, file:%s, it is closed", pWal->vgId, pWal->name);
wDebug("vgId:%d, file:%s, it is closed while renew", pWal->vgId, pWal->name);
}
if (pWal->keep == TAOS_WAL_KEEP) {
......@@ -56,7 +56,7 @@ int32_t walRenew(void *handle) {
code = TAOS_SYSTEM_ERROR(errno);
wError("vgId:%d, file:%s, failed to open since %s", pWal->vgId, pWal->name, strerror(errno));
} else {
wDebug("vgId:%d, file:%s, it is created", pWal->vgId, pWal->name);
wDebug("vgId:%d, file:%s, it is created and open while renew", pWal->vgId, pWal->name);
}
pthread_mutex_unlock(&pWal->mutex);
......@@ -95,11 +95,15 @@ void walRemoveAllOldFiles(void *handle) {
int64_t fileId = -1;
pthread_mutex_lock(&pWal->mutex);
tfClose(pWal->tfd);
wDebug("vgId:%d, file:%s, it is closed before remove all wals", pWal->vgId, pWal->name);
while (walGetNextFile(pWal, &fileId) >= 0) {
snprintf(pWal->name, sizeof(pWal->name), "%s/%s%" PRId64, pWal->path, WAL_PREFIX, fileId);
if (remove(pWal->name) < 0) {
wError("vgId:%d, wal:%p file:%s, failed to remove", pWal->vgId, pWal, pWal->name);
wError("vgId:%d, wal:%p file:%s, failed to remove since %s", pWal->vgId, pWal, pWal->name, strerror(errno));
} else {
wInfo("vgId:%d, wal:%p file:%s, it is removed", pWal->vgId, pWal, pWal->name);
}
......@@ -192,7 +196,7 @@ int32_t walRestore(void *handle, void *pVnode, FWalWrite writeFp) {
wError("vgId:%d, file:%s, failed to open since %s", pWal->vgId, pWal->name, strerror(errno));
return TAOS_SYSTEM_ERROR(errno);
}
wDebug("vgId:%d, file:%s open success", pWal->vgId, pWal->name);
wDebug("vgId:%d, file:%s, it is created and open while restore", pWal->vgId, pWal->name);
}
return TSDB_CODE_SUCCESS;
......@@ -265,6 +269,8 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
wError("vgId:%d, file:%s, failed to open for restore since %s", pWal->vgId, name, strerror(errno));
tfree(buffer);
return TAOS_SYSTEM_ERROR(errno);
} else {
wDebug("vgId:%d, file:%s, open for restore", pWal->vgId, name);
}
int32_t code = TSDB_CODE_SUCCESS;
......@@ -332,6 +338,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
tfClose(tfd);
tfree(buffer);
wDebug("vgId:%d, file:%s, it is closed after restore", pWal->vgId, name);
return code;
}
......
......@@ -110,7 +110,7 @@ system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
sleep 500c
sleep 5000
run general/parser/col_arithmetic_query.sim
......
......@@ -41,10 +41,10 @@ if $data00 != 0.000000000 then
return -1
endi
if $data01 != -nan then
print expect -nan, actual: $data01
return -1
endi
#if $data01 != -nan then
# print expect -nan, actual: $data01
# return -1
#endi
if $data10 != 0.666666667 then
return -1
......@@ -185,9 +185,9 @@ if $data00 != 0.000000000 then
return -1
endi
if $data01 != -nan then
return -1
endi
#if $data01 != -nan then
# return -1
#endi
if $data02 != 0.000000000 then
return -1
......
......@@ -65,24 +65,24 @@ echo serverPort %NODE% >> %TAOS_CFG%
echo dataDir %DATA_DIR% >> %TAOS_CFG%
echo logDir %LOG_DIR% >> %TAOS_CFG%
echo debugFlag 0 >> %TAOS_CFG%
echo mDebugFlag 143 >> %TAOS_CFG%
echo sdbDebugFlag 143 >> %TAOS_CFG%
echo dDebugFlag 143 >> %TAOS_CFG%
echo vDebugFlag 143 >> %TAOS_CFG%
echo tsdbDebugFlag 143 >> %TAOS_CFG%
echo cDebugFlag 143 >> %TAOS_CFG%
echo jnidebugFlag 143 >> %TAOS_CFG%
echo odbcdebugFlag 143 >> %TAOS_CFG%
echo httpDebugFlag 143 >> %TAOS_CFG%
echo monDebugFlag 143 >> %TAOS_CFG%
echo mqttDebugFlag 143 >> %TAOS_CFG%
echo qdebugFlag 143 >> %TAOS_CFG%
echo rpcDebugFlag 143 >> %TAOS_CFG%
echo mDebugFlag 135 >> %TAOS_CFG%
echo sdbDebugFlag 135 >> %TAOS_CFG%
echo dDebugFlag 135 >> %TAOS_CFG%
echo vDebugFlag 135 >> %TAOS_CFG%
echo tsdbDebugFlag 135 >> %TAOS_CFG%
echo cDebugFlag 135 >> %TAOS_CFG%
echo jnidebugFlag 135 >> %TAOS_CFG%
echo odbcdebugFlag 135 >> %TAOS_CFG%
echo httpDebugFlag 135 >> %TAOS_CFG%
echo monDebugFlag 135 >> %TAOS_CFG%
echo mqttDebugFlag 135 >> %TAOS_CFG%
echo qdebugFlag 135 >> %TAOS_CFG%
echo rpcDebugFlag 135 >> %TAOS_CFG%
echo tmrDebugFlag 131 >> %TAOS_CFG%
echo udebugFlag 143 >> %TAOS_CFG%
echo sdebugFlag 143 >> %TAOS_CFG%
echo wdebugFlag 143 >> %TAOS_CFG%
echo cqdebugFlag 143 >> %TAOS_CFG%
echo udebugFlag 135 >> %TAOS_CFG%
echo sdebugFlag 135 >> %TAOS_CFG%
echo wdebugFlag 135 >> %TAOS_CFG%
echo cqdebugFlag 135 >> %TAOS_CFG%
echo monitor 0 >> %TAOS_CFG%
echo monitorInterval 1 >> %TAOS_CFG%
echo http 0 >> %TAOS_CFG%
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册