commit
33d14c1b2f
|
@ -5755,7 +5755,7 @@ int32_t tscCheckCreateDbParams(SSqlCmd* pCmd, SCMCreateDbMsg* pCreate) {
|
|||
char msg[512] = {0};
|
||||
|
||||
if (pCreate->walLevel != -1 && (pCreate->walLevel < TSDB_MIN_WAL_LEVEL || pCreate->walLevel > TSDB_MAX_WAL_LEVEL)) {
|
||||
snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 0-2 allowed", pCreate->walLevel);
|
||||
snprintf(msg, tListLen(msg), "invalid db option walLevel: %d, only 1-2 allowed", pCreate->walLevel);
|
||||
return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef void* twalh; // WAL HANDLE
|
|||
typedef int (*FWalWrite)(void *ahandle, void *pHead, int type);
|
||||
|
||||
twalh walOpen(const char *path, const SWalCfg *pCfg);
|
||||
int walAlter(twalh pWal, const SWalCfg *pCfg);
|
||||
void walClose(twalh);
|
||||
int walRenew(twalh);
|
||||
int walWrite(twalh, SWalHead *);
|
||||
|
|
|
@ -910,13 +910,13 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
|
|||
}
|
||||
|
||||
if (walLevel > 0 && walLevel != pDb->cfg.walLevel) {
|
||||
mError("db:%s, can't alter walLevel option", pDb->name);
|
||||
terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||
mDebug("db:%s, walLevel:%d change to %d", pDb->name, pDb->cfg.walLevel, walLevel);
|
||||
newCfg.walLevel = walLevel;
|
||||
}
|
||||
|
||||
if (fsyncPeriod >= 0 && fsyncPeriod != pDb->cfg.fsyncPeriod) {
|
||||
mError("db:%s, can't alter fsyncPeriod option", pDb->name);
|
||||
terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||
mDebug("db:%s, fsyncPeriod:%d change to %d", pDb->name, pDb->cfg.fsyncPeriod, fsyncPeriod);
|
||||
newCfg.fsyncPeriod = fsyncPeriod;
|
||||
}
|
||||
|
||||
if (replications > 0 && replications != pDb->cfg.replications) {
|
||||
|
|
|
@ -186,6 +186,12 @@ int32_t vnodeAlter(void *param, SMDCreateVnodeMsg *pVnodeCfg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
code = walAlter(pVnode->wal, &pVnode->walCfg);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
pVnode->status = TAOS_VN_STATUS_READY;
|
||||
return code;
|
||||
}
|
||||
|
||||
code = syncReconfig(pVnode->sync, &pVnode->syncCfg);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
pVnode->status = TAOS_VN_STATUS_READY;
|
||||
|
@ -390,6 +396,7 @@ void vnodeRelease(void *pVnodeRaw) {
|
|||
if (0 == tsEnableVnodeBak) {
|
||||
vInfo("vgId:%d, vnode backup not enabled", pVnode->vgId);
|
||||
} else {
|
||||
taosRemoveDir(newDir);
|
||||
taosRename(rootDir, newDir);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,13 @@ static void walModuleInitFunc() {
|
|||
wDebug("WAL module is initialized");
|
||||
}
|
||||
|
||||
static inline bool walNeedFsyncTimer(SWal *pWal) {
|
||||
if (pWal->fsyncPeriod > 0 && pWal->level == TAOS_WAL_FSYNC) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void *walOpen(const char *path, const SWalCfg *pCfg) {
|
||||
SWal *pWal = calloc(sizeof(SWal), 1);
|
||||
if (pWal == NULL) {
|
||||
|
@ -95,7 +102,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
|
|||
tstrncpy(pWal->path, path, sizeof(pWal->path));
|
||||
pthread_mutex_init(&pWal->mutex, NULL);
|
||||
|
||||
if (pWal->fsyncPeriod > 0 && pWal->level == TAOS_WAL_FSYNC) {
|
||||
if (walNeedFsyncTimer(pWal)) {
|
||||
pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl);
|
||||
if (pWal->timer == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
|
@ -127,6 +134,37 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
|
|||
return pWal;
|
||||
}
|
||||
|
||||
int walAlter(twalh wal, const SWalCfg *pCfg) {
|
||||
SWal *pWal = wal;
|
||||
if (pWal == NULL) {
|
||||
return TSDB_CODE_WAL_APP_ERROR;
|
||||
}
|
||||
|
||||
if (pWal->level == pCfg->walLevel && pWal->fsyncPeriod == pCfg->fsyncPeriod) {
|
||||
wDebug("wal:%s, old walLevel:%d fsync:%d, new walLevel:%d fsync:%d not change", pWal->name, pWal->level,
|
||||
pWal->fsyncPeriod, pCfg->walLevel, pCfg->fsyncPeriod);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
wInfo("wal:%s, change old walLevel:%d fsync:%d, new walLevel:%d fsync:%d", pWal->name, pWal->level, pWal->fsyncPeriod,
|
||||
pCfg->walLevel, pCfg->fsyncPeriod);
|
||||
|
||||
pthread_mutex_lock(&pWal->mutex);
|
||||
pWal->level = pCfg->walLevel;
|
||||
pWal->fsyncPeriod = pCfg->fsyncPeriod;
|
||||
if (walNeedFsyncTimer(pWal)) {
|
||||
wInfo("wal:%s, reset fsync timer, walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod);
|
||||
taosTmrReset(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, &pWal->timer,walTmrCtrl);
|
||||
} else {
|
||||
wInfo("wal:%s, stop fsync timer, walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod);
|
||||
taosTmrStop(pWal->timer);
|
||||
pWal->timer = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&pWal->mutex);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
void walClose(void *handle) {
|
||||
if (handle == NULL) return;
|
||||
|
||||
|
@ -484,6 +522,12 @@ static void walProcessFsyncTimer(void *param, void *tmrId) {
|
|||
if (fsync(pWal->fd) < 0) {
|
||||
wError("wal:%s, fsync failed(%s)", pWal->name, strerror(errno));
|
||||
}
|
||||
|
||||
pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl);
|
||||
|
||||
if (walNeedFsyncTimer(pWal)) {
|
||||
pWal->timer = taosTmrStart(walProcessFsyncTimer, pWal->fsyncPeriod, pWal, walTmrCtrl);
|
||||
} else {
|
||||
wInfo("wal:%s, stop fsync timer for walLevel:%d fsyncPeriod:%d", pWal->name, pWal->level, pWal->fsyncPeriod);
|
||||
taosTmrStop(pWal->timer);
|
||||
pWal->timer = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,10 @@ if $data12_db != 1 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql_error alter database db wal 2
|
||||
sql alter database db wal 1
|
||||
sql alter database db wal 2
|
||||
sql alter database db wal 1
|
||||
sql alter database db wal 2
|
||||
sql_error alter database db wal 0
|
||||
sql_error alter database db wal 3
|
||||
sql_error alter database db wal 4
|
||||
|
@ -226,11 +229,13 @@ sql_error alter database db wal -1
|
|||
sql_error alter database db wal 1000
|
||||
|
||||
print ============== step fsync
|
||||
sql_error alter database db fsync 2
|
||||
sql_error alter database db fsync 3
|
||||
sql_error alter database db fsync 4
|
||||
sql alter database db fsync 0
|
||||
sql alter database db fsync 1
|
||||
sql alter database db fsync 3600
|
||||
sql alter database db fsync 18000
|
||||
sql alter database db fsync 180000
|
||||
sql_error alter database db fsync 180001
|
||||
sql_error alter database db fsync -1
|
||||
sql_error alter database db fsync 1000
|
||||
|
||||
print ============== step comp
|
||||
sql show databases
|
||||
|
|
Loading…
Reference in New Issue