fix invalid write in mnode

This commit is contained in:
Shengliang Guan 2022-01-11 02:54:11 -08:00
parent e3c8576473
commit 59d23065fd
5 changed files with 33 additions and 39 deletions

View File

@ -740,7 +740,7 @@ static int32_t mndBuildDropVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *
if (pReq == NULL) return -1; if (pReq == NULL) return -1;
action.pCont = pReq; action.pCont = pReq;
action.contLen = sizeof(SCreateVnodeReq); action.contLen = sizeof(SDropVnodeReq);
action.msgType = TDMT_DND_DROP_VNODE; action.msgType = TDMT_DND_DROP_VNODE;
action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED; action.acceptableCode = TSDB_CODE_DND_VNODE_NOT_DEPLOYED;
if (mndTransAppendRedoAction(pTrans, &action) != 0) { if (mndTransAppendRedoAction(pTrans, &action) != 0) {

View File

@ -235,7 +235,7 @@ int32_t mndGetDnodeSize(SMnode *pMnode) {
bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) { bool mndIsDnodeOnline(SMnode *pMnode, SDnodeObj *pDnode, int64_t curMs) {
int64_t interval = ABS(pDnode->lastAccessTime - curMs); int64_t interval = ABS(pDnode->lastAccessTime - curMs);
if (interval > 3500 * pMnode->cfg.statusInterval) { if (interval > 10000 * pMnode->cfg.statusInterval) {
if (pDnode->rebootTime > 0) { if (pDnode->rebootTime > 0) {
pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT; pDnode->offlineReason = DND_REASON_STATUS_MSG_TIMEOUT;
} }

View File

@ -319,6 +319,14 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup, SArray *pAr
taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes); taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes);
int32_t size = taosArrayGetSize(pArray);
if (size < pVgroup->replica) {
mError("db:%s, vgId:%d, no enough online dnodes:%d to alloc %d replica", pVgroup->dbName, pVgroup->vgId, size,
pVgroup->replica);
terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES;
return -1;
}
for (int32_t v = 0; v < pVgroup->replica; ++v) { for (int32_t v = 0; v < pVgroup->replica; ++v) {
SVnodeGid *pVgid = &pVgroup->vnodeGid[v]; SVnodeGid *pVgid = &pVgroup->vnodeGid[v];
SDnodeObj *pDnode = taosArrayGet(pArray, v); SDnodeObj *pDnode = taosArrayGet(pArray, v);

View File

@ -30,7 +30,7 @@ do
CLEAR_OPTION="clear" CLEAR_OPTION="clear"
;; ;;
v) v)
SHELL_OPTION="true" VALGRIND_OPTION="true"
;; ;;
u) u)
USERS=$OPTARG USERS=$OPTARG
@ -99,7 +99,7 @@ fi
if [ "$EXEC_OPTON" = "start" ]; then if [ "$EXEC_OPTON" = "start" ]; then
echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR echo "ExcuteCmd:" $EXE_DIR/taosd -c $CFG_DIR
if [ "$SHELL_OPTION" = "true" ]; then if [ "$VALGRIND_OPTION" = "true" ]; then
TT=`date +%s` TT=`date +%s`
mkdir ${LOG_DIR}/${TT} mkdir ${LOG_DIR}/${TT}
nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 & nohup valgrind --log-file=${LOG_DIR}/${TT}/valgrind.log --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes $EXE_DIR/taosd -c $CFG_DIR > /dev/null 2>&1 &

View File

@ -1,29 +1,24 @@
system sh/stop_dnodes.sh system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1 system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c wallevel -v 0
system sh/cfg.sh -n dnode1 -c maxVgroupsPerDb -v 4
system sh/cfg.sh -n dnode1 -c maxTablesPerVnode -v 1000
system sh/exec.sh -n dnode1 -s start system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect sql connect
print ============================ dnode1 start print ============================ dnode1 start
$i = 0 $i = 0
$dbPrefix = ob_db_db $dbPrefix = db
$tbPrefix = ob_db_tb $tbPrefix = tb
$db = $dbPrefix . $i $db = $dbPrefix . $i
$tb = $tbPrefix . $i $tb = $tbPrefix . $i
print =============== step1 print =============== step1
sql create database $db replica 1 days 20 keep 2000 cache 16 sql create database $db replica 1 days 20 keep 2000 cache 16 vgroups 4
sql show databases sql show databases
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
if $data00 != $db then if $data00 != $db then
return -1 return -1
endi endi
if $data02 != 0 then if $data02 != 4 then
return -1 return -1
endi endi
if $data03 != 0 then if $data03 != 0 then
@ -63,9 +58,6 @@ print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07
if $data00 != $db then if $data00 != $db then
return -1 return -1
endi endi
if $data02 != 0 then
return -1
endi
if $data03 != 0 then if $data03 != 0 then
return -1 return -1
endi endi
@ -77,30 +69,14 @@ if $data06 != 15 then
endi endi
print =============== step6 print =============== step6
sql use $db $i = $i + 1
sql create table $tb (ts timestamp, speed int) while $i < 5
$i = 1
while $i < 4
$db = $dbPrefix . $i $db = $dbPrefix . $i
$tb = $tbPrefix . $i
sql create database $db sql create database $db
sql use $db sql use $db
sql create table $tb (ts timestamp, speed int)
$i = $i + 1 $i = $i + 1
endw endw
sql show databases
if $rows != 4 then
return -1
endi
$i = 4
$db = $dbPrefix . $i
$tb = $tbPrefix . $i
sql create database $db
sql use $db
sql create table $tb (ts timestamp, speed int)
print =============== step7 print =============== step7
$i = 0 $i = 0
while $i < 5 while $i < 5
@ -115,7 +91,8 @@ $db = $dbPrefix . $i
$tb = $tbPrefix . $i $tb = $tbPrefix . $i
sql create database $db sql create database $db
sql use $db sql use $db
sql create table $tb (ts timestamp, speed int) sql create table st (ts timestamp, i int) tags (j int)
sql create table $tb using st tags(1)
sql show tables sql show tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -133,7 +110,8 @@ if $rows != 0 then
endi endi
print =============== step11 print =============== step11
sql create table $tb (ts timestamp, speed int) sql create table st (ts timestamp, i int) tags (j int)
sql create table $tb using st tags(1)
sql show tables sql show tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
@ -149,16 +127,23 @@ sql show tables
if $rows != 0 then if $rows != 0 then
return -1 return -1
endi endi
sql create table $tb (ts timestamp, speed int)
sql create table st (ts timestamp, i int) tags (j int)
sql create table $tb using st tags(1)
sql show tables sql show tables
if $rows != 1 then if $rows != 1 then
return -1 return -1
endi endi
sql insert into $tb values (now+1a, 0) sql insert into $tb values (now+1a, 0)
sql insert into $tb values (now+2a, 1) sql insert into $tb values (now+2a, 1)
sql insert into $tb values (now+3a, 2) sql insert into $tb values (now+3a, 2)
sql insert into $tb values (now+4a, 3) sql insert into $tb values (now+4a, 3)
sql insert into $tb values (now+5a, 4) sql insert into $tb values (now+5a, 4)
return
sql select * from $tb sql select * from $tb
if $rows != 5 then if $rows != 5 then
return -1 return -1
@ -176,7 +161,8 @@ if $rows != 0 then
endi endi
print =============== step16 print =============== step16
sql create table $tb (ts timestamp, speed int) sql create table st (ts timestamp, i int) tags (j int)
sql create table $tb using st tags(1)
sql show tables sql show tables
if $rows != 1 then if $rows != 1 then
return -1 return -1