Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5f5d72b2
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5f5d72b2
编写于
10月 27, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add audit db for DDL storage
上级
0a3b4046
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
27 deletion
+49
-27
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+5
-5
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+4
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+27
-8
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+13
-13
未找到文件。
src/mnode/inc/mnodeDef.h
浏览文件 @
5f5d72b2
...
...
@@ -57,7 +57,7 @@ typedef struct SDnodeObj {
int8_t
alternativeRole
;
// from dnode status msg, 0-any, 1-mgmt, 2-dnode
int8_t
status
;
// set in balance function
int8_t
isMgmt
;
int8_t
reserve1
[
11
];
int8_t
reserve1
[
11
];
int8_t
updateEnd
[
4
];
int32_t
refCount
;
uint32_t
moduleStatus
;
...
...
@@ -90,7 +90,7 @@ typedef struct STableObj {
}
STableObj
;
typedef
struct
SSTableObj
{
STableObj
info
;
STableObj
info
;
int8_t
reserved0
[
9
];
// for fill struct STableObj to 4byte align
int16_t
nextColId
;
int32_t
sversion
;
...
...
@@ -107,10 +107,10 @@ typedef struct SSTableObj {
}
SSTableObj
;
typedef
struct
{
STableObj
info
;
STableObj
info
;
int8_t
reserved0
[
9
];
// for fill struct STableObj to 4byte align
int16_t
nextColId
;
//used by normal table
int32_t
sversion
;
//used by normal table
int32_t
sversion
;
//used by normal table
uint64_t
uid
;
uint64_t
suid
;
int64_t
createdTime
;
...
...
@@ -195,7 +195,7 @@ typedef struct SDbObj {
int32_t
numOfVgroups
;
int32_t
numOfTables
;
int32_t
numOfSuperTables
;
int32_t
vgListSize
;
int32_t
vgListSize
;
int32_t
vgListIndex
;
SVgObj
**
vgList
;
struct
SAcctObj
*
pAcct
;
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
5f5d72b2
...
...
@@ -1128,6 +1128,8 @@ static int32_t mnodeAlterDbFp(SMnodeMsg *pMsg) {
mDebug
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mLInfo
(
"db:%s, is alterd by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
monSaveAuditLog
(
MON_DDL_CMD_ALTER_DATABASE
,
mnodeGetUserFromMsg
(
pMsg
),
pDb
->
name
,
true
);
// in case there is no vnode for this db currently(no table in db,etc.)
if
(
pMsg
->
expected
==
0
)
{
SSdbRow
row
=
{
...
...
@@ -1184,7 +1186,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to alter, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
}
}
return
code
;
}
...
...
@@ -1214,6 +1216,7 @@ static int32_t mnodeDropDbCb(SMnodeMsg *pMsg, int32_t code) {
}
else
{
mLInfo
(
"db:%s, is dropped by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
}
monSaveAuditLog
(
MON_DDL_CMD_DROP_DATABASE
,
mnodeGetUserFromMsg
(
pMsg
),
pDb
->
name
,
!
code
);
return
code
;
}
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
5f5d72b2
...
...
@@ -38,6 +38,7 @@
#include "mnodeSdb.h"
#include "mnodeShow.h"
#include "mnodeTable.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeWrite.h"
#include "mnodeRead.h"
...
...
@@ -1047,7 +1048,7 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLInfo
(
"stable:%s, is created in sdb, uid:%"
PRIu64
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
if
(
pMsg
->
pBatchMasterMsg
)
pMsg
->
pBatchMasterMsg
->
successed
++
;
pMsg
->
pBatchMasterMsg
->
successed
++
;
}
else
{
mError
(
"msg:%p, app:%p stable:%s, failed to create in sdb, reason:%s"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
,
tstrerror
(
code
));
...
...
@@ -1056,11 +1057,12 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
pMsg
->
pBatchMasterMsg
)
pMsg
->
pBatchMasterMsg
->
received
++
;
}
monSaveAuditLog
(
MON_DDL_CMD_CREATE_SUPER_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
!
code
);
// if super table create by batch msg, check done and send finished to client
if
(
pMsg
->
pBatchMasterMsg
)
{
if
(
pMsg
->
pBatchMasterMsg
->
successed
+
pMsg
->
pBatchMasterMsg
->
received
>=
pMsg
->
pBatchMasterMsg
->
expected
)
dnodeSendRpcMWriteRsp
(
pMsg
->
pBatchMasterMsg
,
code
);
dnodeSendRpcMWriteRsp
(
pMsg
->
pBatchMasterMsg
,
code
);
}
return
code
;
...
...
@@ -1171,11 +1173,12 @@ static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
SSTableObj
*
pTable
=
(
SSTableObj
*
)
pMsg
->
pTable
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"msg:%p, app:%p stable:%s, failed to drop, sdb error"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_SUPER_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
code
;
}
mLInfo
(
"msg:%p, app:%p stable:%s, is dropped from sdb"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_SUPER_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SSTableObj
*
pStable
=
(
SSTableObj
*
)
pMsg
->
pTable
;
if
(
pStable
->
vgHash
!=
NULL
/*pStable->numOfTables != 0*/
)
{
...
...
@@ -1250,6 +1253,8 @@ static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_ADD_TAG
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1308,6 +1313,8 @@ static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_DROP_TAG
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1345,6 +1352,8 @@ static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_CHANGE_TAG
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1403,6 +1412,8 @@ static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_ADD_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1474,6 +1485,8 @@ static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_DROP_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -1522,6 +1535,8 @@ static int32_t mnodeChangeSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
mnodeGetSuperTableMeta
(
pMsg
);
}
monSaveAuditLog
(
MON_DDL_CMD_MODIFY_COLUMN
,
mnodeGetUserFromMsg
(
pMsg
),
pStable
->
info
.
tableId
,
!
code
);
return
code
;
}
...
...
@@ -2294,6 +2309,7 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
if
(
pDrop
==
NULL
)
{
mError
(
"msg:%p, app:%p ctable:%s, failed to drop ctable, no enough memory"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
...
...
@@ -2308,6 +2324,8 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
mInfo
(
"msg:%p, app:%p ctable:%s, send drop ctable msg, vgId:%d sid:%d uid:%"
PRIu64
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pDrop
->
tableFname
,
pTable
->
vgId
,
pTable
->
tid
,
pTable
->
uid
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
true
);
SRpcMsg
rpcMsg
=
{
.
ahandle
=
pMsg
,
.
pCont
=
pDrop
,
...
...
@@ -2327,6 +2345,7 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SCTableObj
*
pTable
=
(
SCTableObj
*
)
pMsg
->
pTable
;
mError
(
"msg:%p, app:%p ctable:%s, failed to drop, sdb error"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pTable
->
info
.
tableId
);
monSaveAuditLog
(
MON_DDL_CMD_DROP_TABLE
,
mnodeGetUserFromMsg
(
pMsg
),
pTable
->
info
.
tableId
,
false
);
return
code
;
}
...
...
@@ -3559,7 +3578,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTable
->
sql
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pTable
->
sql
,
pShow
->
bytes
[
cols
]);
cols
++
;
numOfRows
++
;
...
...
@@ -3594,13 +3613,13 @@ static int32_t mnodeCompactSuperTables() {
};
//mInfo("compact super %" PRIu64, pTable->uid);
sdbInsertCompactRow
(
&
row
);
}
mInfo
(
"end to compact super table..."
);
return
0
;
return
0
;
}
static
int32_t
mnodeCompactChildTables
()
{
...
...
@@ -3620,13 +3639,13 @@ static int32_t mnodeCompactChildTables() {
};
//mInfo("compact child %" PRIu64 ":%d", pTable->uid, pTable->tid);
sdbInsertCompactRow
(
&
row
);
}
mInfo
(
"end to compact child table..."
);
return
0
;
return
0
;
}
int32_t
mnodeCompactTables
()
{
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
5f5d72b2
...
...
@@ -108,7 +108,7 @@ static void mnodePrintUserAuth() {
mDebug
(
"failed to auth.txt for write"
);
return
;
}
void
*
pIter
=
NULL
;
SUserObj
*
pUser
=
NULL
;
...
...
@@ -181,7 +181,7 @@ int32_t mnodeInitUsers() {
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_USER
,
mnodeCancelGetNextUser
);
mnodeAddPeerMsgHandle
(
TSDB_MSG_TYPE_DM_AUTH
,
mnodeProcessAuthMsg
);
mDebug
(
"table:%s, hash is created"
,
desc
.
name
);
return
0
;
}
...
...
@@ -195,20 +195,20 @@ SUserObj *mnodeGetUser(char *name) {
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
void
*
mnodeGetNextUser
(
void
*
pIter
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
pIter
,
(
void
**
)
pUser
);
void
*
mnodeGetNextUser
(
void
*
pIter
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
pIter
,
(
void
**
)
pUser
);
}
void
mnodeCancelGetNextUser
(
void
*
pIter
)
{
sdbFreeIter
(
tsUserSdb
,
pIter
);
}
void
mnodeIncUserRef
(
SUserObj
*
pUser
)
{
sdbIncRef
(
tsUserSdb
,
pUser
);
void
mnodeIncUserRef
(
SUserObj
*
pUser
)
{
sdbIncRef
(
tsUserSdb
,
pUser
);
}
void
mnodeDecUserRef
(
SUserObj
*
pUser
)
{
sdbDecRef
(
tsUserSdb
,
pUser
);
void
mnodeDecUserRef
(
SUserObj
*
pUser
)
{
sdbDecRef
(
tsUserSdb
,
pUser
);
}
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
...
...
@@ -464,7 +464,7 @@ char *mnodeGetUserFromMsg(void *pMsg) {
static
int32_t
mnodeProcessCreateUserMsg
(
SMnodeMsg
*
pMsg
)
{
SUserObj
*
pOperUser
=
pMsg
->
pUser
;
if
(
pOperUser
->
superAuth
)
{
SCreateUserMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
return
mnodeCreateUser
(
pOperUser
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
,
pCreate
->
tags
,
pMsg
);
...
...
@@ -477,7 +477,7 @@ static int32_t mnodeProcessCreateUserMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeProcessAlterUserMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
code
;
SUserObj
*
pOperUser
=
pMsg
->
pUser
;
SAlterUserMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
SUserObj
*
pUser
=
mnodeGetUser
(
pAlter
->
user
);
if
(
pUser
==
NULL
)
{
...
...
@@ -686,10 +686,10 @@ int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, cha
static
int32_t
mnodeProcessAuthMsg
(
SMnodeMsg
*
pMsg
)
{
SAuthMsg
*
pAuthMsg
=
pMsg
->
rpcMsg
.
pCont
;
SAuthRsp
*
pAuthRsp
=
rpcMallocCont
(
sizeof
(
SAuthRsp
));
pMsg
->
rpcRsp
.
rsp
=
pAuthRsp
;
pMsg
->
rpcRsp
.
len
=
sizeof
(
SAuthRsp
);
return
mnodeRetriveAuth
(
pAuthMsg
->
user
,
&
pAuthRsp
->
spi
,
&
pAuthRsp
->
encrypt
,
pAuthRsp
->
secret
,
pAuthRsp
->
ckey
);
}
...
...
@@ -711,7 +711,7 @@ int32_t mnodeCompactUsers() {
};
mInfo
(
"compact users %s"
,
pUser
->
user
);
sdbInsertCompactRow
(
&
row
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录