refactor some codes.
This commit is contained in:
parent
05ce45e76e
commit
c516665a2a
|
@ -2336,7 +2336,7 @@ static int32_t getMeterIndex(SSQLToken* pTableToken, SSqlCmd* pCmd, SColumnIndex
|
|||
|
||||
for (int32_t i = 0; i < pCmd->numOfTables; ++i) {
|
||||
SMeterMetaInfo* pMeterMetaInfo = tscGetMeterMetaInfo(pCmd, i);
|
||||
extractMeterName(pMeterMetaInfo->name, tableName);
|
||||
extractTableName(pMeterMetaInfo->name, tableName);
|
||||
|
||||
if (strncasecmp(tableName, pTableToken->z, pTableToken->n) == 0 && strlen(tableName) == pTableToken->n) {
|
||||
pIndex->tableIndex = i;
|
||||
|
|
|
@ -131,35 +131,39 @@ bool tsMeterMetaIdentical(SMeterMeta* p1, SMeterMeta* p2) {
|
|||
}
|
||||
|
||||
// todo refactor
|
||||
static FORCE_INLINE char* skipSegments(char* input, char delimiter, int32_t num) {
|
||||
static FORCE_INLINE char* skipSegments(char* input, char delim, int32_t num) {
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
while (*input != 0 && *input++ != delimiter) {
|
||||
while (*input != 0 && *input++ != delim) {
|
||||
};
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void copySegment(char* dst, char* src, char delimiter) {
|
||||
static FORCE_INLINE size_t copy(char* dst, const char* src, char delimiter) {
|
||||
size_t len = 0;
|
||||
while (*src != delimiter && *src != 0) {
|
||||
*dst++ = *src++;
|
||||
len++;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* extract meter name from meterid, which the format of userid.dbname.metername
|
||||
* extract table name from meterid, which the format of userid.dbname.metername
|
||||
* @param meterId
|
||||
* @return
|
||||
*/
|
||||
void extractMeterName(char* meterId, char* name) {
|
||||
void extractTableName(char* meterId, char* name) {
|
||||
char* r = skipSegments(meterId, TS_PATH_DELIMITER[0], 2);
|
||||
copySegment(name, r, TS_PATH_DELIMITER[0]);
|
||||
copy(name, r, TS_PATH_DELIMITER[0]);
|
||||
}
|
||||
|
||||
SSQLToken extractDBName(char* meterId, char* name) {
|
||||
char* r = skipSegments(meterId, TS_PATH_DELIMITER[0], 1);
|
||||
copySegment(name, r, TS_PATH_DELIMITER[0]);
|
||||
size_t len = copy(name, r, TS_PATH_DELIMITER[0]);
|
||||
|
||||
SSQLToken token = {.z = name, .n = strlen(name), .type = TK_STRING};
|
||||
SSQLToken token = {.z = name, .n = len, .type = TK_STRING};
|
||||
return token;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ char *tsGetTagsValue(SMeterMeta *pMeta);
|
|||
|
||||
bool tsMeterMetaIdentical(SMeterMeta *p1, SMeterMeta *p2);
|
||||
|
||||
void extractMeterName(char *meterId, char *name);
|
||||
void extractTableName(char *meterId, char *name);
|
||||
|
||||
SSQLToken extractDBName(char *meterId, char *name);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
#include "dnodeSystem.h"
|
||||
#include "mgmt.h"
|
||||
#include "tglobalcfg.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
#include "ttime.h"
|
||||
|
||||
void mgmtCreateDnodeOrderList();
|
||||
|
|
|
@ -64,15 +64,6 @@ enum _sync_cmd {
|
|||
TSDB_SYNC_CMD_REMOVE,
|
||||
};
|
||||
|
||||
enum _meter_state {
|
||||
TSDB_METER_STATE_READY = 0x00,
|
||||
TSDB_METER_STATE_INSERT = 0x01,
|
||||
TSDB_METER_STATE_IMPORTING = 0x02,
|
||||
TSDB_METER_STATE_UPDATING = 0x04,
|
||||
TSDB_METER_STATE_DELETING = 0x10,
|
||||
TSDB_METER_STATE_DELETED = 0x18,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int64_t offset : 48;
|
||||
int64_t length : 16;
|
||||
|
|
|
@ -78,15 +78,26 @@ enum _TSDB_VN_STREAM_STATUS {
|
|||
TSDB_VN_STREAM_STATUS_START
|
||||
};
|
||||
|
||||
const char* taosGetVgroupStatusStr(int vgroupStatus);
|
||||
const char* taosGetDbStatusStr(int dbStatus);
|
||||
const char* taosGetVnodeStatusStr(int vnodeStatus);
|
||||
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus);
|
||||
const char* taosGetVnodeDropStatusStr(int dropping);
|
||||
const char* taosGetDnodeStatusStr(int dnodeStatus);
|
||||
const char* taosGetDnodeLbStatusStr(int dnodeBalanceStatus);
|
||||
const char* taosGetVgroupLbStatusStr(int vglbStatus);
|
||||
const char* taosGetVnodeStreamStatusStr(int vnodeStreamStatus);
|
||||
enum TSDB_TABLE_STATUS {
|
||||
TSDB_METER_STATE_READY = 0x00,
|
||||
TSDB_METER_STATE_INSERTING = 0x01,
|
||||
TSDB_METER_STATE_IMPORTING = 0x02,
|
||||
TSDB_METER_STATE_UPDATING = 0x04,
|
||||
TSDB_METER_STATE_DROPPING = 0x10,
|
||||
TSDB_METER_STATE_DROPPED = 0x18,
|
||||
};
|
||||
|
||||
const char* taosGetVgroupStatusStr(int32_t vgroupStatus);
|
||||
const char* taosGetDbStatusStr(int32_t dbStatus);
|
||||
const char* taosGetVnodeStatusStr(int32_t vnodeStatus);
|
||||
const char* taosGetVnodeSyncStatusStr(int32_t vnodeSyncStatus);
|
||||
const char* taosGetVnodeDropStatusStr(int32_t dropping);
|
||||
const char* taosGetDnodeStatusStr(int32_t dnodeStatus);
|
||||
const char* taosGetDnodeLbStatusStr(int32_t dnodeBalanceStatus);
|
||||
const char* taosGetVgroupLbStatusStr(int32_t vglbStatus);
|
||||
const char* taosGetVnodeStreamStatusStr(int32_t vnodeStreamStatus);
|
||||
|
||||
const char* taosGetTableStatusStr(int32_t tableStatus);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
#include "vnodeMgmt.h"
|
||||
#include "vnodeSystem.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
SMgmtObj mgmtObj;
|
||||
extern uint64_t tsCreatedTime;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "mgmtBalance.h"
|
||||
#include "mgmtUtil.h"
|
||||
#include "tschemautil.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
void *dbSdb = NULL;
|
||||
int tsDbUpdateSize;
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
#include "dnodeSystem.h"
|
||||
#include "mgmt.h"
|
||||
#include "tschemautil.h"
|
||||
#include "tstatus.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
bool mgmtCheckModuleInDnode(SDnodeObj *pDnode, int moduleType);
|
||||
int mgmtGetDnodesNum();
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "tsqlfunction.h"
|
||||
#include "ttime.h"
|
||||
#include "vnodeTagMgmt.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
extern int64_t sdbVersion;
|
||||
|
||||
|
@ -984,6 +984,28 @@ SSchema *mgmtGetMeterSchema(STabObj *pMeter) {
|
|||
return (SSchema *)pMetric->schema;
|
||||
}
|
||||
|
||||
static int32_t mgmtSerializeTagValue(char* pMsg, STabObj* pMeter, int16_t* tagsId, int32_t numOfTags) {
|
||||
int32_t offset = 0;
|
||||
|
||||
for (int32_t j = 0; j < numOfTags; ++j) {
|
||||
if (tagsId[j] == TSDB_TBNAME_COLUMN_INDEX) { // handle the table name tags
|
||||
char name[TSDB_METER_NAME_LEN] = {0};
|
||||
extractTableName(pMeter->meterId, name);
|
||||
|
||||
memcpy(pMsg + offset, name, TSDB_METER_NAME_LEN);
|
||||
offset += TSDB_METER_NAME_LEN;
|
||||
} else {
|
||||
SSchema s = {0};
|
||||
char * tag = mgmtMeterGetTag(pMeter, tagsId[j], &s);
|
||||
|
||||
memcpy(pMsg + offset, tag, (size_t)s.bytes);
|
||||
offset += s.bytes;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
/*
|
||||
* serialize SVnodeSidList to byte array
|
||||
*/
|
||||
|
@ -996,7 +1018,6 @@ static char *mgmtBuildMetricMetaMsg(STabObj *pMeter, int32_t *ovgId, SVnodeSidLi
|
|||
* 1. the query msg may be larger than 64k,
|
||||
* 2. the following meters belong to different vnodes
|
||||
*/
|
||||
|
||||
(*pList) = (SVnodeSidList *)pMsg;
|
||||
(*pList)->numOfSids = 0;
|
||||
(*pList)->index = 0;
|
||||
|
@ -1015,29 +1036,15 @@ static char *mgmtBuildMetricMetaMsg(STabObj *pMeter, int32_t *ovgId, SVnodeSidLi
|
|||
(*pList)->numOfSids++;
|
||||
|
||||
SMeterSidExtInfo *pSMeterTagInfo = (SMeterSidExtInfo *)pMsg;
|
||||
pSMeterTagInfo->sid = pMeter->gid.sid;
|
||||
pSMeterTagInfo->sid = htonl(pMeter->gid.sid);
|
||||
pSMeterTagInfo->uid = htobe64(pMeter->uid);
|
||||
|
||||
pMsg += sizeof(SMeterSidExtInfo);
|
||||
|
||||
int32_t offset = 0;
|
||||
for (int32_t j = 0; j < numOfTags; ++j) {
|
||||
if (tagsId[j] == -1) {
|
||||
char name[TSDB_METER_NAME_LEN] = {0};
|
||||
extractMeterName(pMeter->meterId, name);
|
||||
|
||||
memcpy(pMsg + offset, name, TSDB_METER_NAME_LEN);
|
||||
offset += TSDB_METER_NAME_LEN;
|
||||
} else {
|
||||
SSchema s = {0};
|
||||
char * tag = mgmtMeterGetTag(pMeter, tagsId[j], &s);
|
||||
|
||||
memcpy(pMsg + offset, tag, (size_t)s.bytes);
|
||||
offset += s.bytes;
|
||||
}
|
||||
}
|
||||
|
||||
pMsg += offset;
|
||||
int32_t offset = mgmtSerializeTagValue(pMsg, pMeter, tagsId, numOfTags);
|
||||
assert(offset == tagLen);
|
||||
|
||||
|
||||
pMsg += offset;
|
||||
return pMsg;
|
||||
}
|
||||
|
||||
|
@ -1209,12 +1216,9 @@ int mgmtRetrieveMetricMeta(void *thandle, char **pStart, SMetricMetaMsg *pMetric
|
|||
#endif
|
||||
|
||||
if (ret == TSDB_CODE_SUCCESS) {
|
||||
// todo opt performance
|
||||
for (int32_t i = 0; i < pMetricMetaMsg->numOfMeters; ++i) {
|
||||
ret = mgmtRetrieveMetersFromMetric(pMetricMetaMsg, i, &result[i]);
|
||||
// todo opt performance
|
||||
// if (result[i].num <= 0) {//no result
|
||||
// } else if (result[i].num < 10) {
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1283,7 +1287,7 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
|
|||
memset(meterName, 0, tListLen(meterName));
|
||||
|
||||
// pattern compare for meter name
|
||||
extractMeterName(pMeter->meterId, meterName);
|
||||
extractTableName(pMeter->meterId, meterName);
|
||||
|
||||
if (pShow->payloadLen > 0 &&
|
||||
patternMatch(pShow->payload, meterName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
||||
|
@ -1305,7 +1309,7 @@ int mgmtRetrieveMeters(SShowObj *pShow, char *data, int rows, SConnObj *pConn) {
|
|||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
if (pMeter->pTagData) {
|
||||
extractMeterName(pMeter->pTagData, pWrite);
|
||||
extractTableName(pMeter->pTagData, pWrite);
|
||||
}
|
||||
cols++;
|
||||
|
||||
|
@ -1389,7 +1393,7 @@ int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
|
|||
pShow->pNode = (void *)pMetric->next;
|
||||
|
||||
memset(metricName, 0, tListLen(metricName));
|
||||
extractMeterName(pMetric->meterId, metricName);
|
||||
extractTableName(pMetric->meterId, metricName);
|
||||
|
||||
if (pShow->payloadLen > 0 &&
|
||||
patternMatch(pShow->payload, metricName, TSDB_METER_NAME_LEN, &info) != TSDB_PATTERN_MATCH)
|
||||
|
@ -1398,7 +1402,7 @@ int mgmtRetrieveMetrics(SShowObj *pShow, char *data, int rows, SConnObj *pConn)
|
|||
cols = 0;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
extractMeterName(pMetric->meterId, pWrite);
|
||||
extractTableName(pMetric->meterId, pWrite);
|
||||
cols++;
|
||||
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "mgmtProfile.h"
|
||||
#include "taosmsg.h"
|
||||
#include "tlog.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
#define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN)
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ static bool mgmtTablenameFilterCallback(tSkipListNode* pNode, void* param) {
|
|||
|
||||
// pattern compare for meter name
|
||||
STabObj* pMeterObj = (STabObj*)pNode->pData;
|
||||
extractMeterName(pMeterObj->meterId, name);
|
||||
extractTableName(pMeterObj->meterId, name);
|
||||
|
||||
return patternMatch(pSupporter->pattern, name, TSDB_METER_ID_LEN, &pSupporter->info) == TSDB_PATTERN_MATCH;
|
||||
}
|
||||
|
@ -786,7 +786,7 @@ int mgmtRetrieveMetersFromMetric(SMetricMetaMsg* pMsg, int32_t tableIndex, tQuer
|
|||
// todo refactor!!!!!
|
||||
static char* getTagValueFromMeter(STabObj* pMeter, int32_t offset, int32_t len, char* param) {
|
||||
if (offset == TSDB_TBNAME_COLUMN_INDEX) {
|
||||
extractMeterName(pMeter->meterId, param);
|
||||
extractTableName(pMeter->meterId, param);
|
||||
} else {
|
||||
char* tags = pMeter->pTagData + offset + TSDB_METER_ID_LEN; // tag start position
|
||||
memcpy(param, tags, len); // make sure the value is null-terminated string
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mgmt.h"
|
||||
#include "tschemautil.h"
|
||||
#include "tlog.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
void * vgSdb = NULL;
|
||||
int tsVgUpdateSize;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "vnode.h"
|
||||
#include "vnodeCache.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
void vnodeSearchPointInCache(SMeterObj *pObj, SQuery *pQuery);
|
||||
void vnodeProcessCommitTimer(void *param, void *tmrId);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "tsdb.h"
|
||||
#include "vnode.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
typedef struct {
|
||||
int sversion;
|
||||
|
@ -165,7 +166,7 @@ size_t vnodeRestoreDataFromLog(int vnode, char *fileName, uint64_t *firstV) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPING)) {
|
||||
dWarn("vid:%d sid:%d id:%s, meter is dropped, ignore data in commit log, contLen:%d action:%d",
|
||||
vnode, head.sid, head.contLen, head.action);
|
||||
continue;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "vnode.h"
|
||||
#include "vnodeFile.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
#define FILE_QUERY_NEW_BLOCK -5 // a special negative number
|
||||
|
||||
|
@ -611,7 +612,7 @@ _again:
|
|||
}
|
||||
|
||||
// meter is going to be deleted, abort
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPING)) {
|
||||
dWarn("vid:%d sid:%d is dropped, ignore this meter", vnode, sid);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "vnode.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
extern void vnodeGetHeadTname(char *nHeadName, char *nLastName, int vnode, int fileId);
|
||||
extern int vnodeReadColumnToMem(int fd, SCompBlock *pBlock, SField **fields, int col, char *data, int dataSize,
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "vnodeMgmt.h"
|
||||
#include "vnodeShell.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
#define VALID_TIMESTAMP(key, curKey, prec) (((key) >= 0) && ((key) <= ((curKey) + 36500 * tsMsPerDay[prec])))
|
||||
|
||||
|
@ -520,7 +520,7 @@ int vnodeRemoveMeterObj(int vnode, int sid) {
|
|||
}
|
||||
|
||||
// after remove this meter, change its state to DELETED
|
||||
pObj->state = TSDB_METER_STATE_DELETED;
|
||||
pObj->state = TSDB_METER_STATE_DROPPED;
|
||||
pObj->timeStamp = taosGetTimestampMs();
|
||||
vnodeList[vnode].lastRemove = pObj->timeStamp;
|
||||
|
||||
|
@ -612,12 +612,12 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
return TSDB_CODE_TIMESTAMP_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
if ((code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_INSERT)) != TSDB_CODE_SUCCESS) {
|
||||
if ((code = vnodeSetMeterInsertImportStateEx(pObj, TSDB_METER_STATE_INSERTING)) != TSDB_CODE_SUCCESS) {
|
||||
goto _over;
|
||||
}
|
||||
|
||||
for (i = 0; i < numOfPoints; ++i) { // meter will be dropped, abort current insertion
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPING)) {
|
||||
dWarn("vid:%d sid:%d id:%s, meter is dropped, abort insert, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
|
||||
pObj->state);
|
||||
|
||||
|
@ -660,7 +660,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi
|
|||
|
||||
pthread_mutex_unlock(&(pVnode->vmutex));
|
||||
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERT);
|
||||
vnodeClearMeterState(pObj, TSDB_METER_STATE_INSERTING);
|
||||
|
||||
_over:
|
||||
dTrace("vid:%d sid:%d id:%s, %d out of %d points are inserted, lastKey:%ld source:%d, vnode total storage: %ld",
|
||||
|
@ -726,7 +726,7 @@ void vnodeUpdateMeter(void *param, void *tmrId) {
|
|||
}
|
||||
|
||||
SMeterObj *pObj = pVnode->meterList[pNew->sid];
|
||||
if (pObj == NULL || vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
|
||||
if (pObj == NULL || vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPING)) {
|
||||
dTrace("vid:%d sid:%d id:%s, meter is deleted, abort update schema", pNew->vnode, pNew->sid, pNew->meterId);
|
||||
free(pNew->schema);
|
||||
free(pNew);
|
||||
|
@ -734,7 +734,7 @@ void vnodeUpdateMeter(void *param, void *tmrId) {
|
|||
}
|
||||
|
||||
int32_t state = vnodeSetMeterState(pObj, TSDB_METER_STATE_UPDATING);
|
||||
if (state >= TSDB_METER_STATE_DELETING) {
|
||||
if (state >= TSDB_METER_STATE_DROPPING) {
|
||||
dError("vid:%d sid:%d id:%s, meter is deleted, failed to update, state:%d",
|
||||
pObj->vnode, pObj->sid, pObj->meterId, state);
|
||||
return;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "vnodeDataFilterFunc.h"
|
||||
#include "vnodeFile.h"
|
||||
#include "vnodeQueryImpl.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
enum {
|
||||
TS_JOIN_TS_EQUAL = 0,
|
||||
|
@ -47,8 +48,7 @@ enum {
|
|||
#define IS_DISK_DATA_BLOCK(q) ((q)->fileId >= 0)
|
||||
|
||||
// static int32_t copyDataFromMMapBuffer(int fd, SQInfo *pQInfo, SQueryFilesInfo *pQueryFile, char *buf, uint64_t
|
||||
// offset,
|
||||
// int32_t size);
|
||||
// offset, int32_t size);
|
||||
static int32_t readDataFromDiskFile(int fd, SQInfo *pQInfo, SQueryFilesInfo *pQueryFile, char *buf, uint64_t offset,
|
||||
int32_t size);
|
||||
|
||||
|
@ -2304,7 +2304,7 @@ bool isQueryKilled(SQuery *pQuery) {
|
|||
* if it will be deleted soon, stop current query ASAP.
|
||||
*/
|
||||
SMeterObj *pMeterObj = pQInfo->pObj;
|
||||
if (vnodeIsMeterState(pMeterObj, TSDB_METER_STATE_DELETING)) {
|
||||
if (vnodeIsMeterState(pMeterObj, TSDB_METER_STATE_DROPPING)) {
|
||||
pQInfo->killed = 1;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include "taosmsg.h"
|
||||
#include "tsdb.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
const char* taosGetVgroupStatusStr(int vgroupStatus) {
|
||||
const char* taosGetVgroupStatusStr(int32_t vgroupStatus) {
|
||||
switch (vgroupStatus) {
|
||||
case TSDB_VG_STATUS_READY: return "ready";
|
||||
case TSDB_VG_STATUS_IN_PROGRESS: return "inprogress";
|
||||
|
@ -28,7 +28,7 @@ const char* taosGetVgroupStatusStr(int vgroupStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetDbStatusStr(int dbStatus) {
|
||||
const char* taosGetDbStatusStr(int32_t dbStatus) {
|
||||
switch (dbStatus) {
|
||||
case TSDB_DB_STATUS_READY: return "ready";
|
||||
case TSDB_DB_STATUS_DROPPING: return "dropping";
|
||||
|
@ -37,7 +37,7 @@ const char* taosGetDbStatusStr(int dbStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetVnodeStatusStr(int vnodeStatus) {
|
||||
const char* taosGetVnodeStatusStr(int32_t vnodeStatus) {
|
||||
switch (vnodeStatus) {
|
||||
case TSDB_VN_STATUS_OFFLINE: return "offline";
|
||||
case TSDB_VN_STATUS_CREATING: return "creating";
|
||||
|
@ -50,7 +50,7 @@ const char* taosGetVnodeStatusStr(int vnodeStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus) {
|
||||
const char* taosGetVnodeSyncStatusStr(int32_t vnodeSyncStatus) {
|
||||
switch (vnodeSyncStatus) {
|
||||
case TSDB_VN_SYNC_STATUS_INIT: return "init";
|
||||
case TSDB_VN_SYNC_STATUS_SYNCING: return "syncing";
|
||||
|
@ -60,7 +60,7 @@ const char* taosGetVnodeSyncStatusStr(int vnodeSyncStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetVnodeDropStatusStr(int dropping) {
|
||||
const char* taosGetVnodeDropStatusStr(int32_t dropping) {
|
||||
switch (dropping) {
|
||||
case TSDB_VN_DROP_STATUS_READY: return "ready";
|
||||
case TSDB_VN_DROP_STATUS_DROPPING: return "dropping";
|
||||
|
@ -68,7 +68,7 @@ const char* taosGetVnodeDropStatusStr(int dropping) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetDnodeStatusStr(int dnodeStatus) {
|
||||
const char* taosGetDnodeStatusStr(int32_t dnodeStatus) {
|
||||
switch (dnodeStatus) {
|
||||
case TSDB_DN_STATUS_OFFLINE: return "offline";
|
||||
case TSDB_DN_STATUS_READY: return "ready";
|
||||
|
@ -76,7 +76,7 @@ const char* taosGetDnodeStatusStr(int dnodeStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetDnodeLbStatusStr(int dnodeBalanceStatus) {
|
||||
const char* taosGetDnodeLbStatusStr(int32_t dnodeBalanceStatus) {
|
||||
switch (dnodeBalanceStatus) {
|
||||
case TSDB_DN_LB_STATUS_BALANCED: return "balanced";
|
||||
case TSDB_DN_LB_STATUS_BALANCING: return "balancing";
|
||||
|
@ -86,7 +86,7 @@ const char* taosGetDnodeLbStatusStr(int dnodeBalanceStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetVgroupLbStatusStr(int vglbStatus) {
|
||||
const char* taosGetVgroupLbStatusStr(int32_t vglbStatus) {
|
||||
switch (vglbStatus) {
|
||||
case TSDB_VG_LB_STATUS_READY: return "ready";
|
||||
case TSDB_VG_LB_STATUS_UPDATE: return "updating";
|
||||
|
@ -94,10 +94,22 @@ const char* taosGetVgroupLbStatusStr(int vglbStatus) {
|
|||
}
|
||||
}
|
||||
|
||||
const char* taosGetVnodeStreamStatusStr(int vnodeStreamStatus) {
|
||||
const char* taosGetVnodeStreamStatusStr(int32_t vnodeStreamStatus) {
|
||||
switch (vnodeStreamStatus) {
|
||||
case TSDB_VN_STREAM_STATUS_START: return "start";
|
||||
case TSDB_VN_STREAM_STATUS_STOP: return "stop";
|
||||
default: return "undefined";
|
||||
}
|
||||
}
|
||||
|
||||
const char* taosGetTableStatusStr(int32_t tableStatus) {
|
||||
switch(tableStatus) {
|
||||
case TSDB_METER_STATE_INSERTING: return "inserting";
|
||||
case TSDB_METER_STATE_IMPORTING:return "importing";
|
||||
case TSDB_METER_STATE_UPDATING: return "updating";
|
||||
case TSDB_METER_STATE_DROPPING: return "deleting";
|
||||
case TSDB_METER_STATE_DROPPED: return "dropped";
|
||||
case TSDB_METER_STATE_READY: return "ready";
|
||||
default:return "undefined";
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@
|
|||
#include "vnode.h"
|
||||
#include "vnodeStore.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
int tsMaxVnode = -1;
|
||||
int tsOpenVnodes = 0;
|
||||
|
@ -118,7 +118,7 @@ static int32_t vnodeMarkAllMetersDropped(SVnodeObj* pVnode) {
|
|||
} else { // set the meter is to be deleted
|
||||
SMeterObj* pObj = pVnode->meterList[sid];
|
||||
if (pObj != NULL) {
|
||||
pObj->state = TSDB_METER_STATE_DELETED;
|
||||
pObj->state = TSDB_METER_STATE_DROPPED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "taosmsg.h"
|
||||
#include "vnode.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
/* static TAOS *dbConn = NULL; */
|
||||
void vnodeCloseStreamCallback(void *param);
|
||||
|
@ -86,7 +86,7 @@ void vnodeOpenStreams(void *param, void *tmrId) {
|
|||
|
||||
for (int sid = 0; sid < pVnode->cfg.maxSessions; ++sid) {
|
||||
pObj = pVnode->meterList[sid];
|
||||
if (pObj == NULL || pObj->sqlLen == 0 || vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) continue;
|
||||
if (pObj == NULL || pObj->sqlLen == 0 || vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPING)) continue;
|
||||
|
||||
dTrace("vid:%d sid:%d id:%s, open stream:%s", pObj->vnode, sid, pObj->meterId, pObj->pSql);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "vnode.h"
|
||||
#include "vnodeDataFilterFunc.h"
|
||||
#include "vnodeUtil.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
int vnodeCheckFileIntegrity(FILE* fp) {
|
||||
/*
|
||||
|
@ -547,30 +548,38 @@ int32_t vnodeIncQueryRefCount(SQueryMeterMsg* pQueryMsg, SMeterSidExtInfo** pSid
|
|||
for (int32_t i = 0; i < pQueryMsg->numOfSids; ++i) {
|
||||
SMeterObj* pMeter = pVnode->meterList[pSids[i]->sid];
|
||||
|
||||
if (pMeter == NULL || (pMeter->state > TSDB_METER_STATE_INSERT)) {
|
||||
if (pMeter == NULL || vnodeIsMeterState(pMeter, TSDB_METER_STATE_DELETING)) {
|
||||
code = TSDB_CODE_NOT_ACTIVE_TABLE;
|
||||
dError("qmsg:%p, vid:%d sid:%d, not there or will be dropped", pQueryMsg, pQueryMsg->vnode, pSids[i]->sid);
|
||||
vnodeSendMeterCfgMsg(pQueryMsg->vnode, pSids[i]->sid);
|
||||
} else {//update or import
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
dTrace("qmsg:%p, vid:%d sid:%d id:%s, it is in state:%d, wait!", pQueryMsg, pQueryMsg->vnode, pSids[i]->sid,
|
||||
pMeter->meterId, pMeter->state);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* vnodeIsSafeToDeleteMeter will wait for this function complete, and then it can
|
||||
* check if the numOfQueries is 0 or not.
|
||||
*/
|
||||
pMeterObjList[(*numOfInc)++] = pMeter;
|
||||
atomic_fetch_add_32(&pMeter->numOfQueries, 1);
|
||||
if (pMeter == NULL || vnodeIsMeterState(pMeter, TSDB_METER_STATE_DROPPING)) {
|
||||
code = TSDB_CODE_NOT_ACTIVE_TABLE;
|
||||
dError("qmsg:%p, vid:%d sid:%d, not there or will be dropped", pQueryMsg, pQueryMsg->vnode, pSids[i]->sid);
|
||||
|
||||
vnodeSendMeterCfgMsg(pQueryMsg->vnode, pSids[i]->sid);
|
||||
continue;
|
||||
} else if (pMeter->uid != pSids[i]->uid || pMeter->sid != pSids[i]->sid) {
|
||||
code = TSDB_CODE_TABLE_ID_MISMATCH;
|
||||
dError("qmsg:%p, vid:%d sid:%d id:%s uid:%lld, id mismatch. sid:%d uid:%lld in msg", pQueryMsg,
|
||||
pQueryMsg->vnode, pMeter->sid, pMeter->meterId, pMeter->uid, pSids[i]->sid, pSids[i]->uid);
|
||||
|
||||
vnodeSendMeterCfgMsg(pQueryMsg->vnode, pSids[i]->sid);
|
||||
continue;
|
||||
} else if (pMeter->state > TSDB_METER_STATE_INSERTING) { //update or import
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
dTrace("qmsg:%p, vid:%d sid:%d id:%s, it is in state:%s, wait!", pQueryMsg, pQueryMsg->vnode, pSids[i]->sid,
|
||||
pMeter->meterId, taosGetTableStatusStr(pMeter->state));
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* vnodeIsSafeToDeleteMeter will wait for this function complete, and then it can
|
||||
* check if the numOfQueries is 0 or not.
|
||||
*/
|
||||
pMeterObjList[(*numOfInc)++] = pMeter;
|
||||
atomic_fetch_add_32(&pMeter->numOfQueries, 1);
|
||||
|
||||
// output for meter more than one query executed
|
||||
if (pMeter->numOfQueries > 1) {
|
||||
dTrace("qmsg:%p, vid:%d sid:%d id:%s, inc query ref, numOfQueries:%d", pQueryMsg, pMeter->vnode, pMeter->sid,
|
||||
pMeter->meterId, pMeter->numOfQueries);
|
||||
num++;
|
||||
}
|
||||
// output for meter more than one query executed
|
||||
if (pMeter->numOfQueries > 1) {
|
||||
dTrace("qmsg:%p, vid:%d sid:%d id:%s, inc query ref, numOfQueries:%d", pQueryMsg, pMeter->vnode, pMeter->sid,
|
||||
pMeter->meterId, pMeter->numOfQueries);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -652,7 +661,7 @@ void vnodeClearMeterState(SMeterObj* pMeterObj, int32_t state) {
|
|||
bool vnodeIsMeterState(SMeterObj* pMeterObj, int32_t state) {
|
||||
if (state == TSDB_METER_STATE_READY) {
|
||||
return pMeterObj->state == TSDB_METER_STATE_READY;
|
||||
} else if (state == TSDB_METER_STATE_DELETING) {
|
||||
} else if (state == TSDB_METER_STATE_DROPPING) {
|
||||
return pMeterObj->state >= state;
|
||||
} else {
|
||||
return (((pMeterObj->state) & state) == state);
|
||||
|
@ -664,7 +673,7 @@ void vnodeSetMeterDeleting(SMeterObj* pMeterObj) {
|
|||
return;
|
||||
}
|
||||
|
||||
pMeterObj->state |= TSDB_METER_STATE_DELETING;
|
||||
pMeterObj->state |= TSDB_METER_STATE_DROPPING;
|
||||
}
|
||||
|
||||
int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
|
||||
|
@ -672,7 +681,7 @@ int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
|
|||
|
||||
int32_t state = vnodeSetMeterState(pObj, st);
|
||||
if (state != TSDB_METER_STATE_READY) {//return to denote import is not performed
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETING)) {
|
||||
if (vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPING)) {
|
||||
dTrace("vid:%d sid:%d id:%s, meter is deleted, state:%d", pObj->vnode, pObj->sid, pObj->meterId,
|
||||
pObj->state);
|
||||
code = TSDB_CODE_NOT_ACTIVE_TABLE;
|
||||
|
@ -690,17 +699,17 @@ int32_t vnodeSetMeterInsertImportStateEx(SMeterObj* pObj, int32_t st) {
|
|||
bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid) {
|
||||
SMeterObj* pObj = pVnode->meterList[sid];
|
||||
|
||||
if (pObj == NULL || vnodeIsMeterState(pObj, TSDB_METER_STATE_DELETED)) {
|
||||
if (pObj == NULL || vnodeIsMeterState(pObj, TSDB_METER_STATE_DROPPED)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t prev = vnodeSetMeterState(pObj, TSDB_METER_STATE_DELETING);
|
||||
int32_t prev = vnodeSetMeterState(pObj, TSDB_METER_STATE_DROPPING);
|
||||
|
||||
/*
|
||||
* if the meter is not in ready/deleting state, it must be in insert/import/update,
|
||||
* set the deleting state and wait the procedure to be completed
|
||||
*/
|
||||
if (prev != TSDB_METER_STATE_READY && prev < TSDB_METER_STATE_DELETING) {
|
||||
if (prev != TSDB_METER_STATE_READY && prev < TSDB_METER_STATE_DROPPING) {
|
||||
vnodeSetMeterDeleting(pObj);
|
||||
|
||||
dWarn("vid:%d sid:%d id:%s, can not be deleted, state:%d, wait", pObj->vnode, pObj->sid, pObj->meterId, prev);
|
||||
|
@ -710,7 +719,7 @@ bool vnodeIsSafeToDeleteMeter(SVnodeObj* pVnode, int32_t sid) {
|
|||
bool ready = true;
|
||||
|
||||
/*
|
||||
* the query will be stopped ASAP, since the state of meter is set to TSDB_METER_STATE_DELETING,
|
||||
* the query will be stopped ASAP, since the state of meter is set to TSDB_METER_STATE_DROPPING,
|
||||
* and new query will abort since the meter is deleted.
|
||||
*/
|
||||
pthread_mutex_lock(&pVnode->vmutex);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mgmtBalance.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
void mgmtStartBalanceTimer(int64_t mseconds) {}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mgmt.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
SDnodeObj dnodeObj;
|
||||
extern uint32_t tsRebootTime;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "tutil.h"
|
||||
#include "vnode.h"
|
||||
#include "tsystem.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
extern void *dmQhandle;
|
||||
void * mgmtStatusTimer = NULL;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "vnode.h"
|
||||
#include "tstatus.h"
|
||||
#include "vnodeStatus.h"
|
||||
|
||||
int vnodeInitPeer(int numOfThreads) { return 0; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue