未验证 提交 6da52762 编写于 作者: W wade zhang 提交者: GitHub

Merge pull request #22264 from taosdata/szhou/fix-ts3749

fix: restore user privilege processing if the rows generated by the u…
......@@ -20,6 +20,7 @@
#define SHOW_STEP_SIZE 100
#define SHOW_COLS_STEP_SIZE 4096
#define SHOW_PRIVILEGES_STEP_SIZE 2048
static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq);
static void mndFreeShowObj(SShowObj *pShow);
......@@ -234,6 +235,8 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
if(pShow->type == TSDB_MGMT_TABLE_COL){ // expend capacity for ins_columns
rowsToRead = SHOW_COLS_STEP_SIZE;
} else if (pShow->type == TSDB_MGMT_TABLE_PRIVILEGES) {
rowsToRead = SHOW_PRIVILEGES_STEP_SIZE;
}
ShowRetrieveFp retrieveFp = pMgmt->retrieveFps[pShow->type];
if (retrieveFp == NULL) {
......
......@@ -1213,16 +1213,34 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
int32_t cols = 0;
char *pWrite;
bool fetchNextUser = pShow->restore ? false : true;
pShow->restore = false;
while (numOfRows < rows) {
pShow->pIter = sdbFetch(pSdb, SDB_USER, pShow->pIter, (void **)&pUser);
if (pShow->pIter == NULL) break;
if (fetchNextUser) {
pShow->pIter = sdbFetch(pSdb, SDB_USER, pShow->pIter, (void **)&pUser);
if (pShow->pIter == NULL) break;
} else {
fetchNextUser = true;
void *pKey = taosHashGetKey(pShow->pIter, NULL);
pUser = sdbAcquire(pSdb, SDB_USER, pKey);
if (!pUser) {
continue;
}
}
int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs);
int32_t numOfWriteDbs = taosHashGetSize(pUser->writeDbs);
int32_t numOfTopics = taosHashGetSize(pUser->topics);
int32_t numOfReadTbs = taosHashGetSize(pUser->readTbs);
int32_t numOfWriteTbs = taosHashGetSize(pUser->writeTbs);
if (numOfRows + numOfReadDbs + numOfWriteDbs + numOfTopics + numOfReadTbs + numOfWriteTbs >= rows) break;
if (numOfRows + numOfReadDbs + numOfWriteDbs + numOfTopics + numOfReadTbs + numOfWriteTbs >= rows) {
mInfo("will restore. current num of rows: %d, read dbs %d, write dbs %d, topics %d, read tables %d, write tables %d",
numOfRows, numOfReadDbs, numOfWriteDbs, numOfTopics, numOfReadTbs, numOfWriteTbs);
pShow->restore = true;
sdbRelease(pSdb, pUser);
break;
}
if (pUser->superUser) {
cols = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册