TD-13101
This commit is contained in:
parent
af9178c527
commit
c978eb12ff
|
@ -540,35 +540,41 @@ static int32_t mndRetrieveVgroups(SMnodeMsg *pReq, SShowObj *pShow, char *data,
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
char *pWrite;
|
char *pWrite;
|
||||||
|
|
||||||
|
SDbObj *pDb = mndAcquireDb(pMnode, pShow->db);
|
||||||
|
if (pDb == NULL) return 0;
|
||||||
|
|
||||||
while (numOfRows < rows) {
|
while (numOfRows < rows) {
|
||||||
pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup);
|
pShow->pIter = sdbFetch(pSdb, SDB_VGROUP, pShow->pIter, (void **)&pVgroup);
|
||||||
if (pShow->pIter == NULL) break;
|
if (pShow->pIter == NULL) break;
|
||||||
|
|
||||||
cols = 0;
|
if (pVgroup->dbUid == pDb->uid) {
|
||||||
|
cols = 0;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
*(int32_t *)pWrite = pVgroup->vgId;
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
|
||||||
*(int32_t *)pWrite = pVgroup->numOfTables;
|
|
||||||
cols++;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < pShow->replica; ++i) {
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
*(int16_t *)pWrite = pVgroup->vnodeGid[i].dnodeId;
|
*(int32_t *)pWrite = pVgroup->vgId;
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
const char *role = mndGetRoleStr(pVgroup->vnodeGid[i].role);
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]);
|
*(int32_t *)pWrite = pVgroup->numOfTables;
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < pShow->replica; ++i) {
|
||||||
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
*(int16_t *)pWrite = pVgroup->vnodeGid[i].dnodeId;
|
||||||
|
cols++;
|
||||||
|
|
||||||
|
const char *role = mndGetRoleStr(pVgroup->vnodeGid[i].role);
|
||||||
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
STR_WITH_MAXSIZE_TO_VARSTR(pWrite, role, pShow->bytes[cols]);
|
||||||
|
cols++;
|
||||||
|
}
|
||||||
|
numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbRelease(pSdb, pVgroup);
|
sdbRelease(pSdb, pVgroup);
|
||||||
numOfRows++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mndReleaseDb(pMnode, pDb);
|
||||||
mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow);
|
mndVacuumResult(data, pShow->numOfColumns, numOfRows, rows, pShow);
|
||||||
pShow->numOfReads += numOfRows;
|
pShow->numOfReads += numOfRows;
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
|
|
|
@ -60,6 +60,7 @@ TEST_F(TfsTest, 02_AllocDisk) {
|
||||||
dCfg.level = 0;
|
dCfg.level = 0;
|
||||||
dCfg.primary = 1;
|
dCfg.primary = 1;
|
||||||
|
|
||||||
|
taosRemoveDir(root);
|
||||||
taosMkDir(root);
|
taosMkDir(root);
|
||||||
STfs *pTfs = tfsOpen(&dCfg, 1);
|
STfs *pTfs = tfsOpen(&dCfg, 1);
|
||||||
ASSERT_NE(pTfs, nullptr);
|
ASSERT_NE(pTfs, nullptr);
|
||||||
|
@ -110,6 +111,7 @@ TEST_F(TfsTest, 03_Dir) {
|
||||||
dCfg.level = 0;
|
dCfg.level = 0;
|
||||||
dCfg.primary = 1;
|
dCfg.primary = 1;
|
||||||
|
|
||||||
|
taosRemoveDir(root);
|
||||||
taosMkDir(root);
|
taosMkDir(root);
|
||||||
STfs *pTfs = tfsOpen(&dCfg, 1);
|
STfs *pTfs = tfsOpen(&dCfg, 1);
|
||||||
ASSERT_NE(pTfs, nullptr);
|
ASSERT_NE(pTfs, nullptr);
|
||||||
|
@ -130,7 +132,7 @@ TEST_F(TfsTest, 03_Dir) {
|
||||||
EXPECT_EQ(taosDirExist(ap2), 0);
|
EXPECT_EQ(taosDirExist(ap2), 0);
|
||||||
|
|
||||||
char p3[] = "p3/p2/p1/p0";
|
char p3[] = "p3/p2/p1/p0";
|
||||||
char ap3[128] ={0};
|
char ap3[128] = {0};
|
||||||
snprintf(ap3, 128, "%s%s%s", root, TD_DIRSEP, p3);
|
snprintf(ap3, 128, "%s%s%s", root, TD_DIRSEP, p3);
|
||||||
EXPECT_NE(taosDirExist(ap3), 0);
|
EXPECT_NE(taosDirExist(ap3), 0);
|
||||||
EXPECT_NE(tfsMkdir(pTfs, p3), 0);
|
EXPECT_NE(tfsMkdir(pTfs, p3), 0);
|
||||||
|
@ -156,3 +158,42 @@ TEST_F(TfsTest, 03_Dir) {
|
||||||
|
|
||||||
tfsClose(pTfs);
|
tfsClose(pTfs);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
TEST_F(TfsTest, 04_File) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SDiskCfg dCfg = {0};
|
||||||
|
tstrncpy(dCfg.dir, root, TSDB_FILENAME_LEN);
|
||||||
|
dCfg.level = 0;
|
||||||
|
dCfg.primary = 1;
|
||||||
|
|
||||||
|
taosRemoveDir(root);
|
||||||
|
taosMkDir(root);
|
||||||
|
STfs *pTfs = tfsOpen(&dCfg, 1);
|
||||||
|
ASSERT_NE(pTfs, nullptr);
|
||||||
|
|
||||||
|
STfsFile file0;
|
||||||
|
STfsFile file1;
|
||||||
|
STfsFile file2;
|
||||||
|
STfsFile file3;
|
||||||
|
STfsFile file4;
|
||||||
|
SDiskID did0 = {0};
|
||||||
|
SDiskID did1 = {0};
|
||||||
|
SDiskID did2 = {0};
|
||||||
|
SDiskID did3 = {0};
|
||||||
|
SDiskID did4 = {0};
|
||||||
|
did3.id = 1;
|
||||||
|
did4.level = 1;
|
||||||
|
tfsInitFile(pTfs, &file0, did0, "fname");
|
||||||
|
tfsInitFile(pTfs, &file1, did1, "fname");
|
||||||
|
tfsInitFile(pTfs, &file2, did2, "fnamex");
|
||||||
|
tfsInitFile(pTfs, &file3, did3, "fname");
|
||||||
|
tfsInitFile(pTfs, &file4, did4, "fname");
|
||||||
|
|
||||||
|
EXPECT_TRUE(tfsIsSameFile(&file0, &file1));
|
||||||
|
EXPECT_FALSE(tfsIsSameFile(&file0, &file2));
|
||||||
|
EXPECT_FALSE(tfsIsSameFile(&file0, &file3));
|
||||||
|
EXPECT_FALSE(tfsIsSameFile(&file0, &file4));
|
||||||
|
|
||||||
|
tfsClose(pTfs);
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -4,7 +4,7 @@ system sh/exec.sh -n dnode1 -s start
|
||||||
sql connect
|
sql connect
|
||||||
|
|
||||||
print =============== create database
|
print =============== create database
|
||||||
sql create database d1
|
sql create database d1 vgroups 2
|
||||||
sql show databases
|
sql show databases
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
|
@ -22,6 +22,21 @@ if $data03 != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print =============== show vgroups1
|
||||||
|
sql use d1
|
||||||
|
sql show vgroups
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
print =============== drop database
|
print =============== drop database
|
||||||
sql drop database d1
|
sql drop database d1
|
||||||
sql show databases
|
sql show databases
|
||||||
|
@ -30,14 +45,68 @@ if $rows != 0 then
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print =============== more databases
|
print =============== more databases
|
||||||
sql create database d2
|
sql create database d2 vgroups 2
|
||||||
sql create database d3
|
sql create database d3 vgroups 3
|
||||||
sql create database d4
|
sql create database d4 vgroups 4
|
||||||
sql show databases
|
sql show databases
|
||||||
if $rows != 3 then
|
if $rows != 3 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print =============== show vgroups2
|
||||||
|
sql show d2.vgroups
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== show vgroups3
|
||||||
|
sql show d3.vgroups
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 6 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 7 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data20 != 8 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
print =============== show vgroups4
|
||||||
|
sql show d4.vgroups
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data00 != 9 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data10 != 10 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data20 != 11 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
if $data30 != 12 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
print =============== drop database
|
print =============== drop database
|
||||||
sql drop database d2
|
sql drop database d2
|
||||||
sql drop database d3
|
sql drop database d3
|
||||||
|
@ -50,7 +119,7 @@ if $data00 != d4 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
if $data02 != 2 then
|
if $data02 != 4 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -58,19 +127,12 @@ if $data03 != 0 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
print =============== show vgroups
|
print =============== show vgroups4 again
|
||||||
sql show databases
|
|
||||||
|
|
||||||
if $rows != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql_error use d1
|
sql_error use d1
|
||||||
|
|
||||||
sql use d4
|
sql use d4
|
||||||
sql show vgroups
|
sql show vgroups
|
||||||
|
if $rows != 4 then
|
||||||
if $rows != 2 then
|
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -81,15 +143,16 @@ if $data00 != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
if $data02 != 2 then
|
if $data02 != 4 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
print =============== restart
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
system sh/exec.sh -n dnode1 -s stop -x SIGKILL
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
|
|
||||||
sql show databases
|
sql show databases
|
||||||
|
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
@ -99,7 +162,24 @@ sql_error use d1
|
||||||
sql use d4
|
sql use d4
|
||||||
sql show vgroups
|
sql show vgroups
|
||||||
|
|
||||||
if $rows != 2 then
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql create database d5 vgroups 5;
|
||||||
|
sql use d5
|
||||||
|
sql show vgroups
|
||||||
|
if $rows != 5 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql show d4.vgroups
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql show d5.vgroups
|
||||||
|
if $rows != 5 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,8 @@ sql use $db
|
||||||
sql create table st (ts timestamp, i int) tags (j int)
|
sql create table st (ts timestamp, i int) tags (j int)
|
||||||
sql create table $tb using st tags(1)
|
sql create table $tb using st tags(1)
|
||||||
|
|
||||||
return
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
|
return
|
||||||
|
|
||||||
sql show tables
|
sql show tables
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
|
|
Loading…
Reference in New Issue