Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0a3b4046
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
0a3b4046
编写于
10月 27, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add audit db for DDL storage
上级
09261647
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
35 deletion
+35
-35
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+35
-35
未找到文件。
src/mnode/src/mnodeDb.c
浏览文件 @
0a3b4046
...
...
@@ -160,7 +160,7 @@ static int32_t mnodeDbActionEncode(SSdbRow *pRow) {
static
int32_t
mnodeDbActionDecode
(
SSdbRow
*
pRow
)
{
SDbObj
*
pDb
=
(
SDbObj
*
)
calloc
(
1
,
sizeof
(
SDbObj
));
if
(
pDb
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
memcpy
(
pDb
,
pRow
->
rowData
,
tsDbUpdateSize
);
pRow
->
pObj
=
pDb
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -205,8 +205,8 @@ int32_t mnodeInitDbs() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeGetDbMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeRetrieveDbs
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeCancelGetNextDb
);
mDebug
(
"table:dbs table is created"
);
return
tpInit
();
}
...
...
@@ -224,11 +224,11 @@ SDbObj *mnodeGetDb(char *db) {
}
void
mnodeIncDbRef
(
SDbObj
*
pDb
)
{
sdbIncRef
(
tsDbSdb
,
pDb
);
sdbIncRef
(
tsDbSdb
,
pDb
);
}
void
mnodeDecDbRef
(
SDbObj
*
pDb
)
{
sdbDecRef
(
tsDbSdb
,
pDb
);
void
mnodeDecDbRef
(
SDbObj
*
pDb
)
{
sdbDecRef
(
tsDbSdb
,
pDb
);
}
SDbObj
*
mnodeGetDbByTableName
(
char
*
tableName
)
{
...
...
@@ -420,7 +420,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
SDbObj
*
pDb
=
mnodeGetDb
(
pCreate
->
db
);
if
(
pDb
!=
NULL
)
{
mnodeDecDbRef
(
pDb
);
mnodeDecDbRef
(
pDb
);
if
(
pCreate
->
ignoreExist
)
{
mDebug
(
"db:%s, already exist, ignore exist is set"
,
pCreate
->
db
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -435,8 +435,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
pDb
=
calloc
(
1
,
sizeof
(
SDbObj
));
tstrncpy
(
pDb
->
name
,
pCreate
->
db
,
sizeof
(
pDb
->
name
));
tstrncpy
(
pDb
->
acct
,
pAcct
->
user
,
sizeof
(
pDb
->
acct
));
pDb
->
createdTime
=
taosGetTimestampMs
();
tstrncpy
(
pDb
->
acct
,
pAcct
->
user
,
sizeof
(
pDb
->
acct
));
pDb
->
createdTime
=
taosGetTimestampMs
();
pDb
->
cfg
=
(
SDbCfg
)
{
.
cacheBlockSize
=
pCreate
->
cacheBlockSize
,
.
totalBlocks
=
pCreate
->
totalBlocks
,
...
...
@@ -500,7 +500,7 @@ bool mnodeCheckIsMonitorDB(char *db, char *monitordb) {
#if 0
void mnodePrintVgroups(SDbObj *pDb, char *row) {
mInfo("db:%s, vgroup link from head, row:%s", pDb->name, row);
mInfo("db:%s, vgroup link from head, row:%s", pDb->name, row);
SVgObj *pVgroup = pDb->pHead;
while (pVgroup != NULL) {
mInfo("vgId:%d", pVgroup->vgId);
...
...
@@ -622,7 +622,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
pShow
->
bytes
[
cols
]
=
24
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
#ifdef _STORAGE
#ifdef _STORAGE
strcpy
(
pSchema
[
cols
].
name
,
"keep0,keep1,keep2"
);
#else
strcpy
(
pSchema
[
cols
].
name
,
"keep"
);
...
...
@@ -639,13 +639,13 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
strcpy
(
pSchema
[
cols
].
name
,
"cache(MB)"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"blocks"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"minrows"
);
...
...
@@ -744,7 +744,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
name
=
mnodeGetDbStr
(
pDb
->
name
);
if
(
name
!=
NULL
)
{
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
name
,
pShow
->
bytes
[
cols
]);
...
...
@@ -790,10 +790,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
#endif
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
tmp
[
128
]
=
{
0
};
#ifdef _STORAGE
if
(
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep1
||
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep2
)
{
#ifdef _STORAGE
if
(
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep1
||
pDb
->
cfg
.
daysToKeep0
>
pDb
->
cfg
.
daysToKeep2
)
{
sprintf
(
tmp
,
"%d,%d,%d"
,
pDb
->
cfg
.
daysToKeep1
,
pDb
->
cfg
.
daysToKeep2
,
pDb
->
cfg
.
daysToKeep0
);
}
else
{
sprintf
(
tmp
,
"%d,%d,%d"
,
pDb
->
cfg
.
daysToKeep0
,
pDb
->
cfg
.
daysToKeep1
,
pDb
->
cfg
.
daysToKeep2
);
...
...
@@ -822,7 +822,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
pDb
->
cfg
.
maxRowsPerFileBlock
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int8_t
*
)
pWrite
=
pDb
->
cfg
.
walLevel
;
cols
++
;
...
...
@@ -913,7 +913,7 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb) {
}
static
int32_t
mnodeProcessCreateDbMsg
(
SMnodeMsg
*
pMsg
)
{
SCreateDbMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCreateDbMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
pCreate
->
maxTables
=
htonl
(
pCreate
->
maxTables
);
pCreate
->
cacheBlockSize
=
htonl
(
pCreate
->
cacheBlockSize
);
pCreate
->
totalBlocks
=
htonl
(
pCreate
->
totalBlocks
);
...
...
@@ -926,7 +926,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) {
pCreate
->
partitions
=
htons
(
pCreate
->
partitions
);
pCreate
->
minRowsPerFileBlock
=
htonl
(
pCreate
->
minRowsPerFileBlock
);
pCreate
->
maxRowsPerFileBlock
=
htonl
(
pCreate
->
maxRowsPerFileBlock
);
int32_t
code
;
#ifdef GRANT_CHECK_WRITE
if
(
grantCheck
(
TSDB_GRANT_TIME
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -964,7 +964,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
int8_t
cacheLastRow
=
pAlter
->
cacheLastRow
;
int8_t
dbType
=
pAlter
->
dbType
;
int16_t
partitions
=
htons
(
pAlter
->
partitions
);
terrno
=
TSDB_CODE_SUCCESS
;
//UPGRATE FROM LOW VERSION, reorder it
...
...
@@ -1198,7 +1198,7 @@ int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
mError
(
"db:%s, failed to alter, invalid db"
,
pAlter
->
db
);
return
TSDB_CODE_MND_INVALID_DB
;
}
if
(
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping"
,
pAlter
->
db
,
pMsg
->
pDb
->
status
);
return
TSDB_CODE_MND_DB_IN_DROPPING
;
...
...
@@ -1220,7 +1220,7 @@ static int32_t mnodeDropDbCb(SMnodeMsg *pMsg, int32_t code) {
static
int32_t
mnodeDropDb
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
mInfo
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
...
...
@@ -1260,7 +1260,7 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) {
mError("db:%s, can't drop monitor database", pDrop->db);
return TSDB_CODE_MND_MONITOR_DB_FORBIDDEN;
}
#endif
#endif
int32_t
code
=
mnodeSetDbDropping
(
pMsg
->
pDb
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
...
...
@@ -1293,15 +1293,15 @@ static int32_t mnodeSyncDb(SDbObj *pDb, SMnodeMsg *pMsg) {
static
int32_t
mnodeCompact
(
SDbObj
*
pDb
,
SCompactMsg
*
pCompactMsg
)
{
int32_t
count
=
ntohs
(
pCompactMsg
->
numOfVgroup
);
int32_t
*
buf
=
malloc
(
sizeof
(
int32_t
)
*
count
);
int32_t
count
=
ntohs
(
pCompactMsg
->
numOfVgroup
);
int32_t
*
buf
=
malloc
(
sizeof
(
int32_t
)
*
count
);
if
(
buf
==
NULL
)
{
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
buf
[
i
]
=
ntohs
(
pCompactMsg
->
vgid
[
i
]);
}
// copy from mnodeSyncDb, so ugly
for
(
int32_t
i
=
0
;
i
<
count
;
i
++
)
{
SVgObj
*
pVgroup
=
NULL
;
...
...
@@ -1313,7 +1313,7 @@ static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) {
if
(
pVgroup
->
pDb
==
pDb
&&
pVgroup
->
vgId
==
buf
[
i
])
{
mnodeSendCompactVgroupMsg
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
valid
=
true
;
valid
=
true
;
break
;
}
mnodeDecVgroupRef
(
pVgroup
);
...
...
@@ -1322,7 +1322,7 @@ static int32_t mnodeCompact(SDbObj *pDb, SCompactMsg *pCompactMsg) {
mLError
(
"db:%s, cannot find valid vgId: %d"
,
pDb
->
name
,
buf
[
i
]);
}
}
free
(
buf
);
free
(
buf
);
mLInfo
(
"db:%s, trigger compact"
,
pDb
->
name
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1353,14 +1353,14 @@ static int32_t mnodeProcessSyncDbMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeProcessCompactMsg
(
SMnodeMsg
*
pMsg
)
{
SCompactMsg
*
pCompact
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"db:%s, compact is received from thandle:%p"
,
pCompact
->
db
,
pMsg
->
rpcMsg
.
handle
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDb
(
pCompact
->
db
);
if
(
pMsg
->
pDb
==
NULL
)
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
if
(
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"db:%s, status:%d, in dropping, ignore compact request"
,
pCompact
->
db
,
pMsg
->
pDb
->
status
);
return
TSDB_CODE_MND_DB_IN_DROPPING
;
}
}
return
mnodeCompact
(
pMsg
->
pDb
,
pCompact
);
}
...
...
@@ -1383,7 +1383,7 @@ void mnodeDropAllDbs(SAcctObj *pAcct) {
.
pTable
=
tsDbSdb
,
.
pObj
=
pDb
};
sdbDeleteRow
(
&
row
);
numOfDbs
++
;
}
...
...
@@ -1411,11 +1411,11 @@ int32_t mnodeCompactDbs() {
};
mInfo
(
"compact dbs %s"
,
pDb
->
name
);
sdbInsertCompactRow
(
&
row
);
}
mInfo
(
"end to compact dbs table..."
);
return
0
;
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录