Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4929a943
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看板
提交
4929a943
编写于
7月 02, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-468] deadlock while create tb
上级
0e6c01c0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
21 deletion
+43
-21
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+3
-3
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+39
-17
src/util/src/tidpool.c
src/util/src/tidpool.c
+1
-1
未找到文件。
src/mnode/src/mnodeDb.c
浏览文件 @
4929a943
...
...
@@ -388,7 +388,7 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate, void *pMs
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pDb
);
mnodeDestroyDb
(
pDb
);
mLInfo
(
"db:%s, failed to create, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
return
code
;
}
else
{
...
...
@@ -434,7 +434,7 @@ void mnodeAddVgroupIntoDb(SVgObj *pVgroup) {
}
pDb
->
vgList
[
vgPos
]
=
pVgroup
;
pthread_mutex_lock
(
&
pDb
->
mutex
);
pthread_mutex_
un
lock
(
&
pDb
->
mutex
);
}
void
mnodeRemoveVgroupFromDb
(
SVgObj
*
pVgroup
)
{
...
...
@@ -451,7 +451,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) {
}
}
pthread_mutex_lock
(
&
pDb
->
mutex
);
pthread_mutex_
un
lock
(
&
pDb
->
mutex
);
}
void
mnodeCleanupDbs
()
{
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
4929a943
...
...
@@ -49,14 +49,17 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg);
static
int32_t
mnodeProcessVnodeCfgMsg
(
SMnodeMsg
*
pMsg
)
;
static
void
mnodeSendDropVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
static
int32_t
mnodeVgroupActionDestroy
(
SSdbOper
*
pOper
)
{
SVgObj
*
pVgroup
=
pOper
->
pObj
;
static
void
mnodeDestroyVgroup
(
SVgObj
*
pVgroup
)
{
if
(
pVgroup
->
idPool
)
{
taosIdPoolCleanUp
(
pVgroup
->
idPool
);
pVgroup
->
idPool
=
NULL
;
}
tfree
(
pOper
->
pObj
);
tfree
(
pVgroup
);
}
static
int32_t
mnodeVgroupActionDestroy
(
SSdbOper
*
pOper
)
{
mnodeDestroyVgroup
(
pOper
->
pObj
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -299,39 +302,45 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
SDbObj
*
pDb
=
pInputVgroup
->
pDb
;
if
(
pDb
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
int32_t
currIdPoolSize
=
TSDB_MIN_TABLES
;
int32_t
minIdPoolSize
=
TSDB_MAX_TABLES
;
int32_t
maxIdPoolSize
=
TSDB_MIN_TABLES
;
for
(
int32_t
v
=
0
;
v
<
pDb
->
numOfVgroups
;
++
v
)
{
SVgObj
*
pVgroup
=
pDb
->
vgList
[
v
];
if
(
pVgroup
==
NULL
)
continue
;
int32_t
idPoolSize
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
currIdPoolSize
=
MAX
(
currIdPoolSize
,
idPoolSize
);
minIdPoolSize
=
MIN
(
minIdPoolSize
,
idPoolSize
);
maxIdPoolSize
=
MAX
(
maxIdPoolSize
,
idPoolSize
);
}
// new vgroup
if
(
pInputVgroup
->
idPool
==
NULL
)
{
pInputVgroup
->
idPool
=
taosInitIdPool
(
curr
IdPoolSize
);
pInputVgroup
->
idPool
=
taosInitIdPool
(
max
IdPoolSize
);
if
(
pInputVgroup
->
idPool
==
NULL
)
{
mError
(
"vgId:%d, failed to init idPool for vgroup, size:%d"
,
pInputVgroup
->
vgId
,
curr
IdPoolSize
);
mError
(
"vgId:%d, failed to init idPool for vgroup, size:%d"
,
pInputVgroup
->
vgId
,
max
IdPoolSize
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
else
{
mDebug
(
"vgId:%d, init idPool for vgroup, size:%d"
,
pInputVgroup
->
vgId
,
curr
IdPoolSize
);
mDebug
(
"vgId:%d, init idPool for vgroup, size:%d"
,
pInputVgroup
->
vgId
,
max
IdPoolSize
);
return
TSDB_CODE_SUCCESS
;
}
}
// realloc all vgroups in db
int32_t
newIdPoolSize
;
if
(
curr
IdPoolSize
<
TSDB_TABLES_STEP
)
{
newIdPoolSize
=
curr
IdPoolSize
*
2
;
if
(
min
IdPoolSize
<
TSDB_TABLES_STEP
)
{
newIdPoolSize
=
min
IdPoolSize
*
2
;
}
else
{
newIdPoolSize
=
((
curr
IdPoolSize
/
TSDB_TABLES_STEP
)
+
1
)
*
TSDB_TABLES_STEP
;
newIdPoolSize
=
((
min
IdPoolSize
/
TSDB_TABLES_STEP
)
+
1
)
*
TSDB_TABLES_STEP
;
}
if
(
newIdPoolSize
>
tsMaxTablePerVnode
)
{
mDebug
(
"db:%s, currIdPoolSize:%d newIdPoolSize%d larger than %d"
,
pDb
->
name
,
currIdPoolSize
,
newIdPoolSize
,
tsMaxTablePerVnode
);
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
if
(
minIdPoolSize
>=
tsMaxTablePerVnode
)
{
mError
(
"db:%s, minIdPoolSize:%d newIdPoolSize:%d larger than maxTablesPerVnode:%d"
,
pDb
->
name
,
minIdPoolSize
,
newIdPoolSize
,
tsMaxTablePerVnode
);
return
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
}
else
{
newIdPoolSize
=
tsMaxTablePerVnode
;
}
}
for
(
int32_t
v
=
0
;
v
<
pDb
->
numOfVgroups
;
++
v
)
{
...
...
@@ -339,6 +348,7 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
if
(
pVgroup
==
NULL
)
continue
;
int32_t
oldIdPoolSize
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
if
(
newIdPoolSize
==
oldIdPoolSize
)
continue
;
if
(
taosUpdateIdPool
(
pVgroup
->
idPool
,
newIdPoolSize
)
<
0
)
{
mError
(
"vgId:%d, failed to update idPoolSize from %d to %d"
,
pVgroup
->
vgId
,
oldIdPoolSize
,
newIdPoolSize
);
...
...
@@ -381,7 +391,7 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
int
maxVgroupsPerDb
=
tsMaxVgroupsPerDb
;
if
(
maxVgroupsPerDb
<=
0
)
{
maxVgroupsPerDb
=
mnodeGetOnlinDnodesCpuCoreNum
();
maxVgroupsPerDb
=
M
IN
(
maxVgroupsPerDb
,
2
);
maxVgroupsPerDb
=
M
AX
(
maxVgroupsPerDb
,
2
);
}
if
(
pDb
->
numOfVgroups
<
maxVgroupsPerDb
)
{
...
...
@@ -467,7 +477,7 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg) {
int32_t
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pMsg
->
pVgroup
=
NULL
;
tfree
(
pVgroup
);
mnodeDestroyVgroup
(
pVgroup
);
}
else
{
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
...
...
@@ -515,6 +525,12 @@ int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) {
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"poolSize"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
4
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
[
cols
].
name
,
"maxTables"
);
...
...
@@ -607,7 +623,11 @@ int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, void *pC
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
tsMaxTablePerVnode
;
*
(
int32_t
*
)
pWrite
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
tsMaxTablePerVnode
;
cols
++
;
for
(
int32_t
i
=
0
;
i
<
pShow
->
maxReplica
;
++
i
)
{
...
...
@@ -679,6 +699,8 @@ SMDCreateVnodeMsg *mnodeBuildCreateVnodeMsg(SVgObj *pVgroup) {
strcpy
(
pVnode
->
db
,
pVgroup
->
dbName
);
int32_t
maxTables
=
taosIdPoolMaxSize
(
pVgroup
->
idPool
);
//TODO: dynamic alloc tables in tsdb
maxTables
=
10000
;
SMDVnodeCfg
*
pCfg
=
&
pVnode
->
cfg
;
pCfg
->
vgId
=
htonl
(
pVgroup
->
vgId
);
...
...
src/util/src/tidpool.c
浏览文件 @
4929a943
...
...
@@ -123,7 +123,7 @@ void taosIdPoolMarkStatus(void *handle, int id) {
int
taosUpdateIdPool
(
id_pool_t
*
handle
,
int
maxId
)
{
id_pool_t
*
pIdPool
=
(
id_pool_t
*
)
handle
;
if
(
maxId
<=
pIdPool
->
maxId
)
{
return
-
1
;
return
0
;
}
bool
*
idList
=
calloc
(
maxId
,
sizeof
(
bool
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录