提交 644bfa40 编写于 作者: S slguan

[TD-189] fix bug while drop user

上级 83727507
......@@ -82,6 +82,8 @@ static int32_t mgmtActionAcctRestored() {
if (dnodeIsFirstDeploy()) {
mgmtCreateRootAcct();
}
acctInit();
return TSDB_CODE_SUCCESS;
}
......@@ -112,7 +114,7 @@ int32_t mgmtInitAccts() {
}
mTrace("table:%s, hash is created", tableDesc.tableName);
return acctInit();
return TSDB_CODE_SUCCESS;
}
void mgmtCleanUpAccts() {
......
......@@ -882,18 +882,25 @@ static void mgmtProcessDropDbMsg(SQueuedMsg *pMsg) {
void mgmtDropAllDbs(SAcctObj *pAcct) {
int32_t numOfDbs = 0;
SDbObj *pDb = NULL;
void *pNode = NULL;
void * pNode = NULL;
while (1) {
pNode = sdbFetchRow(tsDbSdb, pNode, (void **)&pDb);
if (pDb == NULL) break;
if (pDb->pAcct == pAcct) {
mgmtSetDbDropping(pDb);
mPrint("db:%s, drop db from sdb for acct:%s is dropped", pDb->name, pAcct->user);
SSdbOper oper = {
.type = SDB_OPER_LOCAL,
.table = tsDbSdb,
.pObj = pDb
};
sdbDeleteRow(&oper);
numOfDbs++;
}
mgmtDecDbRef(pDb);
}
mTrace("acct:%s, all dbs is is set dirty", pAcct->user, numOfDbs);
mTrace("acct:%s, all dbs is is dropped from sdb", pAcct->user, numOfDbs);
}
......@@ -333,7 +333,7 @@ void sdbIncRef(void *handle, void *pRow) {
SSdbTable *pTable = handle;
int32_t * pRefCount = (int32_t *)(pRow + pTable->refCountPos);
atomic_add_fetch_32(pRefCount, 1);
if (0 && strcmp(pTable->tableName, "dnodes") == 0) {
if (0 && strcmp(pTable->tableName, "accounts") == 0) {
sdbTrace("table:%s, add ref to record:%s:%s:%d", pTable->tableName, pTable->tableName, sdbGetkeyStr(pTable, pRow),
*pRefCount);
}
......@@ -345,7 +345,7 @@ void sdbDecRef(void *handle, void *pRow) {
SSdbTable *pTable = handle;
int32_t * pRefCount = (int32_t *)(pRow + pTable->refCountPos);
int32_t refCount = atomic_sub_fetch_32(pRefCount, 1);
if (0 && strcmp(pTable->tableName, "dnodes") == 0) {
if (0 && strcmp(pTable->tableName, "accounts") == 0) {
sdbTrace("table:%s, def ref of record:%s:%s:%d", pTable->tableName, pTable->tableName, sdbGetkeyStr(pTable, pRow),
*pRefCount);
}
......@@ -404,23 +404,24 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbOper *pOper) {
pthread_mutex_unlock(&pTable->mutex);
sdbTrace("table:%s, insert record:%s to hash, numOfRows:%d", pTable->tableName, sdbGetkeyStr(pTable, pOper->pObj),
pTable->numOfRows);
sdbTrace("table:%s, insert record:%s to hash, numOfRows:%d version:%" PRIu64, pTable->tableName,
sdbGetkeyStr(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion());
(*pTable->insertFp)(pOper);
return TSDB_CODE_SUCCESS;
}
static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
(*pTable->deleteFp)(pOper);
pthread_mutex_lock(&pTable->mutex);
(*sdbDeleteIndexFp[pTable->keyType])(pTable->iHandle, pOper->pObj);
pTable->numOfRows--;
pthread_mutex_unlock(&pTable->mutex);
sdbTrace("table:%s, delete record:%s from hash, numOfRows:%d", pTable->tableName, sdbGetkeyStr(pTable, pOper->pObj),
pTable->numOfRows);
sdbTrace("table:%s, delete record:%s from hash, numOfRows:%d version:%" PRIu64, pTable->tableName,
sdbGetkeyStr(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion());
(*pTable->deleteFp)(pOper);
int8_t *updateEnd = pOper->pObj + pTable->refCountPos - 1;
*updateEnd = 1;
sdbDecRef(pTable, pOper->pObj);
......@@ -429,8 +430,8 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
}
static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbOper *pOper) {
sdbTrace("table:%s, update record:%s in hash, numOfRows:%d", pTable->tableName, sdbGetkeyStr(pTable, pOper->pObj),
pTable->numOfRows);
sdbTrace("table:%s, update record:%s in hash, numOfRows:%d version:%" PRIu64, pTable->tableName,
sdbGetkeyStr(pTable, pOper->pObj), pTable->numOfRows, sdbGetVersion());
(*pTable->updateFp)(pOper);
return TSDB_CODE_SUCCESS;
......
......@@ -39,7 +39,7 @@ static int vnodeWalCallback(void *arg);
static int32_t vnodeSaveCfg(SMDCreateVnodeMsg *pVnodeCfg);
static int32_t vnodeReadCfg(SVnodeObj *pVnode);
static int32_t vnodeSaveVersion(SVnodeObj *pVnode);
static int32_t vnodeReadVersion(SVnodeObj *pVnode);
static bool vnodeReadVersion(SVnodeObj *pVnode);
static int vnodeWalCallback(void *arg);
static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size);
static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index);
......@@ -287,7 +287,7 @@ void *vnodeGetVnode(int32_t vgId) {
SVnodeObj **ppVnode = (SVnodeObj **)taosGetIntHashData(tsDnodeVnodesHash, vgId);
if (ppVnode == NULL || *ppVnode == NULL) {
terrno = TSDB_CODE_INVALID_VGROUP_ID;
dError("vgId:%d not exist");
dError("vgId:%d not exist", vgId);
return NULL;
}
......@@ -611,7 +611,7 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId);
FILE *fp = fopen(versionFile, "w");
if (!fp) {
dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId);
dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId, strerror(errno));
return errno;
}
......@@ -632,23 +632,23 @@ static int32_t vnodeSaveVersion(SVnodeObj *pVnode) {
return 0;
}
static int32_t vnodeReadVersion(SVnodeObj *pVnode) {
static bool vnodeReadVersion(SVnodeObj *pVnode) {
char versionFile[TSDB_FILENAME_LEN + 30] = {0};
sprintf(versionFile, "%s/vnode%d/version.json", tsVnodeDir, pVnode->vgId);
FILE *fp = fopen(versionFile, "w");
if (!fp) {
dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId);
return errno;
dError("pVnode:%p vgId:%d, failed to open vnode version file for write, error:%s", pVnode, pVnode->vgId, strerror(errno));
return false;
}
int ret = TSDB_CODE_OTHERS;
bool ret = false;
int maxLen = 100;
char *content = calloc(1, maxLen + 1);
int len = fread(content, 1, maxLen, fp);
if (len <= 0) {
free(content);
fclose(fp);
dError("pVnode:%p vgId:%d, failed to read vnode version, content is null", pVnode, pVnode->vgId);
dPrint("pVnode:%p vgId:%d, failed to read vnode version, content is null", pVnode, pVnode->vgId);
return false;
}
......@@ -665,7 +665,7 @@ static int32_t vnodeReadVersion(SVnodeObj *pVnode) {
}
pVnode->version = version->valueint;
ret = 0;
ret = true;
dPrint("pVnode:%p vgId:%d, read vnode version successed, version:%%" PRId64, pVnode, pVnode->vgId, pVnode->version);
......
run general/account/pass_alter.sim
run general/account/pass_len.sim
run general/account/user_create.sim
run general/account/user_len.sim
run general/account/monitor.sim
\ No newline at end of file
......@@ -13,6 +13,11 @@ print $data00 $data01 $data02
print $data10 $data11 $data22
print $data20 $data11 $data22
sql_error show accounts;
sql_error create account a pass "a"
sql_error drop account a
sql_error drop account root
print =============== create user1
sql create user user1 PASS 'user1'
sql show users
......
......@@ -2,11 +2,10 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
print ============================ dnode1 start
......
......@@ -2,8 +2,8 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......@@ -53,7 +53,7 @@ if $rows != 0 then
return -1
endi
sql show dnodes
if $data02 != 2 then
if $data03 != 2 then
return -1
endi
sql drop account oroot
......
......@@ -2,8 +2,8 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
......@@ -2,9 +2,9 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 8
system sh/exec.sh -n dnode1 -s start
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/exec_up.sh -n dnode1 -s start
system sh/exec_up_up.sh -n dnode1 -s start
sql connect
print =============== show accounts
......
......@@ -7,7 +7,7 @@ system sh/cfg.sh -n dnode1 -c monitor -v 0
print ========== step1
system sh/cfg.sh -n dnode1 -c monitor -v 1
system sh/cfg.sh -n dnode1 -c monitorInterval -v 1
system sh/exec.sh -n dnode1 -s start
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/exec_up.sh -n dnode1 -s start
system sh/exec_up_up.sh -n dnode1 -s start
sql connect
print =============== show accounts
......
......@@ -2,8 +2,8 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
......@@ -2,8 +2,8 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
run unique/account/account_create.sim
run unique/account/account_len.sim
run unique/account/account_delete.sim
run unique/account/pass_alter.sim
run unique/account/pass_len.sim
run unique/account/authority.sim
run unique/account/account_delete.sim
run unique/account/user_create.sim
run unique/account/user_len.sim
run unique/account/authority.sim
run unique/account/monitor.sim
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/exec_up.sh -n dnode1 -s start
system sh/exec_up_up.sh -n dnode1 -s start
sql connect
print =============== show accounts
......
......@@ -2,8 +2,8 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
......@@ -2,8 +2,8 @@ system sh/stop_dnodes.sh
system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c commitLog -v 0
system sh/exec.sh -n dnode1 -s start
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec_up.sh -n dnode1 -s start
sql connect
sleep 3000
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册