提交 32b10a42 编写于 作者: S Shengliang Guan

TD-1207 rename in windows

上级 9db8f7c3
...@@ -64,7 +64,7 @@ typedef struct { ...@@ -64,7 +64,7 @@ typedef struct {
#define tfsclose(fd) close(fd) #define tfsclose(fd) close(fd)
#define tfsremove(pf) remove(TFILE_NAME(pf)) #define tfsremove(pf) remove(TFILE_NAME(pf))
#define tfscopy(sf, df) taosCopy(TFILE_NAME(sf), TFILE_NAME(df)) #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); void tfsInitFile(TFILE *pf, int level, int id, const char *bname);
bool tfsIsSameFile(const TFILE *pf1, const TFILE *pf2); bool tfsIsSameFile(const TFILE *pf1, const TFILE *pf2);
......
...@@ -25,8 +25,8 @@ extern "C" { ...@@ -25,8 +25,8 @@ extern "C" {
// TAOS_OS_FUNC_DIR // TAOS_OS_FUNC_DIR
void taosRemoveDir(char *rootDir); void taosRemoveDir(char *rootDir);
int taosMkDir(const char *pathname, mode_t mode); int taosMkDir(const char *pathname, mode_t mode);
void taosRename(char* oldName, char *newName);
void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays); void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays);
int32_t taosRename(char* oldName, char *newName);
int32_t taosCompressFile(char *srcFileName, char *destFileName); int32_t taosCompressFile(char *srcFileName, char *destFileName);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -69,6 +69,8 @@ extern "C" { ...@@ -69,6 +69,8 @@ extern "C" {
#define TAOS_OS_FUNC_FILE_GETTMPFILEPATH #define TAOS_OS_FUNC_FILE_GETTMPFILEPATH
#define TAOS_OS_FUNC_FILE_FTRUNCATE #define TAOS_OS_FUNC_FILE_FTRUNCATE
#define TAOS_OS_FUNC_DIR
#define TAOS_OS_FUNC_MATH #define TAOS_OS_FUNC_MATH
#define SWAP(a, b, c) \ #define SWAP(a, b, c) \
do { \ do { \
......
...@@ -51,19 +51,22 @@ int taosMkDir(const char *path, mode_t mode) { ...@@ -51,19 +51,22 @@ int taosMkDir(const char *path, mode_t mode) {
return code; return code;
} }
void taosRename(char* oldName, char *newName) {
// if newName in not empty, rename return fail. #ifndef TAOS_OS_FUNC_DIR
// the newName must be empty or does not exist
#ifdef WINDOWS int32_t taosRename(char* oldName, char *newName) {
remove(newName); int32_t code = rename(oldName, newName);
#endif if (code < 0) {
if (rename(oldName, newName)) {
uError("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno)); uError("failed to rename file %s to %s, reason:%s", oldName, newName, strerror(errno));
} else { } 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) { void taosRemoveOldLogFiles(char *rootDir, int32_t keepDays) {
DIR *dir = opendir(rootDir); DIR *dir = opendir(rootDir);
if (dir == NULL) return; if (dir == NULL) return;
......
...@@ -160,7 +160,6 @@ int32_t taosFtruncate(int32_t fd, int64_t l_size) { ...@@ -160,7 +160,6 @@ int32_t taosFtruncate(int32_t fd, int64_t l_size) {
return 0; return 0;
} }
int fsync(int filedes) { int fsync(int filedes) {
if (filedes < 0) { if (filedes < 0) {
errno = EBADF; errno = EBADF;
...@@ -172,3 +171,14 @@ int fsync(int filedes) { ...@@ -172,3 +171,14 @@ int fsync(int filedes) {
return FlushFileBuffers(h); 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
...@@ -395,7 +395,7 @@ static int tsdbSaveFSStatus(SFSStatus *pStatus, int vid) { ...@@ -395,7 +395,7 @@ static int tsdbSaveFSStatus(SFSStatus *pStatus, int vid) {
} }
(void)close(fd); (void)close(fd);
(void)rename(tfname, cfname); (void)taosRename(tfname, cfname);
taosTZfree(pBuf); taosTZfree(pBuf);
return 0; return 0;
......
...@@ -39,7 +39,7 @@ int32_t walRenew(void *handle) { ...@@ -39,7 +39,7 @@ int32_t walRenew(void *handle) {
if (tfValid(pWal->tfd)) { if (tfValid(pWal->tfd)) {
tfClose(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) { if (pWal->keep == TAOS_WAL_KEEP) {
...@@ -56,7 +56,7 @@ int32_t walRenew(void *handle) { ...@@ -56,7 +56,7 @@ int32_t walRenew(void *handle) {
code = TAOS_SYSTEM_ERROR(errno); code = TAOS_SYSTEM_ERROR(errno);
wError("vgId:%d, file:%s, failed to open since %s", pWal->vgId, pWal->name, strerror(errno)); wError("vgId:%d, file:%s, failed to open since %s", pWal->vgId, pWal->name, strerror(errno));
} else { } 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); pthread_mutex_unlock(&pWal->mutex);
...@@ -95,11 +95,15 @@ void walRemoveAllOldFiles(void *handle) { ...@@ -95,11 +95,15 @@ void walRemoveAllOldFiles(void *handle) {
int64_t fileId = -1; int64_t fileId = -1;
pthread_mutex_lock(&pWal->mutex); 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) { while (walGetNextFile(pWal, &fileId) >= 0) {
snprintf(pWal->name, sizeof(pWal->name), "%s/%s%" PRId64, pWal->path, WAL_PREFIX, fileId); snprintf(pWal->name, sizeof(pWal->name), "%s/%s%" PRId64, pWal->path, WAL_PREFIX, fileId);
if (remove(pWal->name) < 0) { 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 { } else {
wInfo("vgId:%d, wal:%p file:%s, it is removed", pWal->vgId, pWal, pWal->name); 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) { ...@@ -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)); wError("vgId:%d, file:%s, failed to open since %s", pWal->vgId, pWal->name, strerror(errno));
return TAOS_SYSTEM_ERROR(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; return TSDB_CODE_SUCCESS;
...@@ -265,6 +269,8 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch ...@@ -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)); wError("vgId:%d, file:%s, failed to open for restore since %s", pWal->vgId, name, strerror(errno));
tfree(buffer); tfree(buffer);
return TAOS_SYSTEM_ERROR(errno); return TAOS_SYSTEM_ERROR(errno);
} else {
wDebug("vgId:%d, file:%s, open for restore", pWal->vgId, name);
} }
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
...@@ -332,6 +338,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch ...@@ -332,6 +338,7 @@ static int32_t walRestoreWalFile(SWal *pWal, void *pVnode, FWalWrite writeFp, ch
tfClose(tfd); tfClose(tfd);
tfree(buffer); tfree(buffer);
wDebug("vgId:%d, file:%s, it is closed after restore", pWal->vgId, name);
return code; return code;
} }
......
...@@ -110,7 +110,7 @@ system sh/exec.sh -n dnode1 -s start ...@@ -110,7 +110,7 @@ system sh/exec.sh -n dnode1 -s start
print ================== server restart completed print ================== server restart completed
sql connect sql connect
sleep 500c sleep 5000
run general/parser/col_arithmetic_query.sim run general/parser/col_arithmetic_query.sim
......
...@@ -41,10 +41,10 @@ if $data00 != 0.000000000 then ...@@ -41,10 +41,10 @@ if $data00 != 0.000000000 then
return -1 return -1
endi endi
if $data01 != -nan then #if $data01 != -nan then
print expect -nan, actual: $data01 # print expect -nan, actual: $data01
return -1 # return -1
endi #endi
if $data10 != 0.666666667 then if $data10 != 0.666666667 then
return -1 return -1
...@@ -185,9 +185,9 @@ if $data00 != 0.000000000 then ...@@ -185,9 +185,9 @@ if $data00 != 0.000000000 then
return -1 return -1
endi endi
if $data01 != -nan then #if $data01 != -nan then
return -1 # return -1
endi #endi
if $data02 != 0.000000000 then if $data02 != 0.000000000 then
return -1 return -1
......
...@@ -65,24 +65,24 @@ echo serverPort %NODE% >> %TAOS_CFG% ...@@ -65,24 +65,24 @@ echo serverPort %NODE% >> %TAOS_CFG%
echo dataDir %DATA_DIR% >> %TAOS_CFG% echo dataDir %DATA_DIR% >> %TAOS_CFG%
echo logDir %LOG_DIR% >> %TAOS_CFG% echo logDir %LOG_DIR% >> %TAOS_CFG%
echo debugFlag 0 >> %TAOS_CFG% echo debugFlag 0 >> %TAOS_CFG%
echo mDebugFlag 143 >> %TAOS_CFG% echo mDebugFlag 135 >> %TAOS_CFG%
echo sdbDebugFlag 143 >> %TAOS_CFG% echo sdbDebugFlag 135 >> %TAOS_CFG%
echo dDebugFlag 143 >> %TAOS_CFG% echo dDebugFlag 135 >> %TAOS_CFG%
echo vDebugFlag 143 >> %TAOS_CFG% echo vDebugFlag 135 >> %TAOS_CFG%
echo tsdbDebugFlag 143 >> %TAOS_CFG% echo tsdbDebugFlag 135 >> %TAOS_CFG%
echo cDebugFlag 143 >> %TAOS_CFG% echo cDebugFlag 135 >> %TAOS_CFG%
echo jnidebugFlag 143 >> %TAOS_CFG% echo jnidebugFlag 135 >> %TAOS_CFG%
echo odbcdebugFlag 143 >> %TAOS_CFG% echo odbcdebugFlag 135 >> %TAOS_CFG%
echo httpDebugFlag 143 >> %TAOS_CFG% echo httpDebugFlag 135 >> %TAOS_CFG%
echo monDebugFlag 143 >> %TAOS_CFG% echo monDebugFlag 135 >> %TAOS_CFG%
echo mqttDebugFlag 143 >> %TAOS_CFG% echo mqttDebugFlag 135 >> %TAOS_CFG%
echo qdebugFlag 143 >> %TAOS_CFG% echo qdebugFlag 135 >> %TAOS_CFG%
echo rpcDebugFlag 143 >> %TAOS_CFG% echo rpcDebugFlag 135 >> %TAOS_CFG%
echo tmrDebugFlag 131 >> %TAOS_CFG% echo tmrDebugFlag 131 >> %TAOS_CFG%
echo udebugFlag 143 >> %TAOS_CFG% echo udebugFlag 135 >> %TAOS_CFG%
echo sdebugFlag 143 >> %TAOS_CFG% echo sdebugFlag 135 >> %TAOS_CFG%
echo wdebugFlag 143 >> %TAOS_CFG% echo wdebugFlag 135 >> %TAOS_CFG%
echo cqdebugFlag 143 >> %TAOS_CFG% echo cqdebugFlag 135 >> %TAOS_CFG%
echo monitor 0 >> %TAOS_CFG% echo monitor 0 >> %TAOS_CFG%
echo monitorInterval 1 >> %TAOS_CFG% echo monitorInterval 1 >> %TAOS_CFG%
echo http 0 >> %TAOS_CFG% echo http 0 >> %TAOS_CFG%
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册