Merge branch 'develop' into feature/TD-1925_new
This commit is contained in:
commit
e5dce6e125
|
@ -352,8 +352,8 @@ void tsdbIncCommitRef(int vgId);
|
||||||
void tsdbDecCommitRef(int vgId);
|
void tsdbDecCommitRef(int vgId);
|
||||||
|
|
||||||
// For TSDB file sync
|
// For TSDB file sync
|
||||||
int tsdbSyncSend(void *pRepo, int socketFd);
|
int tsdbSyncSend(void *pRepo, SOCKET socketFd);
|
||||||
int tsdbSyncRecv(void *pRepo, int socketFd);
|
int tsdbSyncRecv(void *pRepo, SOCKET socketFd);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,8 +79,8 @@ typedef void (*FStopSyncFile)(int32_t vgId, uint64_t fversion);
|
||||||
// get file version
|
// get file version
|
||||||
typedef int32_t (*FGetVersion)(int32_t vgId, uint64_t *fver, uint64_t *vver);
|
typedef int32_t (*FGetVersion)(int32_t vgId, uint64_t *fver, uint64_t *vver);
|
||||||
|
|
||||||
typedef int32_t (*FSendFile)(void *tsdb, int32_t socketFd);
|
typedef int32_t (*FSendFile)(void *tsdb, SOCKET socketFd);
|
||||||
typedef int32_t (*FRecvFile)(void *tsdb, int32_t socketFd);
|
typedef int32_t (*FRecvFile)(void *tsdb, SOCKET socketFd);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId; // vgroup ID
|
int32_t vgId; // vgroup ID
|
||||||
|
|
|
@ -470,7 +470,7 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
|
||||||
|
|
||||||
wordexp_t full_path;
|
wordexp_t full_path;
|
||||||
|
|
||||||
if (wordexp(fname, &full_path, 0) != 0) {
|
if (wordexp((char *)fname, &full_path, 0) != 0) {
|
||||||
fprintf(stderr, "ERROR: invalid file name: %s\n", fname);
|
fprintf(stderr, "ERROR: invalid file name: %s\n", fname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,8 @@ typedef int(*__compar_fn_t)(const void *, const void *);
|
||||||
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_PTHREAD_RWLOCK
|
||||||
|
|
||||||
int64_t tsosStr2int64(char *str);
|
int64_t tsosStr2int64(char *str);
|
||||||
|
|
||||||
#include "eok.h"
|
#include "eok.h"
|
||||||
|
|
|
@ -28,6 +28,21 @@ extern "C" {
|
||||||
#define tsem_destroy sem_destroy
|
#define tsem_destroy sem_destroy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef TAOS_OS_FUNC_PTHREAD_RWLOCK
|
||||||
|
#define pthread_rwlock_t pthread_mutex_t
|
||||||
|
#define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL)
|
||||||
|
#define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock)
|
||||||
|
#define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock)
|
||||||
|
#define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock)
|
||||||
|
#define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock)
|
||||||
|
|
||||||
|
#define pthread_spinlock_t pthread_mutex_t
|
||||||
|
#define pthread_spin_init(lock, NULL) pthread_mutex_init(lock, NULL)
|
||||||
|
#define pthread_spin_destroy(lock) pthread_mutex_destroy(lock)
|
||||||
|
#define pthread_spin_lock(lock) pthread_mutex_lock(lock)
|
||||||
|
#define pthread_spin_unlock(lock) pthread_mutex_unlock(lock)
|
||||||
|
#endif
|
||||||
|
|
||||||
// TAOS_OS_FUNC_SEMPHONE_PTHREAD
|
// TAOS_OS_FUNC_SEMPHONE_PTHREAD
|
||||||
bool taosCheckPthreadValid(pthread_t thread);
|
bool taosCheckPthreadValid(pthread_t thread);
|
||||||
int64_t taosGetSelfPthreadId();
|
int64_t taosGetSelfPthreadId();
|
||||||
|
|
|
@ -201,13 +201,15 @@ int gettimeofday(struct timeval *ptv, void *pTimeZone);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int we_wordc;
|
int we_wordc;
|
||||||
char **we_wordv;
|
char *we_wordv[1];
|
||||||
int we_offs;
|
int we_offs;
|
||||||
char wordPos[20];
|
char wordPos[1025];
|
||||||
} wordexp_t;
|
} wordexp_t;
|
||||||
int wordexp(const char *words, wordexp_t *pwordexp, int flags);
|
int wordexp(char *words, wordexp_t *pwordexp, int flags);
|
||||||
void wordfree(wordexp_t *pwordexp);
|
void wordfree(wordexp_t *pwordexp);
|
||||||
|
|
||||||
|
char *realpath(char *path, char *resolved_path);
|
||||||
|
|
||||||
#define openlog(a, b, c)
|
#define openlog(a, b, c)
|
||||||
#define closelog()
|
#define closelog()
|
||||||
#define LOG_ERR 0
|
#define LOG_ERR 0
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <libproc.h>
|
#include <libproc.h>
|
||||||
|
|
||||||
|
@ -70,8 +71,6 @@ void taosGetSystemInfo() {
|
||||||
taosGetSystemLocale();
|
taosGetSystemLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosGetDisk() {}
|
|
||||||
|
|
||||||
bool taosGetProcIO(float *readKB, float *writeKB) {
|
bool taosGetProcIO(float *readKB, float *writeKB) {
|
||||||
*readKB = 0;
|
*readKB = 0;
|
||||||
*writeKB = 0;
|
*writeKB = 0;
|
||||||
|
@ -106,6 +105,19 @@ int taosSystem(const char *cmd) {
|
||||||
|
|
||||||
void taosSetCoreDump() {}
|
void taosSetCoreDump() {}
|
||||||
|
|
||||||
|
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
|
||||||
|
struct statvfs info;
|
||||||
|
if (statvfs(tsDataDir, &info)) {
|
||||||
|
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
diskSize->tsize = info.f_blocks * info.f_frsize;
|
||||||
|
diskSize->avail = info.f_bavail * info.f_frsize;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char cmdline[1024];
|
char cmdline[1024];
|
||||||
|
|
||||||
char *taosGetCmdlineByPID(int pid) {
|
char *taosGetCmdlineByPID(int pid) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "tconfig.h"
|
#include "tconfig.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
|
||||||
#ifndef TAOS_OS_FUNC_SYSINFO
|
#ifndef TAOS_OS_FUNC_SYSINFO
|
||||||
|
|
||||||
|
@ -320,11 +321,12 @@ int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
|
||||||
struct statvfs info;
|
struct statvfs info;
|
||||||
if (statvfs(tsDataDir, &info)) {
|
if (statvfs(tsDataDir, &info)) {
|
||||||
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
||||||
return false;
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
diskSize->tsize = info.f_blocks * info.f_frsize;
|
diskSize->tsize = info.f_blocks * info.f_frsize;
|
||||||
diskSize->avail = info.f_bavail * info.f_frsize;
|
diskSize->avail = info.f_bavail * info.f_frsize;
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "ttimer.h"
|
#include "ttimer.h"
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
#include "taoserror.h"
|
||||||
#if (_WIN64)
|
#if (_WIN64)
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
#include <mswsock.h>
|
#include <mswsock.h>
|
||||||
|
@ -126,37 +127,22 @@ bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosGetDisk() {
|
int32_t taosGetDiskSize(char *dataDir, SysDiskSize *diskSize) {
|
||||||
const double unit = 1024 * 1024 * 1024;
|
|
||||||
BOOL fResult;
|
|
||||||
unsigned _int64 i64FreeBytesToCaller;
|
unsigned _int64 i64FreeBytesToCaller;
|
||||||
unsigned _int64 i64TotalBytes;
|
unsigned _int64 i64TotalBytes;
|
||||||
unsigned _int64 i64FreeBytes;
|
unsigned _int64 i64FreeBytes;
|
||||||
|
|
||||||
if (tscEmbedded) {
|
BOOL fResult = GetDiskFreeSpaceExA(dataDir, (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes,
|
||||||
fResult = GetDiskFreeSpaceExA(tsDataDir, (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes,
|
(PULARGE_INTEGER)&i64FreeBytes);
|
||||||
(PULARGE_INTEGER)&i64FreeBytes);
|
|
||||||
if (fResult) {
|
|
||||||
tsTotalDataDirGB = (float)(i64TotalBytes / unit);
|
|
||||||
tsAvailDataDirGB = (float)(i64FreeBytes / unit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fResult = GetDiskFreeSpaceExA(tsLogDir, (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes,
|
|
||||||
(PULARGE_INTEGER)&i64FreeBytes);
|
|
||||||
if (fResult) {
|
if (fResult) {
|
||||||
tsTotalLogDirGB = (float)(i64TotalBytes / unit);
|
diskSize->tsize = (int64_t)(i64TotalBytes);
|
||||||
tsAvailLogDirGB = (float)(i64FreeBytes / unit);
|
diskSize->avail = (int64_t)(i64FreeBytes);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
uError("failed to get disk size, dataDir:%s errno:%s", tsDataDir, strerror(errno));
|
||||||
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fResult = GetDiskFreeSpaceExA(tsTempDir, (PULARGE_INTEGER)&i64FreeBytesToCaller, (PULARGE_INTEGER)&i64TotalBytes,
|
|
||||||
(PULARGE_INTEGER)&i64FreeBytes);
|
|
||||||
if (fResult) {
|
|
||||||
tsTotalTmpDirGB = (float)(i64TotalBytes / unit);
|
|
||||||
tsAvailTmpDirectorySpace = (float)(i64FreeBytes / unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosGetBandSpeed(float *bandSpeedKb) {
|
bool taosGetBandSpeed(float *bandSpeedKb) {
|
||||||
|
@ -207,7 +193,7 @@ void taosGetSystemInfo() {
|
||||||
tsTotalMemoryMB = taosGetTotalMemory();
|
tsTotalMemoryMB = taosGetTotalMemory();
|
||||||
|
|
||||||
float tmp1, tmp2;
|
float tmp1, tmp2;
|
||||||
taosGetDisk();
|
// taosGetDisk();
|
||||||
taosGetBandSpeed(&tmp1);
|
taosGetBandSpeed(&tmp1);
|
||||||
taosGetCpuUsage(&tmp1, &tmp2);
|
taosGetCpuUsage(&tmp1, &tmp2);
|
||||||
taosGetProcIO(&tmp1, &tmp2);
|
taosGetProcIO(&tmp1, &tmp2);
|
||||||
|
|
|
@ -21,13 +21,24 @@
|
||||||
#include "tulog.h"
|
#include "tulog.h"
|
||||||
#include "tutil.h"
|
#include "tutil.h"
|
||||||
|
|
||||||
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
|
int wordexp(char *words, wordexp_t *pwordexp, int flags) {
|
||||||
pwordexp->we_offs = 0;
|
pwordexp->we_offs = 0;
|
||||||
pwordexp->we_wordc = 1;
|
pwordexp->we_wordc = 1;
|
||||||
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
|
pwordexp->we_wordv[0] = pwordexp->wordPos;
|
||||||
pwordexp->we_wordv[0] = (char *)words;
|
|
||||||
|
memset(pwordexp->wordPos, 0, 1025);
|
||||||
|
if (_fullpath(pwordexp->wordPos, words, 1024) == NULL) {
|
||||||
|
pwordexp->we_wordv[0] = words;
|
||||||
|
uError("failed to parse relative path:%s to abs path", words);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uTrace("parse relative path:%s to abs path:%s", words, pwordexp->wordPos);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wordfree(wordexp_t *pwordexp) {}
|
void wordfree(wordexp_t *pwordexp) {}
|
||||||
|
|
||||||
|
char *realpath(char *path, char *resolved_path) {
|
||||||
|
return _fullpath(path, resolved_path, TSDB_FILENAME_LEN - 1);
|
||||||
|
}
|
|
@ -35,7 +35,7 @@ void restBuildSqlAffectRowsJson(HttpContext *pContext, HttpSqlCmd *cmd, int32_t
|
||||||
// data row array end
|
// data row array end
|
||||||
httpJsonToken(jsonBuf, JsonArrEnd);
|
httpJsonToken(jsonBuf, JsonArrEnd);
|
||||||
|
|
||||||
cmd->numOfRows = affect_rows;
|
cmd->numOfRows = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void restStartSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result) {
|
void restStartSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result) {
|
||||||
|
|
|
@ -42,17 +42,17 @@ SDisk *tfsFreeDisk(SDisk *pDisk) {
|
||||||
int tfsUpdateDiskInfo(SDisk *pDisk) {
|
int tfsUpdateDiskInfo(SDisk *pDisk) {
|
||||||
ASSERT(pDisk != NULL);
|
ASSERT(pDisk != NULL);
|
||||||
|
|
||||||
struct statvfs dstat;
|
SysDiskSize diskSize = {0};
|
||||||
if (statvfs(pDisk->dir, &dstat) < 0) {
|
|
||||||
|
int code = taosGetDiskSize(pDisk->dir, &diskSize);
|
||||||
|
if (code != 0) {
|
||||||
fError("failed to update disk information at level %d id %d dir %s since %s", pDisk->level, pDisk->id, pDisk->dir,
|
fError("failed to update disk information at level %d id %d dir %s since %s", pDisk->level, pDisk->id, pDisk->dir,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
pDisk->dmeta.size = 0;
|
|
||||||
pDisk->dmeta.free = 0;
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
pDisk->dmeta.size = dstat.f_blocks * dstat.f_frsize;
|
|
||||||
pDisk->dmeta.free = dstat.f_bavail * dstat.f_frsize;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDisk->dmeta.size = diskSize.tsize;
|
||||||
|
pDisk->dmeta.free = diskSize.tsize - diskSize.avail;
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
|
@ -21,8 +21,7 @@
|
||||||
#include "tfs.h"
|
#include "tfs.h"
|
||||||
#include "tfsint.h"
|
#include "tfsint.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#define TMPNAME_LEN (TSDB_FILENAME_LEN * 2 + 32)
|
||||||
#pragma GCC diagnostic ignored "-Wformat-truncation"
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pthread_spinlock_t lock;
|
pthread_spinlock_t lock;
|
||||||
|
@ -188,7 +187,10 @@ void tfsInitFile(TFILE *pf, int level, int id, const char *bname) {
|
||||||
pf->level = level;
|
pf->level = level;
|
||||||
pf->id = id;
|
pf->id = id;
|
||||||
strncpy(pf->rname, bname, TSDB_FILENAME_LEN);
|
strncpy(pf->rname, bname, TSDB_FILENAME_LEN);
|
||||||
snprintf(pf->aname, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), bname);
|
|
||||||
|
char tmpName[TMPNAME_LEN] = {0};
|
||||||
|
snprintf(tmpName, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), bname);
|
||||||
|
tstrncpy(pf->aname, tmpName, TSDB_FILENAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tfsIsSameFile(const TFILE *pf1, const TFILE *pf2) {
|
bool tfsIsSameFile(const TFILE *pf1, const TFILE *pf2) {
|
||||||
|
@ -241,9 +243,9 @@ void tfsdirname(const TFILE *pf, char *dest) {
|
||||||
// DIR APIs ====================================
|
// DIR APIs ====================================
|
||||||
int tfsMkdirAt(const char *rname, int level, int id) {
|
int tfsMkdirAt(const char *rname, int level, int id) {
|
||||||
SDisk *pDisk = TFS_DISK_AT(level, id);
|
SDisk *pDisk = TFS_DISK_AT(level, id);
|
||||||
char aname[TSDB_FILENAME_LEN];
|
char aname[TMPNAME_LEN];
|
||||||
|
|
||||||
snprintf(aname, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), rname);
|
snprintf(aname, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), rname);
|
||||||
if (taosMkDir(aname, 0755) != 0) {
|
if (taosMkDir(aname, 0755) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -289,14 +291,14 @@ int tfsMkdir(const char *rname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tfsRmdir(const char *rname) {
|
int tfsRmdir(const char *rname) {
|
||||||
char aname[TSDB_FILENAME_LEN] = "\0";
|
char aname[TMPNAME_LEN] = "\0";
|
||||||
|
|
||||||
for (int level = 0; level < TFS_NLEVEL(); level++) {
|
for (int level = 0; level < TFS_NLEVEL(); level++) {
|
||||||
STier *pTier = TFS_TIER_AT(level);
|
STier *pTier = TFS_TIER_AT(level);
|
||||||
for (int id = 0; id < TIER_NDISKS(pTier); id++) {
|
for (int id = 0; id < TIER_NDISKS(pTier); id++) {
|
||||||
SDisk *pDisk = DISK_AT_TIER(pTier, id);
|
SDisk *pDisk = DISK_AT_TIER(pTier, id);
|
||||||
|
|
||||||
snprintf(aname, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), rname);
|
snprintf(aname, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), rname);
|
||||||
|
|
||||||
taosRemoveDir(aname);
|
taosRemoveDir(aname);
|
||||||
}
|
}
|
||||||
|
@ -306,16 +308,16 @@ int tfsRmdir(const char *rname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tfsRename(char *orname, char *nrname) {
|
int tfsRename(char *orname, char *nrname) {
|
||||||
char oaname[TSDB_FILENAME_LEN] = "\0";
|
char oaname[TMPNAME_LEN] = "\0";
|
||||||
char naname[TSDB_FILENAME_LEN] = "\0";
|
char naname[TMPNAME_LEN] = "\0";
|
||||||
|
|
||||||
for (int level = 0; level < pfs->nlevel; level++) {
|
for (int level = 0; level < pfs->nlevel; level++) {
|
||||||
STier *pTier = TFS_TIER_AT(level);
|
STier *pTier = TFS_TIER_AT(level);
|
||||||
for (int id = 0; id < TIER_NDISKS(pTier); id++) {
|
for (int id = 0; id < TIER_NDISKS(pTier); id++) {
|
||||||
SDisk *pDisk = DISK_AT_TIER(pTier, id);
|
SDisk *pDisk = DISK_AT_TIER(pTier, id);
|
||||||
|
|
||||||
snprintf(oaname, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), orname);
|
snprintf(oaname, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), orname);
|
||||||
snprintf(naname, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), nrname);
|
snprintf(naname, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), nrname);
|
||||||
|
|
||||||
taosRename(oaname, naname);
|
taosRename(oaname, naname);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +355,7 @@ TDIR *tfsOpendir(const char *rname) {
|
||||||
|
|
||||||
const TFILE *tfsReaddir(TDIR *tdir) {
|
const TFILE *tfsReaddir(TDIR *tdir) {
|
||||||
if (tdir == NULL || tdir->dir == NULL) return NULL;
|
if (tdir == NULL || tdir->dir == NULL) return NULL;
|
||||||
char bname[TSDB_FILENAME_LEN] = "\0";
|
char bname[TMPNAME_LEN * 2] = "\0";
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
struct dirent *dp = NULL;
|
struct dirent *dp = NULL;
|
||||||
|
@ -362,7 +364,7 @@ const TFILE *tfsReaddir(TDIR *tdir) {
|
||||||
// Skip . and ..
|
// Skip . and ..
|
||||||
if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue;
|
if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue;
|
||||||
|
|
||||||
snprintf(bname, TSDB_FILENAME_LEN, "%s/%s", tdir->dirname, dp->d_name);
|
snprintf(bname, TMPNAME_LEN * 2, "%s/%s", tdir->dirname, dp->d_name);
|
||||||
tfsInitFile(&(tdir->tfile), tdir->level, tdir->id, bname);
|
tfsInitFile(&(tdir->tfile), tdir->level, tdir->id, bname);
|
||||||
return &(tdir->tfile);
|
return &(tdir->tfile);
|
||||||
}
|
}
|
||||||
|
@ -524,7 +526,7 @@ static SDisk *tfsGetDiskByName(const char *dir) {
|
||||||
|
|
||||||
static int tfsOpendirImpl(TDIR *tdir) {
|
static int tfsOpendirImpl(TDIR *tdir) {
|
||||||
SDisk *pDisk = NULL;
|
SDisk *pDisk = NULL;
|
||||||
char adir[TSDB_FILENAME_LEN] = "\0";
|
char adir[TMPNAME_LEN * 2] = "\0";
|
||||||
|
|
||||||
if (tdir->dir != NULL) {
|
if (tdir->dir != NULL) {
|
||||||
closedir(tdir->dir);
|
closedir(tdir->dir);
|
||||||
|
@ -538,7 +540,7 @@ static int tfsOpendirImpl(TDIR *tdir) {
|
||||||
tdir->level = DISK_LEVEL(pDisk);
|
tdir->level = DISK_LEVEL(pDisk);
|
||||||
tdir->id = DISK_ID(pDisk);
|
tdir->id = DISK_ID(pDisk);
|
||||||
|
|
||||||
snprintf(adir, TSDB_FILENAME_LEN, "%s/%s", DISK_DIR(pDisk), tdir->dirname);
|
snprintf(adir, TMPNAME_LEN * 2, "%s/%s", DISK_DIR(pDisk), tdir->dirname);
|
||||||
tdir->dir = opendir(adir);
|
tdir->dir = opendir(adir);
|
||||||
if (tdir->dir != NULL) break;
|
if (tdir->dir != NULL) break;
|
||||||
}
|
}
|
||||||
|
@ -582,19 +584,17 @@ void taosGetDisk() {
|
||||||
|
|
||||||
if (tscEmbedded) {
|
if (tscEmbedded) {
|
||||||
tfsUpdateInfo(&fsMeta);
|
tfsUpdateInfo(&fsMeta);
|
||||||
tsTotalDataDirGB = (float)fsMeta.tsize / unit;
|
tsTotalDataDirGB = (float)(fsMeta.tsize / unit);
|
||||||
tsAvailDataDirGB = (float)fsMeta.avail / unit;
|
tsAvailDataDirGB = (float)(fsMeta.avail / unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosGetDiskSize(tsLogDir, &diskSize)) {
|
if (taosGetDiskSize(tsLogDir, &diskSize) == 0) {
|
||||||
tsTotalLogDirGB = (float)diskSize.tsize / unit;
|
tsTotalLogDirGB = (float)(diskSize.tsize / unit);
|
||||||
tsAvailLogDirGB = (float)diskSize.avail / unit;
|
tsAvailLogDirGB = (float)(diskSize.avail / unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosGetDiskSize("/tmp", &diskSize)) {
|
if (taosGetDiskSize("/tmp", &diskSize) == 0) {
|
||||||
tsTotalTmpDirGB = (float)diskSize.tsize / unit;
|
tsTotalTmpDirGB = (float)(diskSize.tsize / unit);
|
||||||
tsAvailTmpDirectorySpace = (float)diskSize.avail / unit;
|
tsAvailTmpDirectorySpace = (float)(diskSize.avail / unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
|
@ -133,7 +133,7 @@ static FORCE_INLINE int tsdbAppendMFile(SMFile* pMFile, void* buf, int64_t nbyte
|
||||||
|
|
||||||
pMFile->info.size += nbyte;
|
pMFile->info.size += nbyte;
|
||||||
|
|
||||||
return nbyte;
|
return (int)nbyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbRemoveMFile(SMFile* pMFile) { return tfsremove(TSDB_FILE_F(pMFile)); }
|
static FORCE_INLINE int tsdbRemoveMFile(SMFile* pMFile) { return tfsremove(TSDB_FILE_F(pMFile)); }
|
||||||
|
@ -246,7 +246,7 @@ static FORCE_INLINE int tsdbAppendDFile(SDFile* pDFile, void* buf, int64_t nbyte
|
||||||
|
|
||||||
pDFile->info.size += nbyte;
|
pDFile->info.size += nbyte;
|
||||||
|
|
||||||
return nbyte;
|
return (int)nbyte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int tsdbRemoveDFile(SDFile* pDFile) { return tfsremove(TSDB_FILE_F(pDFile)); }
|
static FORCE_INLINE int tsdbRemoveDFile(SDFile* pDFile) { return tfsremove(TSDB_FILE_F(pDFile)); }
|
||||||
|
|
|
@ -217,9 +217,9 @@ void tsdbGetRtnSnap(STsdbRepo *pRepo, SRtn *pRtn) {
|
||||||
maxKey = now - pCfg->keep1 * tsMsPerDay[pCfg->precision];
|
maxKey = now - pCfg->keep1 * tsMsPerDay[pCfg->precision];
|
||||||
|
|
||||||
pRtn->minKey = minKey;
|
pRtn->minKey = minKey;
|
||||||
pRtn->minFid = TSDB_KEY_FID(minKey, pCfg->daysPerFile, pCfg->precision);
|
pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->daysPerFile, pCfg->precision));
|
||||||
pRtn->midFid = TSDB_KEY_FID(midKey, pCfg->daysPerFile, pCfg->precision);
|
pRtn->midFid = (int)(TSDB_KEY_FID(midKey, pCfg->daysPerFile, pCfg->precision));
|
||||||
pRtn->maxFid = TSDB_KEY_FID(maxKey, pCfg->daysPerFile, pCfg->precision);
|
pRtn->maxFid = (int)(TSDB_KEY_FID(maxKey, pCfg->daysPerFile, pCfg->precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbUpdateMetaRecord(STsdbFS *pfs, SMFile *pMFile, uint64_t uid, void *cont, int contLen) {
|
static int tsdbUpdateMetaRecord(STsdbFS *pfs, SMFile *pMFile, uint64_t uid, void *cont, int contLen) {
|
||||||
|
@ -292,10 +292,12 @@ static int tsdbDropMetaRecord(STsdbFS *pfs, SMFile *pMFile, uint64_t uid) {
|
||||||
// =================== Commit Time-Series Data
|
// =================== Commit Time-Series Data
|
||||||
static int tsdbCommitTSData(STsdbRepo *pRepo) {
|
static int tsdbCommitTSData(STsdbRepo *pRepo) {
|
||||||
SMemTable *pMem = pRepo->imem;
|
SMemTable *pMem = pRepo->imem;
|
||||||
SCommitH commith = {0};
|
SCommitH commith;
|
||||||
SDFileSet *pSet = NULL;
|
SDFileSet *pSet = NULL;
|
||||||
int fid;
|
int fid;
|
||||||
|
|
||||||
|
memset(&commith, 0, sizeof(SMemTable *));
|
||||||
|
|
||||||
if (pMem->numOfRows <= 0) {
|
if (pMem->numOfRows <= 0) {
|
||||||
// No memory data, just apply retention on each file on disk
|
// No memory data, just apply retention on each file on disk
|
||||||
if (tsdbApplyRtn(pRepo) < 0) {
|
if (tsdbApplyRtn(pRepo) < 0) {
|
||||||
|
@ -591,7 +593,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) {
|
||||||
if (nextKey == TSDB_DATA_TIMESTAMP_NULL) {
|
if (nextKey == TSDB_DATA_TIMESTAMP_NULL) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
int tfid = TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision);
|
int tfid = (int)(TSDB_KEY_FID(nextKey, pCfg->daysPerFile, pCfg->precision));
|
||||||
if (fid == TSDB_IVLD_FID || fid > tfid) {
|
if (fid == TSDB_IVLD_FID || fid > tfid) {
|
||||||
fid = tfid;
|
fid = tfid;
|
||||||
}
|
}
|
||||||
|
@ -887,7 +889,7 @@ static int tsdbWriteBlockInfo(SCommitH *pCommih) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlen = sizeof(SBlockInfo) + sizeof(SBlock) * (nSupBlocks + nSubBlocks) + sizeof(TSCKSUM);
|
tlen = (uint32_t)(sizeof(SBlockInfo) + sizeof(SBlock) * (nSupBlocks + nSubBlocks) + sizeof(TSCKSUM));
|
||||||
|
|
||||||
// Write SBlockInfo part
|
// Write SBlockInfo part
|
||||||
if (tsdbMakeRoom((void **)(&(TSDB_COMMIT_BUF(pCommih))), tlen) < 0) return -1;
|
if (tsdbMakeRoom((void **)(&(TSDB_COMMIT_BUF(pCommih))), tlen) < 0) return -1;
|
||||||
|
@ -925,7 +927,7 @@ static int tsdbWriteBlockInfo(SCommitH *pCommih) {
|
||||||
blkIdx.uid = TABLE_UID(pTable);
|
blkIdx.uid = TABLE_UID(pTable);
|
||||||
blkIdx.hasLast = pBlock->last ? 1 : 0;
|
blkIdx.hasLast = pBlock->last ? 1 : 0;
|
||||||
blkIdx.maxKey = pBlock->keyLast;
|
blkIdx.maxKey = pBlock->keyLast;
|
||||||
blkIdx.numOfBlocks = nSupBlocks;
|
blkIdx.numOfBlocks = (uint32_t)nSupBlocks;
|
||||||
blkIdx.len = tlen;
|
blkIdx.len = tlen;
|
||||||
blkIdx.offset = (uint32_t)offset;
|
blkIdx.offset = (uint32_t)offset;
|
||||||
|
|
||||||
|
@ -976,7 +978,7 @@ static int tsdbWriteBlockIdx(SCommitH *pCommih) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbUpdateDFileMagic(pHeadf, POINTER_SHIFT(TSDB_COMMIT_BUF(pCommih), tlen - sizeof(TSCKSUM)));
|
tsdbUpdateDFileMagic(pHeadf, POINTER_SHIFT(TSDB_COMMIT_BUF(pCommih), tlen - sizeof(TSCKSUM)));
|
||||||
pHeadf->info.offset = offset;
|
pHeadf->info.offset = (uint32_t)offset;
|
||||||
pHeadf->info.len = tlen;
|
pHeadf->info.len = tlen;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -13,7 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "os.h"
|
||||||
#include "tsdbint.h"
|
#include "tsdbint.h"
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T;
|
typedef enum { TSDB_TXN_TEMP_FILE = 0, TSDB_TXN_CURR_FILE } TSDB_TXN_FILE_T;
|
||||||
static const char *tsdbTxnFname[] = {"current.t", "current"};
|
static const char *tsdbTxnFname[] = {"current.t", "current"};
|
||||||
|
@ -162,7 +164,7 @@ static void tsdbSetStatusMFile(SFSStatus *pStatus, const SMFile *pMFile) {
|
||||||
ASSERT(pStatus->pmf == NULL);
|
ASSERT(pStatus->pmf == NULL);
|
||||||
|
|
||||||
pStatus->pmf = &(pStatus->mf);
|
pStatus->pmf = &(pStatus->mf);
|
||||||
tsdbInitMFileEx(pStatus->pmf, pMFile);
|
tsdbInitMFileEx(pStatus->pmf, (SMFile *)pMFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) {
|
static int tsdbAddDFileSetToStatus(SFSStatus *pStatus, const SDFileSet *pSet) {
|
||||||
|
@ -482,7 +484,7 @@ void tsdbFSIterInit(SFSIter *pIter, STsdbFS *pfs, int direction) {
|
||||||
if (direction == TSDB_FS_ITER_FORWARD) {
|
if (direction == TSDB_FS_ITER_FORWARD) {
|
||||||
pIter->index = 0;
|
pIter->index = 0;
|
||||||
} else {
|
} else {
|
||||||
pIter->index = size - 1;
|
pIter->index = (int)(size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pIter->fid = ((SDFileSet *)taosArrayGet(pfs->cstatus->df, pIter->index))->fid;
|
pIter->fid = ((SDFileSet *)taosArrayGet(pfs->cstatus->df, pIter->index))->fid;
|
||||||
|
@ -505,7 +507,7 @@ void tsdbFSIterSeek(SFSIter *pIter, int fid) {
|
||||||
pIter->index = -1;
|
pIter->index = -1;
|
||||||
pIter->fid = TSDB_IVLD_FID;
|
pIter->fid = TSDB_IVLD_FID;
|
||||||
} else {
|
} else {
|
||||||
pIter->index = TARRAY_ELEM_IDX(pfs->cstatus->df, ptr);
|
pIter->index = (int)(TARRAY_ELEM_IDX(pfs->cstatus->df, ptr));
|
||||||
pIter->fid = ((SDFileSet *)ptr)->fid;
|
pIter->fid = ((SDFileSet *)ptr)->fid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -590,7 +592,7 @@ static int tsdbOpenFSFromCurrent(STsdbRepo *pRepo) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nread = taosRead(fd, buffer, TSDB_FILE_HEAD_SIZE);
|
int nread = (int)taosRead(fd, buffer, TSDB_FILE_HEAD_SIZE);
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
tsdbError("vgId:%d failed to read %d bytes from file %s since %s", REPO_ID(pRepo), TSDB_FILENAME_LEN, current,
|
tsdbError("vgId:%d failed to read %d bytes from file %s since %s", REPO_ID(pRepo), TSDB_FILENAME_LEN, current,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
@ -624,7 +626,7 @@ static int tsdbOpenFSFromCurrent(STsdbRepo *pRepo) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
nread = taosRead(fd, buffer, fsheader.len);
|
nread = (int)taosRead(fd, buffer, fsheader.len);
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), current, strerror(errno));
|
tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), current, strerror(errno));
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -771,7 +773,7 @@ int tsdbLoadMetaCache(STsdbRepo *pRepo, bool recoverMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recoverMeta) {
|
if (recoverMeta) {
|
||||||
pBuf = malloc(maxBufSize);
|
pBuf = malloc((size_t)maxBufSize);
|
||||||
if (pBuf == NULL) {
|
if (pBuf == NULL) {
|
||||||
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||||
tsdbCloseMFile(pMFile);
|
tsdbCloseMFile(pMFile);
|
||||||
|
@ -788,7 +790,7 @@ int tsdbLoadMetaCache(STsdbRepo *pRepo, bool recoverMeta) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nread = tsdbReadMFile(pMFile, pBuf, pRecord->size);
|
int nread = (int)tsdbReadMFile(pMFile, pBuf, pRecord->size);
|
||||||
if (nread < 0) {
|
if (nread < 0) {
|
||||||
tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile),
|
tsdbError("vgId:%d failed to read file %s since %s", REPO_ID(pRepo), TSDB_FILE_FULL_NAME(pMFile),
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
|
@ -806,7 +808,7 @@ int tsdbLoadMetaCache(STsdbRepo *pRepo, bool recoverMeta) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsdbRestoreTable(pRepo, pBuf, pRecord->size) < 0) {
|
if (tsdbRestoreTable(pRepo, pBuf, (int)pRecord->size) < 0) {
|
||||||
tsdbError("vgId:%d failed to restore table, uid %" PRId64 ", since %s" PRIu64, REPO_ID(pRepo), pRecord->uid,
|
tsdbError("vgId:%d failed to restore table, uid %" PRId64 ", since %s" PRIu64, REPO_ID(pRepo), pRecord->uid,
|
||||||
tstrerror(terrno));
|
tstrerror(terrno));
|
||||||
tfree(pBuf);
|
tfree(pBuf);
|
||||||
|
|
|
@ -323,7 +323,7 @@ int tsdbLoadBlockStatis(SReadH *pReadh, SBlock *pBlock) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!taosCheckChecksumWhole((uint8_t *)(pReadh->pBlkData), size)) {
|
if (!taosCheckChecksumWhole((uint8_t *)(pReadh->pBlkData), (uint32_t)size)) {
|
||||||
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
terrno = TSDB_CODE_TDB_FILE_CORRUPTED;
|
||||||
tsdbError("vgId:%d block statis part in file %s is corrupted since wrong checksum, offset:%" PRId64 " len :%" PRIzu,
|
tsdbError("vgId:%d block statis part in file %s is corrupted since wrong checksum, offset:%" PRId64 " len :%" PRIzu,
|
||||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), (int64_t)pBlock->offset, size);
|
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), (int64_t)pBlock->offset, size);
|
||||||
|
@ -487,7 +487,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
|
||||||
|
|
||||||
if (tsdbCheckAndDecodeColumnData(pDataCol, POINTER_SHIFT(pBlockData, tsize + toffset), tlen, pBlock->algorithm,
|
if (tsdbCheckAndDecodeColumnData(pDataCol, POINTER_SHIFT(pBlockData, tsize + toffset), tlen, pBlock->algorithm,
|
||||||
pBlock->numOfRows, pDataCols->maxPoints, TSDB_READ_COMP_BUF(pReadh),
|
pBlock->numOfRows, pDataCols->maxPoints, TSDB_READ_COMP_BUF(pReadh),
|
||||||
taosTSizeof(TSDB_READ_COMP_BUF(pReadh))) < 0) {
|
(int)taosTSizeof(TSDB_READ_COMP_BUF(pReadh))) < 0) {
|
||||||
tsdbError("vgId:%d file %s is broken at column %d block offset %" PRId64 " column offset %d",
|
tsdbError("vgId:%d file %s is broken at column %d block offset %" PRId64 " column offset %d",
|
||||||
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), tcolId, (int64_t)pBlock->offset, toffset);
|
TSDB_READ_REPO_ID(pReadh), TSDB_FILE_FULL_NAME(pDFile), tcolId, (int64_t)pBlock->offset, toffset);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
STsdbRepo *pRepo;
|
STsdbRepo *pRepo;
|
||||||
SRtn rtn;
|
SRtn rtn;
|
||||||
int32_t socketFd;
|
SOCKET socketFd;
|
||||||
void * pBuf;
|
void * pBuf;
|
||||||
bool mfChanged;
|
bool mfChanged;
|
||||||
SMFile * pmf;
|
SMFile * pmf;
|
||||||
|
@ -33,7 +33,7 @@ typedef struct {
|
||||||
|
|
||||||
#define SYNC_BUFFER(sh) ((sh)->pBuf)
|
#define SYNC_BUFFER(sh) ((sh)->pBuf)
|
||||||
|
|
||||||
static void tsdbInitSyncH(SSyncH *pSyncH, STsdbRepo *pRepo, int32_t socketFd);
|
static void tsdbInitSyncH(SSyncH *pSyncH, STsdbRepo *pRepo, SOCKET socketFd);
|
||||||
static void tsdbDestroySyncH(SSyncH *pSyncH);
|
static void tsdbDestroySyncH(SSyncH *pSyncH);
|
||||||
static int32_t tsdbSyncSendMeta(SSyncH *pSynch);
|
static int32_t tsdbSyncSendMeta(SSyncH *pSynch);
|
||||||
static int32_t tsdbSyncRecvMeta(SSyncH *pSynch);
|
static int32_t tsdbSyncRecvMeta(SSyncH *pSynch);
|
||||||
|
@ -49,7 +49,7 @@ static int32_t tsdbSendDFileSetInfo(SSyncH *pSynch, SDFileSet *pSet);
|
||||||
static int32_t tsdbRecvDFileSetInfo(SSyncH *pSynch);
|
static int32_t tsdbRecvDFileSetInfo(SSyncH *pSynch);
|
||||||
static int tsdbReload(STsdbRepo *pRepo, bool isMfChanged);
|
static int tsdbReload(STsdbRepo *pRepo, bool isMfChanged);
|
||||||
|
|
||||||
int32_t tsdbSyncSend(void *tsdb, int32_t socketFd) {
|
int32_t tsdbSyncSend(void *tsdb, SOCKET socketFd) {
|
||||||
STsdbRepo *pRepo = (STsdbRepo *)tsdb;
|
STsdbRepo *pRepo = (STsdbRepo *)tsdb;
|
||||||
SSyncH synch = {0};
|
SSyncH synch = {0};
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbSyncRecv(void *tsdb, int32_t socketFd) {
|
int32_t tsdbSyncRecv(void *tsdb, SOCKET socketFd) {
|
||||||
STsdbRepo *pRepo = (STsdbRepo *)tsdb;
|
STsdbRepo *pRepo = (STsdbRepo *)tsdb;
|
||||||
SSyncH synch = {0};
|
SSyncH synch = {0};
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tsdbInitSyncH(SSyncH *pSyncH, STsdbRepo *pRepo, int32_t socketFd) {
|
static void tsdbInitSyncH(SSyncH *pSyncH, STsdbRepo *pRepo, SOCKET socketFd) {
|
||||||
pSyncH->pRepo = pRepo;
|
pSyncH->pRepo = pRepo;
|
||||||
pSyncH->socketFd = socketFd;
|
pSyncH->socketFd = socketFd;
|
||||||
tsdbGetRtnSnap(pRepo, &(pSyncH->rtn));
|
tsdbGetRtnSnap(pRepo, &(pSyncH->rtn));
|
||||||
|
@ -149,10 +149,10 @@ static int32_t tsdbSyncSendMeta(SSyncH *pSynch) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t writeLen = mf.info.size;
|
int32_t writeLen = (int32_t)mf.info.size;
|
||||||
tsdbInfo("vgId:%d, metafile:%s will be sent, size:%d", REPO_ID(pRepo), mf.f.aname, writeLen);
|
tsdbInfo("vgId:%d, metafile:%s will be sent, size:%d", REPO_ID(pRepo), mf.f.aname, writeLen);
|
||||||
|
|
||||||
int32_t ret = taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&mf), 0, writeLen);
|
int32_t ret = (int32_t)taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&mf), 0, writeLen);
|
||||||
if (ret != writeLen) {
|
if (ret != writeLen) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tsdbError("vgId:%d, failed to send metafile since %s, ret:%d writeLen:%d", REPO_ID(pRepo), tstrerror(terrno), ret,
|
tsdbError("vgId:%d, failed to send metafile since %s, ret:%d writeLen:%d", REPO_ID(pRepo), tstrerror(terrno), ret,
|
||||||
|
@ -213,7 +213,7 @@ static int32_t tsdbSyncRecvMeta(SSyncH *pSynch) {
|
||||||
|
|
||||||
tsdbInfo("vgId:%d, metafile:%s is created", REPO_ID(pRepo), mf.f.aname);
|
tsdbInfo("vgId:%d, metafile:%s is created", REPO_ID(pRepo), mf.f.aname);
|
||||||
|
|
||||||
int32_t readLen = pSynch->pmf->info.size;
|
int32_t readLen = (int32_t)pSynch->pmf->info.size;
|
||||||
int32_t ret = taosCopyFds(pSynch->socketFd, TSDB_FILE_FD(&mf), readLen);
|
int32_t ret = taosCopyFds(pSynch->socketFd, TSDB_FILE_FD(&mf), readLen);
|
||||||
if (ret != readLen) {
|
if (ret != readLen) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -458,7 +458,7 @@ static int32_t tsdbSyncRecvDFileSetArray(SSyncH *pSynch) {
|
||||||
tsdbInfo("vgId:%d, file:%s will be received, osize:%" PRIu64 " rsize:%" PRIu64, REPO_ID(pRepo),
|
tsdbInfo("vgId:%d, file:%s will be received, osize:%" PRIu64 " rsize:%" PRIu64, REPO_ID(pRepo),
|
||||||
pDFile->f.aname, pDFile->info.size, pRDFile->info.size);
|
pDFile->f.aname, pDFile->info.size, pRDFile->info.size);
|
||||||
|
|
||||||
int32_t writeLen = pRDFile->info.size;
|
int32_t writeLen = (int32_t)pRDFile->info.size;
|
||||||
int32_t ret = taosCopyFds(pSynch->socketFd, pDFile->fd, writeLen);
|
int32_t ret = taosCopyFds(pSynch->socketFd, pDFile->fd, writeLen);
|
||||||
if (ret != writeLen) {
|
if (ret != writeLen) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
|
@ -570,10 +570,10 @@ static int32_t tsdbSyncSendDFileSet(SSyncH *pSynch, SDFileSet *pSet) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t writeLen = df.info.size;
|
int32_t writeLen = (int32_t)df.info.size;
|
||||||
tsdbInfo("vgId:%d, file:%s will be sent, size:%d", REPO_ID(pRepo), df.f.aname, writeLen);
|
tsdbInfo("vgId:%d, file:%s will be sent, size:%d", REPO_ID(pRepo), df.f.aname, writeLen);
|
||||||
|
|
||||||
int32_t ret = taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&df), 0, writeLen);
|
int32_t ret = (int32_t)taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&df), 0, writeLen);
|
||||||
if (ret != writeLen) {
|
if (ret != writeLen) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tsdbError("vgId:%d, failed to send file:%s since %s, ret:%d writeLen:%d", REPO_ID(pRepo), df.f.aname,
|
tsdbError("vgId:%d, failed to send file:%s since %s, ret:%d writeLen:%d", REPO_ID(pRepo), df.f.aname,
|
||||||
|
|
|
@ -483,5 +483,5 @@ int32_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) {
|
||||||
leftLen -= readLen;
|
leftLen -= readLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return (int32_t)len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,11 @@ static void removeTimer(uintptr_t id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t getMonotonicMs(void) {
|
static int64_t getMonotonicMs(void) {
|
||||||
|
#ifdef WINDOWS
|
||||||
return (int64_t) getMonotonicUs() / 1000;
|
return (int64_t) getMonotonicUs() / 1000;
|
||||||
|
#else
|
||||||
|
return taosGetTimestampMs();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addToWheel(tmr_obj_t* timer, uint32_t delay) {
|
static void addToWheel(tmr_obj_t* timer, uint32_t delay) {
|
||||||
|
@ -537,7 +541,8 @@ static void taosTmrModuleInit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) {
|
void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) {
|
||||||
tmrInfo("ttimer monotonic clock source:%s", monotonicInit());
|
const char* ret = monotonicInit();
|
||||||
|
tmrInfo("ttimer monotonic clock source:%s", ret);
|
||||||
|
|
||||||
pthread_once(&tmrModuleInit, taosTmrModuleInit);
|
pthread_once(&tmrModuleInit, taosTmrModuleInit);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ python3 ./test.py -f insert/nchar.py
|
||||||
python3 ./test.py -f insert/nchar-unicode.py
|
python3 ./test.py -f insert/nchar-unicode.py
|
||||||
python3 ./test.py -f insert/multi.py
|
python3 ./test.py -f insert/multi.py
|
||||||
python3 ./test.py -f insert/randomNullCommit.py
|
python3 ./test.py -f insert/randomNullCommit.py
|
||||||
python3 insert/retentionpolicy.py
|
#python3 insert/retentionpolicy.py
|
||||||
python3 ./test.py -f insert/alterTableAndInsert.py
|
python3 ./test.py -f insert/alterTableAndInsert.py
|
||||||
python3 ./test.py -f insert/insertIntoTwoTables.py
|
python3 ./test.py -f insert/insertIntoTwoTables.py
|
||||||
#python3 ./test.py -f insert/before_1970.py
|
#python3 ./test.py -f insert/before_1970.py
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
|
||||||
|
|
||||||
# update
|
# update
|
||||||
python3 ./test.py -f update/allow_update.py
|
#python3 ./test.py -f update/allow_update.py
|
||||||
python3 ./test.py -f update/allow_update-0.py
|
python3 ./test.py -f update/allow_update-0.py
|
||||||
python3 ./test.py -f update/append_commit_data.py
|
python3 ./test.py -f update/append_commit_data.py
|
||||||
python3 ./test.py -f update/append_commit_last-0.py
|
python3 ./test.py -f update/append_commit_last-0.py
|
||||||
python3 ./test.py -f update/append_commit_last.py
|
python3 ./test.py -f update/append_commit_last.py
|
||||||
python3 ./test.py -f update/merge_commit_data.py
|
#python3 ./test.py -f update/merge_commit_data.py
|
||||||
python3 ./test.py -f update/merge_commit_data-0.py
|
#python3 ./test.py -f update/merge_commit_data-0.py
|
||||||
python3 ./test.py -f update/merge_commit_data2.py
|
#python3 ./test.py -f update/merge_commit_data2.py
|
||||||
python3 ./test.py -f update/merge_commit_data2_update0.py
|
#python3 ./test.py -f update/merge_commit_data2_update0.py
|
||||||
python3 ./test.py -f update/merge_commit_last-0.py
|
#python3 ./test.py -f update/merge_commit_last-0.py
|
||||||
python3 ./test.py -f update/merge_commit_last.py
|
#python3 ./test.py -f update/merge_commit_last.py
|
||||||
python3 ./test.py -f update/bug_td2279.py
|
#python3 ./test.py -f update/bug_td2279.py
|
||||||
|
|
||||||
# wal
|
# wal
|
||||||
python3 ./test.py -f wal/addOldWalTest.py
|
python3 ./test.py -f wal/addOldWalTest.py
|
||||||
|
|
|
@ -94,7 +94,7 @@ endi
|
||||||
|
|
||||||
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql
|
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d1' 127.0.0.1:7111/rest/sql
|
||||||
print 12-> $system_content
|
print 12-> $system_content
|
||||||
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":0}@ then
|
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ endi
|
||||||
|
|
||||||
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d1.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
|
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d1.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
|
||||||
print 22-> $system_content
|
print 22-> $system_content
|
||||||
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":0}@ then
|
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -214,13 +214,13 @@ endi
|
||||||
|
|
||||||
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d2' 127.0.0.1:7111/rest/sql
|
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d 'create database d2' 127.0.0.1:7111/rest/sql
|
||||||
print 28-> $system_content
|
print 28-> $system_content
|
||||||
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":0}@ then
|
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d2.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
|
system_content curl -H 'Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04' -d ' create table d2.t1 (ts timestamp, speed int)' 127.0.0.1:7111/rest/sql
|
||||||
print 29-> $system_content
|
print 29-> $system_content
|
||||||
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":0}@ then
|
if $system_content != @{"status":"succ","head":["affected_rows"],"data":[[0]],"rows":1}@ then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue