Skip to content

Commit

Permalink
Merge branch 'main' into merge/mainto3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guanshengliang committed Dec 21, 2024
2 parents bdbb0bb + d02e9b0 commit 3ac820e
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 8 deletions.
Binary file modified docs/zh/26-tdinternal/aggquery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/zh/26-tdinternal/cache.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/zh/26-tdinternal/compression.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/zh/26-tdinternal/streamarch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/zh/26-tdinternal/streamtask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/zh/26-tdinternal/taskarch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions include/common/tglobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ void printConfigNotMatch(SArray *array);

int32_t compareSConfigItemArrays(SArray *mArray, const SArray *dArray, SArray *diffArray);
bool isConifgItemLazyMode(SConfigItem *item);
int32_t taosUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs);

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions include/libs/tfs/tfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,15 @@ bool tfsDiskSpaceAvailable(STfs *pTfs, int32_t level);
*/
bool tfsDiskSpaceSufficient(STfs *pTfs, int32_t level, int32_t disk);

/**
* @brief Update disk size of tfs.
*
* @param pTfs The fs object.
* @param dir The directory.
* @param disable The disable flag.
*/
int32_t tfsUpdateDiskDisable(STfs *pTfs, const char *dir, int8_t disable);

#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 14 additions & 0 deletions source/common/src/tglobal.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,16 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
int32_t taosSetTfsCfg(SConfig *pCfg);
#endif

#ifndef _STORAGE
int32_t cfgUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs) { return TSDB_CODE_INVALID_CFG; }
#else
int32_t cfgUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs);
#endif

int32_t taosUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs) {
return cfgUpdateTfsItemDisable(pCfg, value, pTfs);
}

static int32_t taosSplitS3Cfg(SConfig *pCfg, const char *name, char gVarible[TSDB_MAX_EP_NUM][TSDB_FQDN_LEN],
int8_t *pNum) {
int32_t code = TSDB_CODE_SUCCESS;
Expand Down Expand Up @@ -2389,6 +2399,10 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
code = TSDB_CODE_SUCCESS;
goto _exit;
}
if (strcasecmp(name, "dataDir") == 0) {
code = TSDB_CODE_SUCCESS;
goto _exit;
}

{ // 'bool/int32_t/int64_t/float/double' variables with general modification function
static OptionNameAndVar debugOptions[] = {
Expand Down
1 change: 1 addition & 0 deletions source/dnode/mgmt/mgmt_dnode/inc/dmInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern "C" {
typedef struct SDnodeMgmt {
SDnodeData *pData;
SMsgCb msgCb;
STfs *pTfs;
const char *path;
const char *name;
TdThread statusThread;
Expand Down
9 changes: 6 additions & 3 deletions source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,19 +499,22 @@ static int32_t dmAlterMaxCompactTask(const char *value) {
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t code = 0;
SDCfgDnodeReq cfgReq = {0};
SConfig *pCfg = taosGetCfg();
SConfigItem *pItem = NULL;

if (tDeserializeSDCfgDnodeReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) {
return TSDB_CODE_INVALID_MSG;
}
if (strcasecmp(cfgReq.config, "dataDir") == 0) {
return taosUpdateTfsItemDisable(pCfg, cfgReq.value, pMgmt->pTfs);
}

if (strncmp(cfgReq.config, tsAlterCompactTaskKeywords, strlen(tsAlterCompactTaskKeywords) + 1) == 0) {
return dmAlterMaxCompactTask(cfgReq.value);
}

dInfo("start to config, option:%s, value:%s", cfgReq.config, cfgReq.value);

SConfig *pCfg = taosGetCfg();
SConfigItem *pItem = NULL;

code = cfgGetAndSetItem(pCfg, &pItem, cfgReq.config, cfgReq.value, CFG_STYPE_ALTER_SERVER_CMD, true);
if (code != 0) {
if (strncasecmp(cfgReq.config, "resetlog", strlen("resetlog")) == 0) {
Expand Down
1 change: 1 addition & 0 deletions source/dnode/mgmt/mgmt_dnode/src/dmInt.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static int32_t dmOpenMgmt(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {

pMgmt->pData = pInput->pData;
pMgmt->msgCb = pInput->msgCb;
pMgmt->pTfs = pInput->pTfs;
pMgmt->path = pInput->path;
pMgmt->name = pInput->name;
pMgmt->processCreateNodeFp = pInput->processCreateNodeFp;
Expand Down
19 changes: 19 additions & 0 deletions source/libs/tfs/src/tfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,22 @@ int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) {

TAOS_RETURN(0);
}

int32_t tfsUpdateDiskDisable(STfs *pTfs, const char *dir, int8_t disable) {
TAOS_UNUSED(tfsLock(pTfs));
for (int32_t level = 0; level < pTfs->nlevel; level++) {
STfsTier *pTier = &pTfs->tiers[level];
for (int32_t disk = 0; disk < pTier->ndisk; ++disk) {
STfsDisk *pDisk = pTier->disks[disk];
if (strcmp(pDisk->path, dir) == 0) {
pDisk->disable = disable;
TAOS_UNUSED(tfsUnLock(pTfs));
fInfo("disk %s is %s", dir, disable ? "disabled" : "enabled");
TAOS_RETURN(TSDB_CODE_SUCCESS);
}
}
}
TAOS_UNUSED(tfsUnLock(pTfs));
fError("failed to update disk disable since %s not found", dir);
TAOS_RETURN(TSDB_CODE_FS_NO_VALID_DISK);
}
8 changes: 5 additions & 3 deletions source/util/src/tconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,13 @@ int32_t cfgGetAndSetItem(SConfig *pCfg, SConfigItem **pItem, const char *name, c

*pItem = cfgGetItem(pCfg, name);
if (*pItem == NULL) {
(void)taosThreadMutexUnlock(&pCfg->lock);
TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND);
code = TSDB_CODE_CFG_NOT_FOUND;
goto _exit;
}
TAOS_CHECK_RETURN(cfgSetItemVal(*pItem, name, value, stype));

TAOS_CHECK_GOTO(cfgSetItemVal(*pItem, name, value, stype), NULL, _exit);

_exit:
if (lock) {
(void)taosThreadMutexUnlock(&pCfg->lock);
}
Expand Down
53 changes: 51 additions & 2 deletions tests/system-test/0-others/multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,55 @@ def trim_database(self):
checkFiles('/mnt/data3/vnode/*/tsdb/v*',0)
checkFiles('/mnt/data4/vnode/*/tsdb/v*',1)

def test_alter_disable_err_case(self):
tdLog.info("============== test_alter_disable_err_case test ===============")
tdDnodes.stop(1)
cfg={
'/mnt/data1 0 1 1' : 'dataDir',
'/mnt/data2 0 0 0' : 'dataDir'
}
tdSql.createDir('/mnt/data1')
tdSql.createDir('/mnt/data2')
tdDnodes.deploy(1,cfg)
tdDnodes.start(1)

tdSql.execute('alter dnode 1 "dataDir /mnt/data2 1"')
tdSql.error('alter dnode 1 "dataDir /mnt/errpath 1"')
tdSql.error('alter dnode 1 "dataDir /mnt/data2 3"')
tdSql.error('alter dnode 1 "dataDir /mnt/data2 ee"')

def test_alter_disable_case(self):
tdLog.info("============== test_alter_disable_case test ===============")
tdDnodes.stop(1)
cfg={
'/mnt/data1 0 1 1' : 'dataDir',
'/mnt/data2 0 0 0' : 'dataDir',
'/mnt/data3 0 0 0' : 'dataDir'
}
tdSql.createDir('/mnt/data1')
tdSql.createDir('/mnt/data2')
tdSql.createDir('/mnt/data3')
tdDnodes.deploy(1,cfg)
tdDnodes.start(1)

tdSql.execute('create database dbtest duration 3')
tdSql.execute('use dbtest')
tdSql.execute('create table stb (ts timestamp,c0 int) tags(t0 int)')
tdSql.execute('create table tb1 using stb tags(1)')
for i in range(1,600, 30):
tdSql.execute(f'insert into tb1 values(now-{i}d,10)')
tdSql.execute('flush database dbtest')

tdSql.execute('alter dnode 1 "dataDir /mnt/data2 1"')

tdSql.execute('create database dbtest1 duration 3')
tdSql.execute('use dbtest1')
tdSql.execute('create table stb (ts timestamp,c0 int) tags(t0 int)')
tdSql.execute('create table tb1 using stb tags(1)')
for i in range(1,600, 30):
tdSql.execute(f'insert into tb1 values(now-{i}d,10)')
tdSql.execute('flush database dbtest1')

def run(self):
self.basic()
self.dir_not_exist()
Expand All @@ -297,8 +346,8 @@ def run(self):
self.trim_database()
self.missing_middle_level()
self.disable_create_new_file()


self.test_alter_disable_err_case()
self.test_alter_disable_case()

def stop(self):
tdSql.close()
Expand Down

0 comments on commit 3ac820e

Please sign in to comment.