Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
24042fff
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
24042fff
编写于
7月 11, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into enh/stopquery_a
上级
d8be162b
4ecbfd07
变更
60
隐藏空白更改
内联
并排
Showing
60 changed file
with
1445 addition
and
443 deletion
+1445
-443
include/util/tlockfree.h
include/util/tlockfree.h
+8
-7
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+33
-30
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-0
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+12
-2
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+1
-1
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+2
-0
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+483
-23
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+0
-2
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+33
-26
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+3
-1
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+7
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+16
-18
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+4
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+4
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+109
-69
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+1
-0
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+6
-6
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+1
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+21
-18
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+4
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+11
-6
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+1
-1
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+31
-32
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+27
-18
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+2
-0
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+4
-0
source/libs/qworker/inc/qwInt.h
source/libs/qworker/inc/qwInt.h
+16
-16
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+2
-1
source/libs/scheduler/inc/schInt.h
source/libs/scheduler/inc/schInt.h
+43
-3
source/libs/scheduler/src/schDbg.c
source/libs/scheduler/src/schDbg.c
+1
-0
source/libs/scheduler/src/schJob.c
source/libs/scheduler/src/schJob.c
+7
-2
source/libs/scheduler/src/schTask.c
source/libs/scheduler/src/schTask.c
+3
-2
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+2
-2
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+1
-1
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+2
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+23
-12
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+4
-4
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+8
-8
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+10
-7
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+10
-6
source/libs/sync/src/syncRequestVoteReply.c
source/libs/sync/src/syncRequestVoteReply.c
+5
-4
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+8
-4
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+13
-9
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+14
-10
source/libs/sync/test/syncEntryCacheTest.cpp
source/libs/sync/test/syncEntryCacheTest.cpp
+121
-4
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+10
-7
source/libs/sync/test/syncRespMgrTest.cpp
source/libs/sync/test/syncRespMgrTest.cpp
+2
-2
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+8
-6
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+18
-7
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+8
-6
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+14
-16
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+32
-13
source/util/src/tlockfree.c
source/util/src/tlockfree.c
+40
-11
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-2
tests/script/tsim/sync/vnodesnapshot-test.sim
tests/script/tsim/sync/vnodesnapshot-test.sim
+178
-0
tests/system-test/2-query/function_diff.py
tests/system-test/2-query/function_diff.py
+5
-5
tests/system-test/2-query/mavg.py
tests/system-test/2-query/mavg.py
+5
-5
tests/system-test/2-query/queryQnode.py
tests/system-test/2-query/queryQnode.py
+3
-3
未找到文件。
include/util/tlockfree.h
浏览文件 @
24042fff
...
@@ -69,13 +69,14 @@ typedef void (*_ref_fn_t)(const void *pObj);
...
@@ -69,13 +69,14 @@ typedef void (*_ref_fn_t)(const void *pObj);
#define T_REF_VAL_GET(x) (x)->_ref.val
#define T_REF_VAL_GET(x) (x)->_ref.val
// single writer multiple reader lock
// single writer multiple reader lock
typedef
volatile
int32_t
SRWLatch
;
typedef
volatile
int64_t
SRWLatch
;
void
taosInitRWLatch
(
SRWLatch
*
pLatch
);
void
taosInitRWLatch
(
SRWLatch
*
pLatch
);
void
taosWLockLatch
(
SRWLatch
*
pLatch
);
void
taosInitReentrantRWLatch
(
SRWLatch
*
pLatch
);
void
taosWUnLockLatch
(
SRWLatch
*
pLatch
);
void
taosWLockLatch
(
SRWLatch
*
pLatch
);
void
taosRLockLatch
(
SRWLatch
*
pLatch
);
void
taosWUnLockLatch
(
SRWLatch
*
pLatch
);
void
taosRUnLockLatch
(
SRWLatch
*
pLatch
);
void
taosRLockLatch
(
SRWLatch
*
pLatch
);
void
taosRUnLockLatch
(
SRWLatch
*
pLatch
);
int32_t
taosWTryLockLatch
(
SRWLatch
*
pLatch
);
int32_t
taosWTryLockLatch
(
SRWLatch
*
pLatch
);
// copy on read
// copy on read
...
...
source/client/src/clientImpl.c
浏览文件 @
24042fff
...
@@ -148,7 +148,8 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
...
@@ -148,7 +148,8 @@ STscObj* taos_connect_internal(const char* ip, const char* user, const char* pas
return
taosConnectImpl
(
user
,
&
secretEncrypt
[
0
],
localDb
,
NULL
,
NULL
,
*
pInst
,
connType
);
return
taosConnectImpl
(
user
,
&
secretEncrypt
[
0
],
localDb
,
NULL
,
NULL
,
*
pInst
,
connType
);
}
}
int32_t
buildRequest
(
uint64_t
connId
,
const
char
*
sql
,
int
sqlLen
,
void
*
param
,
bool
validateSql
,
SRequestObj
**
pRequest
)
{
int32_t
buildRequest
(
uint64_t
connId
,
const
char
*
sql
,
int
sqlLen
,
void
*
param
,
bool
validateSql
,
SRequestObj
**
pRequest
)
{
*
pRequest
=
createRequest
(
connId
,
TSDB_SQL_SELECT
);
*
pRequest
=
createRequest
(
connId
,
TSDB_SQL_SELECT
);
if
(
*
pRequest
==
NULL
)
{
if
(
*
pRequest
==
NULL
)
{
tscError
(
"failed to malloc sqlObj, %s"
,
sql
);
tscError
(
"failed to malloc sqlObj, %s"
,
sql
);
...
@@ -165,7 +166,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
...
@@ -165,7 +166,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
strntolower
((
*
pRequest
)
->
sqlstr
,
sql
,
(
int32_t
)
sqlLen
);
strntolower
((
*
pRequest
)
->
sqlstr
,
sql
,
(
int32_t
)
sqlLen
);
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlstr
[
sqlLen
]
=
0
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
(
*
pRequest
)
->
sqlLen
=
sqlLen
;
(
*
pRequest
)
->
validateOnly
=
validateSql
;
(
*
pRequest
)
->
validateOnly
=
validateSql
;
if
(
param
==
NULL
)
{
if
(
param
==
NULL
)
{
...
@@ -351,7 +352,8 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
...
@@ -351,7 +352,8 @@ int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList) {
if
(
pNodeList
)
{
if
(
pNodeList
)
{
pInfo
->
pQnodeList
=
taosArrayDup
(
pNodeList
);
pInfo
->
pQnodeList
=
taosArrayDup
(
pNodeList
);
taosArraySort
(
pInfo
->
pQnodeList
,
compareQueryNodeLoad
);
taosArraySort
(
pInfo
->
pQnodeList
,
compareQueryNodeLoad
);
tscDebug
(
"QnodeList updated in cluster 0x%"
PRIx64
", num:%d"
,
pInfo
->
clusterId
,
taosArrayGetSize
(
pInfo
->
pQnodeList
));
tscDebug
(
"QnodeList updated in cluster 0x%"
PRIx64
", num:%d"
,
pInfo
->
clusterId
,
taosArrayGetSize
(
pInfo
->
pQnodeList
));
}
}
taosThreadMutexUnlock
(
&
pInfo
->
qnodeMutex
);
taosThreadMutexUnlock
(
&
pInfo
->
qnodeMutex
);
...
@@ -649,22 +651,22 @@ _return:
...
@@ -649,22 +651,22 @@ _return:
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
SExecResult
res
=
{
0
};
SExecResult
res
=
{
0
};
SRequestConnInfo
conn
=
{.
pTrans
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
SRequestConnInfo
conn
=
{.
pTrans
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
.
requestObjRefId
=
pRequest
->
self
};
SSchedulerReq
req
=
{
SSchedulerReq
req
=
{
.
syncReq
=
true
,
.
syncReq
=
true
,
.
pConn
=
&
conn
,
.
pConn
=
&
conn
,
.
pNodeList
=
pNodeList
,
.
pNodeList
=
pNodeList
,
.
pDag
=
pDag
,
.
pDag
=
pDag
,
.
sql
=
pRequest
->
sqlstr
,
.
sql
=
pRequest
->
sqlstr
,
.
startTs
=
pRequest
->
metric
.
start
,
.
startTs
=
pRequest
->
metric
.
start
,
.
execFp
=
NULL
,
.
execFp
=
NULL
,
.
cbParam
=
NULL
,
.
cbParam
=
NULL
,
.
chkKillFp
=
chkRequestKilled
,
.
chkKillFp
=
chkRequestKilled
,
.
chkKillParam
=
(
void
*
)
pRequest
->
self
,
.
chkKillParam
=
(
void
*
)
pRequest
->
self
,
.
pExecRes
=
&
res
,
.
pExecRes
=
&
res
,
};
};
int32_t
code
=
schedulerExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
int32_t
code
=
schedulerExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
...
@@ -778,7 +780,7 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
...
@@ -778,7 +780,7 @@ int32_t handleQueryExecRsp(SRequestObj* pRequest) {
return
code
;
return
code
;
}
}
SEpSet
epset
=
getEpSet_s
(
&
pAppInfo
->
mgmtEp
);
SEpSet
epset
=
getEpSet_s
(
&
pAppInfo
->
mgmtEp
);
SExecResult
*
pRes
=
&
pRequest
->
body
.
resInfo
.
execRes
;
SExecResult
*
pRes
=
&
pRequest
->
body
.
resInfo
.
execRes
;
switch
(
pRes
->
msgType
)
{
switch
(
pRes
->
msgType
)
{
...
@@ -969,17 +971,17 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM
...
@@ -969,17 +971,17 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM
SRequestConnInfo
conn
=
{
SRequestConnInfo
conn
=
{
.
pTrans
=
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
.
pTrans
=
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
SSchedulerReq
req
=
{
SSchedulerReq
req
=
{
.
syncReq
=
false
,
.
syncReq
=
false
,
.
pConn
=
&
conn
,
.
pConn
=
&
conn
,
.
pNodeList
=
pNodeList
,
.
pNodeList
=
pNodeList
,
.
pDag
=
pDag
,
.
pDag
=
pDag
,
.
sql
=
pRequest
->
sqlstr
,
.
sql
=
pRequest
->
sqlstr
,
.
startTs
=
pRequest
->
metric
.
start
,
.
startTs
=
pRequest
->
metric
.
start
,
.
execFp
=
schedulerExecCb
,
.
execFp
=
schedulerExecCb
,
.
cbParam
=
pRequest
,
.
cbParam
=
pRequest
,
.
chkKillFp
=
chkRequestKilled
,
.
chkKillFp
=
chkRequestKilled
,
.
chkKillParam
=
(
void
*
)
pRequest
->
self
,
.
chkKillParam
=
(
void
*
)
pRequest
->
self
,
.
pExecRes
=
NULL
,
.
pExecRes
=
NULL
,
};
};
code
=
schedulerExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
code
=
schedulerExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
taosArrayDestroy
(
pNodeList
);
taosArrayDestroy
(
pNodeList
);
...
@@ -998,6 +1000,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM
...
@@ -998,6 +1000,7 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
0
);
break
;
break
;
default:
default:
pRequest
->
body
.
queryFp
(
pRequest
->
body
.
param
,
pRequest
,
-
1
);
break
;
break
;
}
}
...
@@ -1421,9 +1424,9 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
...
@@ -1421,9 +1424,9 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4)
}
}
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
SSchedulerReq
req
=
{
SSchedulerReq
req
=
{
.
syncReq
=
true
,
.
syncReq
=
true
,
.
pFetchRes
=
(
void
**
)
&
pResInfo
->
pData
,
.
pFetchRes
=
(
void
**
)
&
pResInfo
->
pData
,
};
};
pRequest
->
code
=
schedulerFetchRows
(
pRequest
->
body
.
queryJob
,
&
req
);
pRequest
->
code
=
schedulerFetchRows
(
pRequest
->
body
.
queryJob
,
&
req
);
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pRequest
->
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/common/src/tdatablock.c
浏览文件 @
24042fff
...
@@ -463,6 +463,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
...
@@ -463,6 +463,7 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
pDst
->
info
=
pBlock
->
info
;
pDst
->
info
=
pBlock
->
info
;
pDst
->
info
.
rows
=
0
;
pDst
->
info
.
rows
=
0
;
pDst
->
info
.
capacity
=
0
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
colInfo
=
{
0
};
SColumnInfoData
colInfo
=
{
0
};
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
24042fff
...
@@ -527,10 +527,20 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
...
@@ -527,10 +527,20 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea
streamObj
.
version
=
1
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
smaId
=
smaObj
.
uid
;
streamObj
.
smaId
=
smaObj
.
uid
;
streamObj
.
watermark
=
0
;
streamObj
.
watermark
=
pCreate
->
watermark
;
streamObj
.
trigger
=
STREAM_TRIGGER_AT_ONCE
;
streamObj
.
trigger
=
STREAM_TRIGGER_WINDOW_CLOSE
;
streamObj
.
triggerParam
=
pCreate
->
maxDelay
;
streamObj
.
ast
=
strdup
(
smaObj
.
ast
);
streamObj
.
ast
=
strdup
(
smaObj
.
ast
);
// check the maxDelay
if
(
streamObj
.
triggerParam
<
TSDB_MIN_ROLLUP_MAX_DELAY
)
{
int64_t
msInterval
=
convertTimeFromPrecisionToUnit
(
pCreate
->
interval
,
pDb
->
cfg
.
precision
,
TIME_UNIT_MILLISECOND
);
streamObj
.
triggerParam
=
msInterval
>
TSDB_MIN_ROLLUP_MAX_DELAY
?
msInterval
:
TSDB_MIN_ROLLUP_MAX_DELAY
;
}
if
(
streamObj
.
triggerParam
>
TSDB_MAX_ROLLUP_MAX_DELAY
)
{
streamObj
.
triggerParam
=
TSDB_MAX_ROLLUP_MAX_DELAY
;
}
if
(
mndAllocSmaVgroup
(
pMnode
,
pDb
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
{
if
(
mndAllocSmaVgroup
(
pMnode
,
pDb
,
&
streamObj
.
fixedSinkVg
)
!=
0
)
{
mError
(
"sma:%s, failed to create since %s"
,
smaObj
.
name
,
terrstr
());
mError
(
"sma:%s, failed to create since %s"
,
smaObj
.
name
,
terrstr
());
return
-
1
;
return
-
1
;
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
24042fff
...
@@ -238,7 +238,7 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx, uint8_t **ppBuf);
...
@@ -238,7 +238,7 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx, uint8_t **ppBuf);
// tsdbCache
// tsdbCache
int32_t
tsdbOpenCache
(
STsdb
*
pTsdb
);
int32_t
tsdbOpenCache
(
STsdb
*
pTsdb
);
void
tsdbCloseCache
(
SLRUCache
*
pCache
);
void
tsdbCloseCache
(
SLRUCache
*
pCache
);
int32_t
tsdbCacheInsertLast
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STSRow
*
row
);
int32_t
tsdbCacheInsertLast
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STSRow
*
row
,
STsdb
*
pTsdb
);
int32_t
tsdbCacheInsertLastrow
(
SLRUCache
*
pCache
,
STsdb
*
pTsdb
,
tb_uid_t
uid
,
STSRow
*
row
,
bool
dup
);
int32_t
tsdbCacheInsertLastrow
(
SLRUCache
*
pCache
,
STsdb
*
pTsdb
,
tb_uid_t
uid
,
STSRow
*
row
,
bool
dup
);
int32_t
tsdbCacheGetLastH
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
LRUHandle
**
h
);
int32_t
tsdbCacheGetLastH
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
LRUHandle
**
h
);
int32_t
tsdbCacheGetLastrowH
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
LRUHandle
**
h
);
int32_t
tsdbCacheGetLastrowH
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STsdb
*
pTsdb
,
LRUHandle
**
h
);
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
24042fff
...
@@ -147,6 +147,8 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
...
@@ -147,6 +147,8 @@ int metaTbCursorNext(SMTbCursor *pTbCur) {
return
-
1
;
return
-
1
;
}
}
tDecoderClear
(
&
pTbCur
->
mr
.
coder
);
metaGetTableEntryByVersion
(
&
pTbCur
->
mr
,
*
(
int64_t
*
)
pTbCur
->
pVal
,
*
(
tb_uid_t
*
)
pTbCur
->
pKey
);
metaGetTableEntryByVersion
(
&
pTbCur
->
mr
,
*
(
int64_t
*
)
pTbCur
->
pVal
,
*
(
tb_uid_t
*
)
pTbCur
->
pKey
);
if
(
pTbCur
->
mr
.
me
.
type
==
TSDB_SUPER_TABLE
)
{
if
(
pTbCur
->
mr
.
me
.
type
==
TSDB_SUPER_TABLE
)
{
continue
;
continue
;
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
24042fff
...
@@ -173,20 +173,64 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
...
@@ -173,20 +173,64 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST
return
code
;
return
code
;
}
}
int32_t
tsdbCacheInsertLast
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STSRow
*
row
)
{
typedef
struct
{
TSKEY
ts
;
SColVal
colVal
;
}
SLastCol
;
int32_t
tsdbCacheInsertLast
(
SLRUCache
*
pCache
,
tb_uid_t
uid
,
STSRow
*
row
,
STsdb
*
pTsdb
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
STSRow
*
cacheRow
=
NULL
;
STSRow
*
cacheRow
=
NULL
;
char
key
[
32
]
=
{
0
};
char
key
[
32
]
=
{
0
};
int
keyLen
=
0
;
int
keyLen
=
0
;
((
void
)(
row
));
//
((void)(row));
// getTableCacheKey(uid, "l", key, &keyLen);
// getTableCacheKey(uid, "l", key, &keyLen);
getTableCacheKey
(
uid
,
1
,
key
,
&
keyLen
);
getTableCacheKey
(
uid
,
1
,
key
,
&
keyLen
);
LRUHandle
*
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
LRUHandle
*
h
=
taosLRUCacheLookup
(
pCache
,
key
,
keyLen
);
if
(
h
)
{
if
(
h
)
{
STSchema
*
pTSchema
=
metaGetTbTSchema
(
pTsdb
->
pVnode
->
pMeta
,
uid
,
-
1
);
TSKEY
keyTs
=
row
->
ts
;
bool
invalidate
=
false
;
SArray
*
pLast
=
(
SArray
*
)
taosLRUCacheValue
(
pCache
,
h
);
int16_t
nCol
=
taosArrayGetSize
(
pLast
);
int16_t
iCol
=
0
;
SLastCol
*
tTsVal
=
(
SLastCol
*
)
taosArrayGet
(
pLast
,
iCol
);
if
(
keyTs
>
tTsVal
->
ts
)
{
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
SColVal
tColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
ts
=
keyTs
});
taosArraySet
(
pLast
,
iCol
,
&
(
SLastCol
){.
ts
=
keyTs
,
.
colVal
=
tColVal
});
}
for
(
++
iCol
;
iCol
<
nCol
;
++
iCol
)
{
SLastCol
*
tTsVal
=
(
SLastCol
*
)
taosArrayGet
(
pLast
,
iCol
);
if
(
keyTs
>=
tTsVal
->
ts
)
{
SColVal
*
tColVal
=
&
tTsVal
->
colVal
;
SColVal
colVal
=
{
0
};
tTSRowGetVal
(
row
,
pTSchema
,
iCol
,
&
colVal
);
if
(
colVal
.
isNone
||
colVal
.
isNull
)
{
if
(
keyTs
==
tTsVal
->
ts
&&
!
tColVal
->
isNone
&&
!
tColVal
->
isNull
)
{
invalidate
=
true
;
break
;
}
}
else
{
taosArraySet
(
pLast
,
iCol
,
&
(
SLastCol
){.
ts
=
keyTs
,
.
colVal
=
colVal
});
}
}
}
taosMemoryFreeClear
(
pTSchema
);
taosLRUCacheRelease
(
pCache
,
h
,
invalidate
);
// clear last cache anyway, lazy load when get last lookup
// clear last cache anyway, lazy load when get last lookup
taosLRUCacheRelease
(
pCache
,
h
,
true
);
//
taosLRUCacheRelease(pCache, h, true);
}
}
return
code
;
return
code
;
...
@@ -516,12 +560,46 @@ typedef struct SMemNextRowIter {
...
@@ -516,12 +560,46 @@ typedef struct SMemNextRowIter {
SMEMNEXTROWSTATES
state
;
SMEMNEXTROWSTATES
state
;
STbData
*
pMem
;
// [input]
STbData
*
pMem
;
// [input]
STbDataIter
iter
;
// mem buffer skip list iterator
STbDataIter
iter
;
// mem buffer skip list iterator
// bool iterOpened;
// TSDBROW *curRow;
}
SMemNextRowIter
;
}
SMemNextRowIter
;
static
int32_t
getNextRowFromMem
(
void
*
iter
,
TSDBROW
**
ppRow
)
{
static
int32_t
getNextRowFromMem
(
void
*
iter
,
TSDBROW
**
ppRow
)
{
// static int32_t getNextRowFromMem(void *iter, SArray *pRowArray) {
SMemNextRowIter
*
state
=
(
SMemNextRowIter
*
)
iter
;
SMemNextRowIter
*
state
=
(
SMemNextRowIter
*
)
iter
;
int32_t
code
=
0
;
int32_t
code
=
0
;
/*
if (!state->iterOpened) {
if (state->pMem != NULL) {
tsdbTbDataIterOpen(state->pMem, NULL, 1, &state->iter);
state->iterOpened = true;
TSDBROW *pMemRow = tsdbTbDataIterGet(&state->iter);
if (pMemRow) {
state->curRow = pMemRow;
} else {
return code;
}
} else {
return code;
}
}
taosArrayPush(pRowArray, state->curRow);
while (tsdbTbDataIterNext(&state->iter)) {
TSDBROW *row = tsdbTbDataIterGet(&state->iter);
if (TSDBROW_TS(row) < TSDBROW_TS(state->curRow)) {
state->curRow = row;
break;
} else {
taosArrayPush(pRowArray, row);
}
}
return code;
*/
switch
(
state
->
state
)
{
switch
(
state
->
state
)
{
case
SMEMNEXTROW_ENTER
:
{
case
SMEMNEXTROW_ENTER
:
{
if
(
state
->
pMem
!=
NULL
)
{
if
(
state
->
pMem
!=
NULL
)
{
...
@@ -599,7 +677,7 @@ _exit:
...
@@ -599,7 +677,7 @@ _exit:
return
code
;
return
code
;
}
}
static
bool
tsdbKeyDeleted
(
TSDBKEY
*
key
,
SArray
*
pSkyline
,
int
*
iSkyline
)
{
static
bool
tsdbKeyDeleted
(
TSDBKEY
*
key
,
SArray
*
pSkyline
,
int
64_t
*
iSkyline
)
{
bool
deleted
=
false
;
bool
deleted
=
false
;
while
(
*
iSkyline
>
0
)
{
while
(
*
iSkyline
>
0
)
{
TSDBKEY
*
pItemBack
=
(
TSDBKEY
*
)
taosArrayGet
(
pSkyline
,
*
iSkyline
);
TSDBKEY
*
pItemBack
=
(
TSDBKEY
*
)
taosArrayGet
(
pSkyline
,
*
iSkyline
);
...
@@ -626,9 +704,11 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int *iSkyline) {
...
@@ -626,9 +704,11 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int *iSkyline) {
}
}
typedef
int32_t
(
*
_next_row_fn_t
)(
void
*
iter
,
TSDBROW
**
ppRow
);
typedef
int32_t
(
*
_next_row_fn_t
)(
void
*
iter
,
TSDBROW
**
ppRow
);
// typedef int32_t (*_next_row_fn_t)(void *iter, SArray *pRowArray);
typedef
int32_t
(
*
_next_row_clear_fn_t
)(
void
*
iter
);
typedef
int32_t
(
*
_next_row_clear_fn_t
)(
void
*
iter
);
typedef
struct
TsdbNextRowState
{
// typedef struct TsdbNextRowState {
typedef
struct
{
TSDBROW
*
pRow
;
TSDBROW
*
pRow
;
bool
stop
;
bool
stop
;
bool
next
;
bool
next
;
...
@@ -637,6 +717,388 @@ typedef struct TsdbNextRowState {
...
@@ -637,6 +717,388 @@ typedef struct TsdbNextRowState {
_next_row_clear_fn_t
nextRowClearFn
;
_next_row_clear_fn_t
nextRowClearFn
;
}
TsdbNextRowState
;
}
TsdbNextRowState
;
typedef
struct
{
// STsdb *pTsdb;
SArray
*
pSkyline
;
int64_t
iSkyline
;
SBlockIdx
idx
;
SMemNextRowIter
memState
;
SMemNextRowIter
imemState
;
SFSNextRowIter
fsState
;
TSDBROW
memRow
,
imemRow
,
fsRow
;
TsdbNextRowState
input
[
3
];
}
CacheNextRowIter
;
static
int32_t
nextRowIterOpen
(
CacheNextRowIter
*
pIter
,
tb_uid_t
uid
,
STsdb
*
pTsdb
)
{
int
code
=
0
;
tb_uid_t
suid
=
getTableSuidByUid
(
uid
,
pTsdb
);
STbData
*
pMem
=
NULL
;
if
(
pTsdb
->
mem
)
{
tsdbGetTbDataFromMemTable
(
pTsdb
->
mem
,
suid
,
uid
,
&
pMem
);
}
STbData
*
pIMem
=
NULL
;
if
(
pTsdb
->
imem
)
{
tsdbGetTbDataFromMemTable
(
pTsdb
->
imem
,
suid
,
uid
,
&
pIMem
);
}
pIter
->
pSkyline
=
taosArrayInit
(
32
,
sizeof
(
TSDBKEY
));
SDelIdx
delIdx
;
SDelFile
*
pDelFile
=
tsdbFSStateGetDelFile
(
pTsdb
->
fs
->
cState
);
if
(
pDelFile
)
{
SDelFReader
*
pDelFReader
;
code
=
tsdbDelFReaderOpen
(
&
pDelFReader
,
pDelFile
,
pTsdb
,
NULL
);
if
(
code
)
goto
_err
;
code
=
getTableDelIdx
(
pDelFReader
,
suid
,
uid
,
&
delIdx
);
if
(
code
)
goto
_err
;
code
=
getTableDelSkyline
(
pMem
,
pIMem
,
pDelFReader
,
&
delIdx
,
pIter
->
pSkyline
);
if
(
code
)
goto
_err
;
tsdbDelFReaderClose
(
&
pDelFReader
);
}
else
{
code
=
getTableDelSkyline
(
pMem
,
pIMem
,
NULL
,
NULL
,
pIter
->
pSkyline
);
if
(
code
)
goto
_err
;
}
pIter
->
iSkyline
=
taosArrayGetSize
(
pIter
->
pSkyline
)
-
1
;
pIter
->
idx
=
(
SBlockIdx
){.
suid
=
suid
,
.
uid
=
uid
};
pIter
->
fsState
.
state
=
SFSNEXTROW_FS
;
pIter
->
fsState
.
pTsdb
=
pTsdb
;
pIter
->
fsState
.
pBlockIdxExp
=
&
pIter
->
idx
;
pIter
->
input
[
0
]
=
(
TsdbNextRowState
){
&
pIter
->
memRow
,
true
,
false
,
&
pIter
->
memState
,
getNextRowFromMem
,
NULL
};
pIter
->
input
[
1
]
=
(
TsdbNextRowState
){
&
pIter
->
imemRow
,
true
,
false
,
&
pIter
->
imemState
,
getNextRowFromMem
,
NULL
};
pIter
->
input
[
2
]
=
(
TsdbNextRowState
){
&
pIter
->
fsRow
,
false
,
true
,
&
pIter
->
fsState
,
getNextRowFromFS
,
clearNextRowFromFS
};
if
(
pMem
)
{
pIter
->
memState
.
pMem
=
pMem
;
pIter
->
memState
.
state
=
SMEMNEXTROW_ENTER
;
pIter
->
input
[
0
].
stop
=
false
;
pIter
->
input
[
0
].
next
=
true
;
}
if
(
pIMem
)
{
pIter
->
imemState
.
pMem
=
pIMem
;
pIter
->
imemState
.
state
=
SMEMNEXTROW_ENTER
;
pIter
->
input
[
1
].
stop
=
false
;
pIter
->
input
[
1
].
next
=
true
;
}
return
code
;
_err:
return
code
;
}
static
int32_t
nextRowIterClose
(
CacheNextRowIter
*
pIter
)
{
int
code
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
pIter
->
input
[
i
].
nextRowClearFn
)
{
pIter
->
input
[
i
].
nextRowClearFn
(
pIter
->
input
[
i
].
iter
);
}
}
if
(
pIter
->
pSkyline
)
{
taosArrayDestroy
(
pIter
->
pSkyline
);
}
return
code
;
_err:
return
code
;
}
// iterate next row non deleted backward ts, version (from high to low)
static
int32_t
nextRowIterGet
(
CacheNextRowIter
*
pIter
,
TSDBROW
**
ppRow
)
{
int
code
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
pIter
->
input
[
i
].
next
&&
!
pIter
->
input
[
i
].
stop
)
{
code
=
pIter
->
input
[
i
].
nextRowFn
(
pIter
->
input
[
i
].
iter
,
&
pIter
->
input
[
i
].
pRow
);
if
(
code
)
goto
_err
;
if
(
pIter
->
input
[
i
].
pRow
==
NULL
)
{
pIter
->
input
[
i
].
stop
=
true
;
pIter
->
input
[
i
].
next
=
false
;
}
}
}
if
(
pIter
->
input
[
0
].
stop
&&
pIter
->
input
[
1
].
stop
&&
pIter
->
input
[
2
].
stop
)
{
*
ppRow
=
NULL
;
return
code
;
}
// select maxpoint(s) from mem, imem, fs
TSDBROW
*
max
[
3
]
=
{
0
};
int
iMax
[
3
]
=
{
-
1
,
-
1
,
-
1
};
int
nMax
=
0
;
TSKEY
maxKey
=
TSKEY_MIN
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
!
pIter
->
input
[
i
].
stop
&&
pIter
->
input
[
i
].
pRow
!=
NULL
)
{
TSDBKEY
key
=
TSDBROW_KEY
(
pIter
->
input
[
i
].
pRow
);
// merging & deduplicating on client side
if
(
maxKey
<=
key
.
ts
)
{
if
(
maxKey
<
key
.
ts
)
{
nMax
=
0
;
maxKey
=
key
.
ts
;
}
iMax
[
nMax
]
=
i
;
max
[
nMax
++
]
=
pIter
->
input
[
i
].
pRow
;
}
}
}
// delete detection
TSDBROW
*
merge
[
3
]
=
{
0
};
int
iMerge
[
3
]
=
{
-
1
,
-
1
,
-
1
};
int
nMerge
=
0
;
for
(
int
i
=
0
;
i
<
nMax
;
++
i
)
{
TSDBKEY
maxKey
=
TSDBROW_KEY
(
max
[
i
]);
bool
deleted
=
tsdbKeyDeleted
(
&
maxKey
,
pIter
->
pSkyline
,
&
pIter
->
iSkyline
);
if
(
!
deleted
)
{
iMerge
[
nMerge
]
=
iMax
[
i
];
merge
[
nMerge
++
]
=
max
[
i
];
}
pIter
->
input
[
iMax
[
i
]].
next
=
deleted
;
}
if
(
nMerge
>
0
)
{
pIter
->
input
[
iMerge
[
0
]].
next
=
true
;
*
ppRow
=
merge
[
0
];
}
else
{
*
ppRow
=
NULL
;
}
return
code
;
_err:
return
code
;
}
static
int32_t
mergeLastRow2
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
bool
*
dup
,
STSRow
**
ppRow
)
{
int32_t
code
=
0
;
STSchema
*
pTSchema
=
metaGetTbTSchema
(
pTsdb
->
pVnode
->
pMeta
,
uid
,
-
1
);
int16_t
nCol
=
pTSchema
->
numOfCols
;
int16_t
iCol
=
0
;
int16_t
noneCol
=
0
;
bool
setNoneCol
=
false
;
SArray
*
pColArray
=
taosArrayInit
(
nCol
,
sizeof
(
SColVal
));
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
TSKEY
lastRowTs
=
TSKEY_MAX
;
CacheNextRowIter
iter
=
{
0
};
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
);
do
{
TSDBROW
*
pRow
=
NULL
;
nextRowIterGet
(
&
iter
,
&
pRow
);
if
(
!
pRow
)
{
break
;
}
if
(
lastRowTs
==
TSKEY_MAX
)
{
lastRowTs
=
TSDBROW_TS
(
pRow
);
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
ts
=
lastRowTs
});
if
(
taosArrayPush
(
pColArray
,
pColVal
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
for
(
iCol
=
1
;
iCol
<
nCol
;
++
iCol
)
{
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
(
taosArrayPush
(
pColArray
,
pColVal
)
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
if
(
pColVal
->
isNone
&&
!
setNoneCol
)
{
noneCol
=
iCol
;
setNoneCol
=
true
;
}
}
if
(
!
setNoneCol
)
{
// goto build the result ts row
break
;
}
else
{
continue
;
}
}
if
((
TSDBROW_TS
(
pRow
)
<
lastRowTs
))
{
// goto build the result ts row
break
;
}
// merge into pColArray
setNoneCol
=
false
;
for
(
iCol
=
noneCol
;
iCol
<
nCol
;
++
iCol
)
{
// high version's column value
SColVal
*
tColVal
=
(
SColVal
*
)
taosArrayGet
(
pColArray
,
iCol
);
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
(
tColVal
->
isNone
&&
!
pColVal
->
isNone
)
{
taosArraySet
(
pColArray
,
iCol
,
pColVal
);
}
else
if
(
tColVal
->
isNone
&&
pColVal
->
isNone
&&
!
setNoneCol
)
{
noneCol
=
iCol
;
setNoneCol
=
true
;
}
}
}
while
(
setNoneCol
);
// build the result ts row here
*
dup
=
false
;
if
(
taosArrayGetSize
(
pColArray
)
==
nCol
)
{
code
=
tdSTSRowNew
(
pColArray
,
pTSchema
,
ppRow
);
if
(
code
)
goto
_err
;
}
else
{
*
ppRow
=
NULL
;
}
nextRowIterClose
(
&
iter
);
taosArrayDestroy
(
pColArray
);
taosMemoryFreeClear
(
pTSchema
);
return
code
;
_err:
nextRowIterClose
(
&
iter
);
taosArrayDestroy
(
pColArray
);
taosMemoryFreeClear
(
pTSchema
);
return
code
;
}
static
int32_t
mergeLast2
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
SArray
**
ppLastArray
)
{
int32_t
code
=
0
;
STSchema
*
pTSchema
=
metaGetTbTSchema
(
pTsdb
->
pVnode
->
pMeta
,
uid
,
-
1
);
int16_t
nCol
=
pTSchema
->
numOfCols
;
int16_t
iCol
=
0
;
int16_t
noneCol
=
0
;
bool
setNoneCol
=
false
;
SArray
*
pColArray
=
taosArrayInit
(
nCol
,
sizeof
(
SLastCol
));
SColVal
*
pColVal
=
&
(
SColVal
){
0
};
// tb_uid_t suid = getTableSuidByUid(uid, pTsdb);
TSKEY
lastRowTs
=
TSKEY_MAX
;
CacheNextRowIter
iter
=
{
0
};
nextRowIterOpen
(
&
iter
,
uid
,
pTsdb
);
do
{
TSDBROW
*
pRow
=
NULL
;
nextRowIterGet
(
&
iter
,
&
pRow
);
if
(
!
pRow
)
{
break
;
}
TSKEY
rowTs
=
TSDBROW_TS
(
pRow
);
if
(
lastRowTs
==
TSKEY_MAX
)
{
lastRowTs
=
rowTs
;
STColumn
*
pTColumn
=
&
pTSchema
->
columns
[
0
];
*
pColVal
=
COL_VAL_VALUE
(
pTColumn
->
colId
,
pTColumn
->
type
,
(
SValue
){.
ts
=
lastRowTs
});
if
(
taosArrayPush
(
pColArray
,
&
(
SLastCol
){.
ts
=
lastRowTs
,
.
colVal
=
*
pColVal
})
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
for
(
iCol
=
1
;
iCol
<
nCol
;
++
iCol
)
{
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
(
taosArrayPush
(
pColArray
,
&
(
SLastCol
){.
ts
=
lastRowTs
,
.
colVal
=
*
pColVal
})
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
if
((
pColVal
->
isNone
||
pColVal
->
isNull
)
&&
!
setNoneCol
)
{
noneCol
=
iCol
;
setNoneCol
=
true
;
}
}
if
(
!
setNoneCol
)
{
// goto build the result ts row
break
;
}
else
{
continue
;
}
}
/*
if ((TSDBROW_TS(pRow) < lastRowTs)) {
// goto build the result ts row
break;
}
*/
// merge into pColArray
setNoneCol
=
false
;
for
(
iCol
=
noneCol
;
iCol
<
nCol
;
++
iCol
)
{
// high version's column value
SColVal
*
tColVal
=
(
SColVal
*
)
taosArrayGet
(
pColArray
,
iCol
);
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
((
tColVal
->
isNone
||
tColVal
->
isNull
)
&&
(
!
pColVal
->
isNone
&&
!
pColVal
->
isNull
))
{
taosArraySet
(
pColArray
,
iCol
,
&
(
SLastCol
){.
ts
=
rowTs
,
.
colVal
=
*
pColVal
});
//} else if (tColVal->isNone && pColVal->isNone && !setNoneCol) {
}
else
if
((
tColVal
->
isNone
||
tColVal
->
isNull
)
&&
(
pColVal
->
isNone
||
pColVal
->
isNull
)
&&
!
setNoneCol
)
{
noneCol
=
iCol
;
setNoneCol
=
true
;
}
}
}
while
(
setNoneCol
);
// build the result ts row here
//*dup = false;
if
(
taosArrayGetSize
(
pColArray
)
<=
0
)
{
*
ppLastArray
=
NULL
;
taosArrayDestroy
(
pColArray
);
}
else
{
*
ppLastArray
=
pColArray
;
}
/* if (taosArrayGetSize(pColArray) == nCol) {
code = tdSTSRowNew(pColArray, pTSchema, ppRow);
if (code) goto _err;
} else {
*ppRow = NULL;
}*/
nextRowIterClose
(
&
iter
);
// taosArrayDestroy(pColArray);
taosMemoryFreeClear
(
pTSchema
);
return
code
;
_err:
nextRowIterClose
(
&
iter
);
// taosArrayDestroy(pColArray);
taosMemoryFreeClear
(
pTSchema
);
return
code
;
}
static
int32_t
mergeLastRow
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
bool
*
dup
,
STSRow
**
ppRow
)
{
static
int32_t
mergeLastRow
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
bool
*
dup
,
STSRow
**
ppRow
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SArray
*
pSkyline
=
NULL
;
SArray
*
pSkyline
=
NULL
;
...
@@ -682,7 +1144,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
...
@@ -682,7 +1144,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
}
int
iSkyline
=
taosArrayGetSize
(
pSkyline
)
-
1
;
int
64_t
iSkyline
=
taosArrayGetSize
(
pSkyline
)
-
1
;
SBlockIdx
idx
=
{.
suid
=
suid
,
.
uid
=
uid
};
SBlockIdx
idx
=
{.
suid
=
suid
,
.
uid
=
uid
};
...
@@ -719,12 +1181,14 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
...
@@ -719,12 +1181,14 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
do
{
do
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
input
[
i
].
next
&&
!
input
[
i
].
stop
)
{
if
(
input
[
i
].
next
&&
!
input
[
i
].
stop
)
{
code
=
input
[
i
].
nextRowFn
(
input
[
i
].
iter
,
&
input
[
i
].
pRow
);
if
(
code
)
goto
_err
;
if
(
input
[
i
].
pRow
==
NULL
)
{
if
(
input
[
i
].
pRow
==
NULL
)
{
input
[
i
].
stop
=
true
;
code
=
input
[
i
].
nextRowFn
(
input
[
i
].
iter
,
&
input
[
i
].
pRow
);
input
[
i
].
next
=
false
;
if
(
code
)
goto
_err
;
if
(
input
[
i
].
pRow
==
NULL
)
{
input
[
i
].
stop
=
true
;
input
[
i
].
next
=
false
;
}
}
}
}
}
}
}
...
@@ -758,14 +1222,14 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
...
@@ -758,14 +1222,14 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
// delete detection
// delete detection
TSDBROW
*
merge
[
3
]
=
{
0
};
TSDBROW
*
merge
[
3
]
=
{
0
};
//
int iMerge[3] = {-1, -1, -1};
int
iMerge
[
3
]
=
{
-
1
,
-
1
,
-
1
};
int
nMerge
=
0
;
int
nMerge
=
0
;
for
(
int
i
=
0
;
i
<
nMax
;
++
i
)
{
for
(
int
i
=
0
;
i
<
nMax
;
++
i
)
{
TSDBKEY
maxKey
=
TSDBROW_KEY
(
max
[
i
]);
TSDBKEY
maxKey
=
TSDBROW_KEY
(
max
[
i
]);
bool
deleted
=
tsdbKeyDeleted
(
&
maxKey
,
pSkyline
,
&
iSkyline
);
bool
deleted
=
tsdbKeyDeleted
(
&
maxKey
,
pSkyline
,
&
iSkyline
);
if
(
!
deleted
)
{
if
(
!
deleted
)
{
//
iMerge[nMerge] = i;
iMerge
[
nMerge
]
=
i
;
merge
[
nMerge
++
]
=
max
[
i
];
merge
[
nMerge
++
]
=
max
[
i
];
}
}
...
@@ -792,7 +1256,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
...
@@ -792,7 +1256,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, STSRow **ppRo
}
}
}
}
}
while
(
*
ppRow
==
NULL
);
}
while
(
1
);
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
input
[
i
].
nextRowClearFn
)
{
if
(
input
[
i
].
nextRowClearFn
)
{
...
@@ -819,11 +1283,6 @@ _err:
...
@@ -819,11 +1283,6 @@ _err:
return
code
;
return
code
;
}
}
typedef
struct
{
TSKEY
ts
;
SColVal
colVal
;
}
SLastCol
;
// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) {
// static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, STSRow **ppRow) {
static
int32_t
mergeLast
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
SArray
**
ppLastArray
)
{
static
int32_t
mergeLast
(
tb_uid_t
uid
,
STsdb
*
pTsdb
,
SArray
**
ppLastArray
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -873,7 +1332,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
...
@@ -873,7 +1332,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
if
(
code
)
goto
_err
;
if
(
code
)
goto
_err
;
}
}
int
iSkyline
=
taosArrayGetSize
(
pSkyline
)
-
1
;
int
64_t
iSkyline
=
taosArrayGetSize
(
pSkyline
)
-
1
;
SBlockIdx
idx
=
{.
suid
=
suid
,
.
uid
=
uid
};
SBlockIdx
idx
=
{.
suid
=
suid
,
.
uid
=
uid
};
...
@@ -1128,7 +1587,7 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH
...
@@ -1128,7 +1587,7 @@ int32_t tsdbCacheGetLastrowH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUH
}
else
{
}
else
{
STSRow
*
pRow
=
NULL
;
STSRow
*
pRow
=
NULL
;
bool
dup
=
false
;
// which is always false for now
bool
dup
=
false
;
// which is always false for now
code
=
mergeLastRow
(
uid
,
pTsdb
,
&
dup
,
&
pRow
);
code
=
mergeLastRow
2
(
uid
,
pTsdb
,
&
dup
,
&
pRow
);
// if table's empty or error, return code of -1
// if table's empty or error, return code of -1
if
(
code
<
0
||
pRow
==
NULL
)
{
if
(
code
<
0
||
pRow
==
NULL
)
{
if
(
!
dup
&&
pRow
)
{
if
(
!
dup
&&
pRow
)
{
...
@@ -1195,7 +1654,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
...
@@ -1195,7 +1654,8 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
// STSRow *pRow = NULL;
// STSRow *pRow = NULL;
// code = mergeLast(uid, pTsdb, &pRow);
// code = mergeLast(uid, pTsdb, &pRow);
SArray
*
pLastArray
=
NULL
;
SArray
*
pLastArray
=
NULL
;
code
=
mergeLast
(
uid
,
pTsdb
,
&
pLastArray
);
// code = mergeLast(uid, pTsdb, &pLastArray);
code
=
mergeLast2
(
uid
,
pTsdb
,
&
pLastArray
);
// if table's empty or error, return code of -1
// if table's empty or error, return code of -1
// if (code < 0 || pRow == NULL) {
// if (code < 0 || pRow == NULL) {
if
(
code
<
0
||
pLastArray
==
NULL
)
{
if
(
code
<
0
||
pLastArray
==
NULL
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
24042fff
...
@@ -561,7 +561,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
...
@@ -561,7 +561,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
}
}
}
}
tsdbCacheInsertLast
(
pMemTable
->
pTsdb
->
lruCache
,
pTbData
->
uid
,
pLastRow
);
tsdbCacheInsertLast
(
pMemTable
->
pTsdb
->
lruCache
,
pTbData
->
uid
,
pLastRow
,
pMemTable
->
pTsdb
);
pTbData
->
minVersion
=
TMIN
(
pTbData
->
minVersion
,
version
);
pTbData
->
minVersion
=
TMIN
(
pTbData
->
minVersion
,
version
);
pTbData
->
maxVersion
=
TMAX
(
pTbData
->
maxVersion
,
version
);
pTbData
->
maxVersion
=
TMAX
(
pTbData
->
maxVersion
,
version
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
24042fff
...
@@ -323,11 +323,9 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
...
@@ -323,11 +323,9 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
if
((
asc
&&
(
win
.
ekey
<
pReader
->
window
.
skey
))
||
((
!
asc
)
&&
(
win
.
skey
>
pReader
->
window
.
ekey
)))
{
if
((
asc
&&
(
win
.
ekey
<
pReader
->
window
.
skey
))
||
((
!
asc
)
&&
(
win
.
skey
>
pReader
->
window
.
ekey
)))
{
pIter
->
index
+=
step
;
pIter
->
index
+=
step
;
if
((
asc
&&
pIter
->
index
>=
pIter
->
numOfFiles
)
||
((
!
asc
)
&&
pIter
->
index
<
0
))
{
if
((
asc
&&
pIter
->
index
>=
pIter
->
numOfFiles
)
||
((
!
asc
)
&&
pIter
->
index
<
0
))
{
return
false
;
return
false
;
}
}
continue
;
continue
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
24042fff
...
@@ -15,30 +15,37 @@
...
@@ -15,30 +15,37 @@
#include "vnd.h"
#include "vnd.h"
const
SVnodeCfg
vnodeCfgDefault
=
{
const
SVnodeCfg
vnodeCfgDefault
=
{.
vgId
=
-
1
,
.
vgId
=
-
1
,
.
dbname
=
""
,
.
dbname
=
""
,
.
dbId
=
0
,
.
dbId
=
0
,
.
szPage
=
4096
,
.
szPage
=
4096
,
.
szCache
=
256
,
.
szCache
=
256
,
.
szBuf
=
96
*
1024
*
1024
,
.
szBuf
=
96
*
1024
*
1024
,
.
isHeap
=
false
,
.
isHeap
=
false
,
.
isWeak
=
0
,
.
isWeak
=
0
,
.
tsdbCfg
=
{.
precision
=
TSDB_TIME_PRECISION_MILLI
,
.
tsdbCfg
=
{.
precision
=
TSDB_TIME_PRECISION_MILLI
,
.
update
=
1
,
.
update
=
1
,
.
compression
=
2
,
.
compression
=
2
,
.
slLevel
=
5
,
.
slLevel
=
5
,
.
days
=
14400
,
.
days
=
14400
,
.
minRows
=
100
,
.
minRows
=
100
,
.
maxRows
=
4096
,
.
maxRows
=
4096
,
.
keep2
=
5256000
,
.
keep2
=
5256000
,
.
keep0
=
5256000
,
.
keep0
=
5256000
,
.
keep1
=
5256000
},
.
keep1
=
5256000
},
.
walCfg
=
.
walCfg
=
{
{.
vgId
=
-
1
,
.
fsyncPeriod
=
0
,
.
retentionPeriod
=
0
,
.
rollPeriod
=
0
,
.
segSize
=
0
,
.
level
=
TAOS_WAL_WRITE
},
.
vgId
=
-
1
,
.
hashBegin
=
0
,
.
fsyncPeriod
=
0
,
.
hashEnd
=
0
,
.
retentionPeriod
=
-
1
,
.
hashMethod
=
0
};
.
rollPeriod
=
-
1
,
.
segSize
=
-
1
,
.
retentionSize
=
-
1
,
.
level
=
TAOS_WAL_WRITE
,
},
.
hashBegin
=
0
,
.
hashEnd
=
0
,
.
hashMethod
=
0
};
int
vnodeCheckCfg
(
const
SVnodeCfg
*
pCfg
)
{
int
vnodeCheckCfg
(
const
SVnodeCfg
*
pCfg
)
{
// TODO
// TODO
...
@@ -79,7 +86,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
...
@@ -79,7 +86,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
SJson
*
pNodeRetentions
=
tjsonCreateArray
();
SJson
*
pNodeRetentions
=
tjsonCreateArray
();
tjsonAddItemToObject
(
pJson
,
"retentions"
,
pNodeRetentions
);
tjsonAddItemToObject
(
pJson
,
"retentions"
,
pNodeRetentions
);
for
(
int32_t
i
=
0
;
i
<
nRetention
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
nRetention
;
++
i
)
{
SJson
*
pNodeRetention
=
tjsonCreateObject
();
SJson
*
pNodeRetention
=
tjsonCreateObject
();
const
SRetention
*
pRetention
=
pCfg
->
tsdbCfg
.
retentions
+
i
;
const
SRetention
*
pRetention
=
pCfg
->
tsdbCfg
.
retentions
+
i
;
tjsonAddIntegerToObject
(
pNodeRetention
,
"freq"
,
pRetention
->
freq
);
tjsonAddIntegerToObject
(
pNodeRetention
,
"freq"
,
pRetention
->
freq
);
tjsonAddIntegerToObject
(
pNodeRetention
,
"freqUnit"
,
pRetention
->
freqUnit
);
tjsonAddIntegerToObject
(
pNodeRetention
,
"freqUnit"
,
pRetention
->
freqUnit
);
...
@@ -156,7 +163,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
...
@@ -156,7 +163,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"keep2"
,
pCfg
->
tsdbCfg
.
keep2
,
code
);
tjsonGetNumberValue
(
pJson
,
"keep2"
,
pCfg
->
tsdbCfg
.
keep2
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
SJson
*
pNodeRetentions
=
tjsonGetObjectItem
(
pJson
,
"retentions"
);
SJson
*
pNodeRetentions
=
tjsonGetObjectItem
(
pJson
,
"retentions"
);
int32_t
nRetention
=
tjsonGetArraySize
(
pNodeRetentions
);
int32_t
nRetention
=
tjsonGetArraySize
(
pNodeRetentions
);
if
(
nRetention
>
TSDB_RETENTION_MAX
)
{
if
(
nRetention
>
TSDB_RETENTION_MAX
)
{
nRetention
=
TSDB_RETENTION_MAX
;
nRetention
=
TSDB_RETENTION_MAX
;
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
24042fff
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "vnd.h"
#include "vnd.h"
#define VND_INFO_FNAME
"vnode.json"
#define VND_INFO_FNAME "vnode.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
#define VND_INFO_FNAME_TMP "vnode_tmp.json"
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
static
int
vnodeEncodeInfo
(
const
SVnodeInfo
*
pInfo
,
char
**
ppData
);
...
@@ -230,6 +230,7 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -230,6 +230,7 @@ int vnodeCommit(SVnode *pVnode) {
ASSERT
(
0
);
ASSERT
(
0
);
return
-
1
;
return
-
1
;
}
}
walBeginSnapshot
(
pVnode
->
pWal
,
pVnode
->
state
.
applied
);
// preCommit
// preCommit
smaPreCommit
(
pVnode
->
pSma
);
smaPreCommit
(
pVnode
->
pSma
);
...
@@ -278,6 +279,7 @@ int vnodeCommit(SVnode *pVnode) {
...
@@ -278,6 +279,7 @@ int vnodeCommit(SVnode *pVnode) {
smaPostCommit
(
pVnode
->
pSma
);
smaPostCommit
(
pVnode
->
pSma
);
// apply the commit (TODO)
// apply the commit (TODO)
walEndSnapshot
(
pVnode
->
pWal
);
vnodeBufPoolReset
(
pVnode
->
onCommit
);
vnodeBufPoolReset
(
pVnode
->
onCommit
);
pVnode
->
onCommit
->
next
=
pVnode
->
pPool
;
pVnode
->
onCommit
->
next
=
pVnode
->
pPool
;
pVnode
->
pPool
=
pVnode
->
onCommit
;
pVnode
->
pPool
=
pVnode
->
onCommit
;
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
24042fff
...
@@ -117,6 +117,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
...
@@ -117,6 +117,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
// open wal
// open wal
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_WAL_DIR
);
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_WAL_DIR
);
taosRealPath
(
tdir
,
NULL
,
sizeof
(
tdir
));
taosRealPath
(
tdir
,
NULL
,
sizeof
(
tdir
));
// for test tsdb snapshot
#if 0
pVnode->config.walCfg.segSize = 200;
pVnode->config.walCfg.retentionSize = 2000;
#endif
pVnode
->
pWal
=
walOpen
(
tdir
,
&
(
pVnode
->
config
.
walCfg
));
pVnode
->
pWal
=
walOpen
(
tdir
,
&
(
pVnode
->
config
.
walCfg
));
if
(
pVnode
->
pWal
==
NULL
)
{
if
(
pVnode
->
pWal
==
NULL
)
{
vError
(
"vgId:%d, failed to open vnode wal since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
vError
(
"vgId:%d, failed to open vnode wal since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
24042fff
...
@@ -480,37 +480,35 @@ typedef struct SCtgOperation {
...
@@ -480,37 +480,35 @@ typedef struct SCtgOperation {
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
#define CTG_IS_LOCKED(_lock) atomic_load_32((_lock))
#define CTG_LOCK(type, _lock) do { \
#define CTG_LOCK(type, _lock) do { \
if (CTG_READ == (type)) { \
if (CTG_READ == (type)) { \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
CTG_LOCK_DEBUG("CTG RLOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG RLOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosRLockLatch(_lock); \
taosRLockLatch(_lock); \
CTG_LOCK_DEBUG("CTG RLOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG RLOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) > 0); \
assert(atomic_load_
64
((_lock)) > 0); \
} else { \
} else { \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
CTG_LOCK_DEBUG("CTG WLOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG WLOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosWLockLatch(_lock); \
taosWLockLatch(_lock); \
CTG_LOCK_DEBUG("CTG WLOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG WLOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
assert(atomic_load_
64
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
} \
} \
} while (0)
} while (0)
#define CTG_UNLOCK(type, _lock) do { \
#define CTG_UNLOCK(type, _lock) do { \
if (CTG_READ == (type)) { \
if (CTG_READ == (type)) { \
assert(atomic_load_
32
((_lock)) > 0); \
assert(atomic_load_
64
((_lock)) > 0); \
CTG_LOCK_DEBUG("CTG RULOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG RULOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosRUnLockLatch(_lock); \
taosRUnLockLatch(_lock); \
CTG_LOCK_DEBUG("CTG RULOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG RULOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
} else { \
} else { \
assert(atomic_load_
32
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
assert(atomic_load_
64
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
CTG_LOCK_DEBUG("CTG WULOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG WULOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosWUnLockLatch(_lock); \
taosWUnLockLatch(_lock); \
CTG_LOCK_DEBUG("CTG WULOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
CTG_LOCK_DEBUG("CTG WULOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
} \
} \
} while (0)
} while (0)
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
24042fff
...
@@ -789,9 +789,13 @@ _return:
...
@@ -789,9 +789,13 @@ _return:
int32_t
ctgCallUserCb
(
void
*
param
)
{
int32_t
ctgCallUserCb
(
void
*
param
)
{
SCtgJob
*
pJob
=
(
SCtgJob
*
)
param
;
SCtgJob
*
pJob
=
(
SCtgJob
*
)
param
;
qDebug
(
"QID:0x%"
PRIx64
" ctg start to call user cb with rsp %s"
,
pJob
->
queryId
,
tstrerror
(
pJob
->
jobResCode
));
(
*
pJob
->
userFp
)(
&
pJob
->
jobRes
,
pJob
->
userParam
,
pJob
->
jobResCode
);
(
*
pJob
->
userFp
)(
&
pJob
->
jobRes
,
pJob
->
userParam
,
pJob
->
jobResCode
);
qDebug
(
"QID:0x%"
PRIx64
" ctg end to call user cb"
,
pJob
->
queryId
);
taosRemoveRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
taosRemoveRef
(
gCtgMgmt
.
jobPool
,
pJob
->
refId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -822,8 +826,6 @@ int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) {
...
@@ -822,8 +826,6 @@ int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) {
_return:
_return:
qDebug
(
"QID:0x%"
PRIx64
" ctg call user callback with rsp %s"
,
pJob
->
queryId
,
tstrerror
(
code
));
pJob
->
jobResCode
=
code
;
pJob
->
jobResCode
=
code
;
//taosSsleep(2);
//taosSsleep(2);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
24042fff
...
@@ -540,6 +540,9 @@ typedef struct SIndefOperatorInfo {
...
@@ -540,6 +540,9 @@ typedef struct SIndefOperatorInfo {
SArray
*
pPseudoColInfo
;
SArray
*
pPseudoColInfo
;
SExprSupp
scalarSup
;
SExprSupp
scalarSup
;
SNode
*
pCondition
;
SNode
*
pCondition
;
uint64_t
groupId
;
SSDataBlock
*
pNextGroupRes
;
}
SIndefOperatorInfo
;
}
SIndefOperatorInfo
;
typedef
struct
SFillOperatorInfo
{
typedef
struct
SFillOperatorInfo
{
...
@@ -552,6 +555,7 @@ typedef struct SFillOperatorInfo {
...
@@ -552,6 +555,7 @@ typedef struct SFillOperatorInfo {
STimeWindow
win
;
STimeWindow
win
;
SNode
*
pCondition
;
SNode
*
pCondition
;
SArray
*
pColMatchColInfo
;
SArray
*
pColMatchColInfo
;
int32_t
primaryTsCol
;
}
SFillOperatorInfo
;
}
SFillOperatorInfo
;
typedef
struct
SGroupbyOperatorInfo
{
typedef
struct
SGroupbyOperatorInfo
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
24042fff
...
@@ -571,8 +571,8 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
...
@@ -571,8 +571,8 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
setPseudoOutputColInfo
(
pResult
,
pCtx
,
pPseudoList
);
setPseudoOutputColInfo
(
pResult
,
pCtx
,
pPseudoList
);
pResult
->
info
.
groupId
=
pSrcBlock
->
info
.
groupId
;
pResult
->
info
.
groupId
=
pSrcBlock
->
info
.
groupId
;
// if the source equals to the destination, it is to create a new column as the result of scalar
function or some
// if the source equals to the destination, it is to create a new column as the result of scalar
// operators.
//
function or some
operators.
bool
createNewColModel
=
(
pResult
==
pSrcBlock
);
bool
createNewColModel
=
(
pResult
==
pSrcBlock
);
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -580,17 +580,17 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
...
@@ -580,17 +580,17 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
int32_t
outputSlotId
=
pExpr
[
k
].
base
.
resSchema
.
slotId
;
int32_t
outputSlotId
=
pExpr
[
k
].
base
.
resSchema
.
slotId
;
SqlFunctionCtx
*
pfCtx
=
&
pCtx
[
k
];
SqlFunctionCtx
*
pfCtx
=
&
pCtx
[
k
];
SInputColumnInfoData
*
pInputData
=
&
pfCtx
->
input
;
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
// it is a project query
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
// it is a project query
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
if
(
pResult
->
info
.
rows
>
0
&&
!
createNewColModel
)
{
if
(
pResult
->
info
.
rows
>
0
&&
!
createNewColModel
)
{
colDataMergeCol
(
pColInfoData
,
pResult
->
info
.
rows
,
&
pResult
->
info
.
capacity
,
pfCtx
->
input
.
pData
[
0
],
colDataMergeCol
(
pColInfoData
,
pResult
->
info
.
rows
,
&
pResult
->
info
.
capacity
,
pInputData
->
pData
[
0
],
pInputData
->
numOfRows
);
pfCtx
->
input
.
numOfRows
);
}
else
{
}
else
{
colDataAssign
(
pColInfoData
,
p
fCtx
->
input
.
pData
[
0
],
pfCtx
->
input
.
numOfRows
,
&
pResult
->
info
);
colDataAssign
(
pColInfoData
,
p
InputData
->
pData
[
0
],
pInputData
->
numOfRows
,
&
pResult
->
info
);
}
}
numOfRows
=
p
fCtx
->
input
.
numOfRows
;
numOfRows
=
p
InputData
->
numOfRows
;
}
else
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_VALUE
)
{
}
else
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_VALUE
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
...
@@ -623,14 +623,12 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
...
@@ -623,14 +623,12 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
numOfRows
=
dest
.
numOfRows
;
numOfRows
=
dest
.
numOfRows
;
taosArrayDestroy
(
pBlockList
);
taosArrayDestroy
(
pBlockList
);
}
else
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_FUNCTION
)
{
}
else
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_FUNCTION
)
{
ASSERT
(
!
fmIsAggFunc
(
pfCtx
->
functionId
));
// _rowts/_c0, not tbname column
// _rowts/_c0, not tbname column
if
(
fmIsPseudoColumnFunc
(
pfCtx
->
functionId
)
&&
(
!
fmIsScanPseudoColumnFunc
(
pfCtx
->
functionId
)))
{
if
(
fmIsPseudoColumnFunc
(
pfCtx
->
functionId
)
&&
(
!
fmIsScanPseudoColumnFunc
(
pfCtx
->
functionId
)))
{
// do nothing
// do nothing
}
else
if
(
fmIsIndefiniteRowsFunc
(
pfCtx
->
functionId
))
{
}
else
if
(
fmIsIndefiniteRowsFunc
(
pfCtx
->
functionId
))
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
k
]
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pfCtx
);
pfCtx
->
fpSet
.
init
(
&
pCtx
[
k
]
,
pResInfo
);
pfCtx
->
fpSet
.
init
(
pfCtx
,
pResInfo
);
pfCtx
->
pOutput
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
pfCtx
->
pOutput
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
pfCtx
->
offset
=
createNewColModel
?
0
:
pResult
->
info
.
rows
;
// set the start offset
pfCtx
->
offset
=
createNewColModel
?
0
:
pResult
->
info
.
rows
;
// set the start offset
...
@@ -642,6 +640,23 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
...
@@ -642,6 +640,23 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
}
}
numOfRows
=
pfCtx
->
fpSet
.
process
(
pfCtx
);
numOfRows
=
pfCtx
->
fpSet
.
process
(
pfCtx
);
}
else
if
(
fmIsAggFunc
(
pfCtx
->
functionId
))
{
// _group_key function for "partition by tbname" + csum(col_name) query
SColumnInfoData
*
pOutput
=
taosArrayGet
(
pResult
->
pDataBlock
,
outputSlotId
);
int32_t
slotId
=
pfCtx
->
param
[
0
].
pCol
->
slotId
;
// todo handle the json tag
SColumnInfoData
*
pInput
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
slotId
);
for
(
int32_t
f
=
0
;
f
<
pSrcBlock
->
info
.
rows
;
++
f
)
{
bool
isNull
=
colDataIsNull_s
(
pInput
,
f
);
if
(
isNull
)
{
colDataAppendNULL
(
pOutput
,
pResult
->
info
.
rows
+
f
);
}
else
{
char
*
data
=
colDataGetData
(
pInput
,
f
);
colDataAppend
(
pOutput
,
pResult
->
info
.
rows
+
f
,
data
,
isNull
);
}
}
}
else
{
}
else
{
SArray
*
pBlockList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
SArray
*
pBlockList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
taosArrayPush
(
pBlockList
,
&
pSrcBlock
);
taosArrayPush
(
pBlockList
,
&
pSrcBlock
);
...
@@ -675,25 +690,6 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
...
@@ -675,25 +690,6 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
setResultRowKey
(
SResultRow
*
pResultRow
,
char
*
pData
,
int16_t
type
)
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
// todo disable this
// if (pResultRow->key == NULL) {
// pResultRow->key = taosMemoryMalloc(varDataTLen(pData));
// varDataCopy(pResultRow->key, pData);
// } else {
// ASSERT(memcmp(pResultRow->key, pData, varDataTLen(pData)) == 0);
// }
}
else
{
int64_t
v
=
-
1
;
GET_TYPED_DATA
(
v
,
int64_t
,
type
,
pData
);
pResultRow
->
win
.
skey
=
v
;
pResultRow
->
win
.
ekey
=
v
;
}
}
bool
functionNeedToExecute
(
SqlFunctionCtx
*
pCtx
)
{
bool
functionNeedToExecute
(
SqlFunctionCtx
*
pCtx
)
{
struct
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
struct
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -3825,6 +3821,40 @@ _error:
...
@@ -3825,6 +3821,40 @@ _error:
return
NULL
;
return
NULL
;
}
}
static
void
doHandleDataBlock
(
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pBlock
,
SOperatorInfo
*
downstream
,
SExecTaskInfo
*
pTaskInfo
)
{
int32_t
order
=
0
;
int32_t
scanFlag
=
0
;
SIndefOperatorInfo
*
pIndefInfo
=
pOperator
->
info
;
SOptrBasicInfo
*
pInfo
=
&
pIndefInfo
->
binfo
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
// the pDataBlock are always the same one, no need to call this again
int32_t
code
=
getTableScanInfo
(
downstream
,
&
order
,
&
scanFlag
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
// there is an scalar expression that needs to be calculated before apply the group aggregation.
SExprSupp
*
pScalarSup
=
&
pIndefInfo
->
scalarSup
;
if
(
pScalarSup
->
pExprInfo
!=
NULL
)
{
code
=
projectApplyFunctions
(
pScalarSup
->
pExprInfo
,
pBlock
,
pBlock
,
pScalarSup
->
pCtx
,
pScalarSup
->
numOfExprs
,
pIndefInfo
->
pPseudoColInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
}
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
order
,
scanFlag
,
false
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pInfo
->
pRes
->
info
.
rows
+
pBlock
->
info
.
rows
);
code
=
projectApplyFunctions
(
pSup
->
pExprInfo
,
pInfo
->
pRes
,
pBlock
,
pSup
->
pCtx
,
pSup
->
numOfExprs
,
pIndefInfo
->
pPseudoColInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
}
static
SSDataBlock
*
doApplyIndefinitFunction
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
doApplyIndefinitFunction
(
SOperatorInfo
*
pOperator
)
{
SIndefOperatorInfo
*
pIndefInfo
=
pOperator
->
info
;
SIndefOperatorInfo
*
pIndefInfo
=
pOperator
->
info
;
SOptrBasicInfo
*
pInfo
=
&
pIndefInfo
->
binfo
;
SOptrBasicInfo
*
pInfo
=
&
pIndefInfo
->
binfo
;
...
@@ -3839,8 +3869,6 @@ static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
...
@@ -3839,8 +3869,6 @@ static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
}
}
int64_t
st
=
0
;
int64_t
st
=
0
;
int32_t
order
=
0
;
int32_t
scanFlag
=
0
;
if
(
pOperator
->
cost
.
openCost
==
0
)
{
if
(
pOperator
->
cost
.
openCost
==
0
)
{
st
=
taosGetTimestampUs
();
st
=
taosGetTimestampUs
();
...
@@ -3848,42 +3876,54 @@ static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
...
@@ -3848,42 +3876,54 @@ static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
while
(
1
)
{
// The downstream exec may change the value of the newgroup, so use a local variable instead.
// here we need to handle the existsed group results
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pIndefInfo
->
pNextGroupRes
!=
NULL
)
{
// todo extract method
if
(
pBlock
==
NULL
)
{
for
(
int32_t
k
=
0
;
k
<
pSup
->
numOfExprs
;
++
k
)
{
doSetOperatorCompleted
(
pOperator
);
SqlFunctionCtx
*
pCtx
=
&
pSup
->
pCtx
[
k
];
break
;
}
// the pDataBlock are always the same one, no need to call this again
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
int32_t
code
=
getTableScanInfo
(
pOperator
->
pDownstream
[
0
],
&
order
,
&
scanFlag
);
pResInfo
->
initialized
=
false
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pCtx
->
pOutput
=
NULL
;
longjmp
(
pTaskInfo
->
env
,
code
);
}
doHandleDataBlock
(
pOperator
,
pIndefInfo
->
pNextGroupRes
,
downstream
,
pTaskInfo
);
pIndefInfo
->
pNextGroupRes
=
NULL
;
}
}
// there is an scalar expression that needs to be calculated before apply the group aggregation.
if
(
pInfo
->
pRes
->
info
.
rows
<
pOperator
->
resultInfo
.
threshold
)
{
SExprSupp
*
pScalarSup
=
&
pIndefInfo
->
scalarSup
;
while
(
1
)
{
if
(
pScalarSup
->
pExprInfo
!=
NULL
)
{
// The downstream exec may change the value of the newgroup, so use a local variable instead.
code
=
projectApplyFunctions
(
pScalarSup
->
pExprInfo
,
pBlock
,
pBlock
,
pScalarSup
->
pCtx
,
pScalarSup
->
numOfExprs
,
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
pIndefInfo
->
pPseudoColInfo
);
if
(
pBlock
==
NULL
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
doSetOperatorCompleted
(
pOperator
);
longjmp
(
pTaskInfo
->
env
,
code
);
break
;
}
if
(
pIndefInfo
->
groupId
==
0
&&
pBlock
->
info
.
groupId
!=
0
)
{
pIndefInfo
->
groupId
=
pBlock
->
info
.
groupId
;
// this is the initial group result
}
else
{
if
(
pIndefInfo
->
groupId
!=
pBlock
->
info
.
groupId
)
{
// reset output buffer and computing status
pIndefInfo
->
groupId
=
pBlock
->
info
.
groupId
;
pIndefInfo
->
pNextGroupRes
=
pBlock
;
break
;
}
}
doHandleDataBlock
(
pOperator
,
pBlock
,
downstream
,
pTaskInfo
);
if
(
pInfo
->
pRes
->
info
.
rows
>=
pOperator
->
resultInfo
.
threshold
)
{
break
;
}
}
}
}
}
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
order
,
scanFlag
,
false
);
doFilter
(
pIndefInfo
->
pCondition
,
pInfo
->
pRes
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pInfo
->
pRes
->
info
.
rows
+
pBlock
->
info
.
rows
);
size_t
rows
=
pInfo
->
pRes
->
info
.
rows
;
if
(
rows
>=
0
)
{
code
=
projectApplyFunctions
(
pOperator
->
exprSupp
.
pExprInfo
,
pInfo
->
pRes
,
pBlock
,
pSup
->
pCtx
,
break
;
pOperator
->
exprSupp
.
numOfExprs
,
pIndefInfo
->
pPseudoColInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
}
}
}
doFilter
(
pIndefInfo
->
pCondition
,
pInfo
->
pRes
);
size_t
rows
=
pInfo
->
pRes
->
info
.
rows
;
size_t
rows
=
pInfo
->
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
rows
;
pOperator
->
resultInfo
.
totalRows
+=
rows
;
...
@@ -3928,24 +3968,23 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
...
@@ -3928,24 +3968,23 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
if
(
numOfRows
*
pResBlock
->
info
.
rowSize
>
TWOMB
)
{
if
(
numOfRows
*
pResBlock
->
info
.
rowSize
>
TWOMB
)
{
numOfRows
=
TWOMB
/
pResBlock
->
info
.
rowSize
;
numOfRows
=
TWOMB
/
pResBlock
->
info
.
rowSize
;
}
}
initResultSizeInfo
(
pOperator
,
numOfRows
);
initResultSizeInfo
(
pOperator
,
numOfRows
);
initAggInfo
(
&
pOperator
->
exprSup
p
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfExpr
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initAggInfo
(
pSu
p
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfExpr
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
setFunctionResultOutput
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
MAIN_SCAN
,
numOfExpr
);
setFunctionResultOutput
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
MAIN_SCAN
,
numOfExpr
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
p
PseudoColInfo
=
setRowTsColumnOutputInfo
(
pSup
->
pCtx
,
numOfExpr
)
;
pInfo
->
p
Condition
=
pPhyNode
->
node
.
pConditions
;
pInfo
->
p
Condition
=
pPhyNode
->
node
.
pConditions
;
pInfo
->
p
PseudoColInfo
=
setRowTsColumnOutputInfo
(
pSup
->
pCtx
,
numOfExpr
)
;
pOperator
->
name
=
"IndefinitOperator"
;
pOperator
->
name
=
"IndefinitOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PROJECT
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC
;
pOperator
->
blocking
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
exprSupp
.
pExprInfo
=
pExprInfo
;
pOperator
->
exprSupp
.
numOfExprs
=
numOfExpr
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doApplyIndefinitFunction
,
NULL
,
NULL
,
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doApplyIndefinitFunction
,
NULL
,
NULL
,
...
@@ -4006,6 +4045,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
...
@@ -4006,6 +4045,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
pInfo
->
primaryTsCol
=
((
SColumnNode
*
)
pPhyFillNode
->
pWStartTs
)
->
slotId
;
int32_t
numOfOutputCols
=
0
;
int32_t
numOfOutputCols
=
0
;
SArray
*
pColMatchColInfo
=
SArray
*
pColMatchColInfo
=
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
24042fff
...
@@ -637,6 +637,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
...
@@ -637,6 +637,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
int32_t
*
pageId
=
taosArrayGet
(
pGroupInfo
->
pPageList
,
pInfo
->
pageIndex
);
int32_t
*
pageId
=
taosArrayGet
(
pGroupInfo
->
pPageList
,
pInfo
->
pageIndex
);
void
*
page
=
getBufPage
(
pInfo
->
pBuf
,
*
pageId
);
void
*
page
=
getBufPage
(
pInfo
->
pBuf
,
*
pageId
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pInfo
->
rowCapacity
);
blockDataFromBuf1
(
pInfo
->
binfo
.
pRes
,
page
,
pInfo
->
rowCapacity
);
blockDataFromBuf1
(
pInfo
->
binfo
.
pRes
,
page
,
pInfo
->
rowCapacity
);
pInfo
->
pageIndex
+=
1
;
pInfo
->
pageIndex
+=
1
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
24042fff
...
@@ -1134,12 +1134,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
...
@@ -1134,12 +1134,6 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
pInfo
->
pRes
->
info
.
type
=
STREAM_NORMAL
;
pInfo
->
pRes
->
info
.
type
=
STREAM_NORMAL
;
pInfo
->
pRes
->
info
.
capacity
=
pBlock
->
info
.
rows
;
pInfo
->
pRes
->
info
.
capacity
=
pBlock
->
info
.
rows
;
// for generating rollup SMA result, each time is an independent time serie.
// TODO temporarily used, when the statement of "partition by tbname" is ready, remove this
if
(
pInfo
->
assignBlockUid
)
{
pInfo
->
pRes
->
info
.
groupId
=
pBlock
->
info
.
uid
;
}
uint64_t
*
groupIdPre
=
taosHashGet
(
pOperator
->
pTaskInfo
->
tableqinfoList
.
map
,
&
pBlock
->
info
.
uid
,
sizeof
(
int64_t
));
uint64_t
*
groupIdPre
=
taosHashGet
(
pOperator
->
pTaskInfo
->
tableqinfoList
.
map
,
&
pBlock
->
info
.
uid
,
sizeof
(
int64_t
));
if
(
groupIdPre
)
{
if
(
groupIdPre
)
{
pInfo
->
pRes
->
info
.
groupId
=
*
groupIdPre
;
pInfo
->
pRes
->
info
.
groupId
=
*
groupIdPre
;
...
@@ -1147,6 +1141,12 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
...
@@ -1147,6 +1141,12 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
pInfo
->
pRes
->
info
.
groupId
=
0
;
pInfo
->
pRes
->
info
.
groupId
=
0
;
}
}
// for generating rollup SMA result, each time is an independent time serie.
// TODO temporarily used, when the statement of "partition by tbname" is ready, remove this
if
(
pInfo
->
assignBlockUid
)
{
pInfo
->
pRes
->
info
.
groupId
=
pBlock
->
info
.
uid
;
}
// todo extract method
// todo extract method
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pColMatchInfo
);
++
i
)
{
SColMatchInfo
*
pColMatchInfo
=
taosArrayGet
(
pInfo
->
pColMatchInfo
,
i
);
SColMatchInfo
*
pColMatchInfo
=
taosArrayGet
(
pInfo
->
pColMatchInfo
,
i
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
24042fff
...
@@ -4502,6 +4502,7 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
...
@@ -4502,6 +4502,7 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
}
}
size_t
rows
=
pRes
->
info
.
rows
;
size_t
rows
=
pRes
->
info
.
rows
;
blockDataUpdateTsWindow
(
pRes
,
iaInfo
->
primaryTsIndex
);
pOperator
->
resultInfo
.
totalRows
+=
rows
;
pOperator
->
resultInfo
.
totalRows
+=
rows
;
return
(
rows
==
0
)
?
NULL
:
pRes
;
return
(
rows
==
0
)
?
NULL
:
pRes
;
}
}
...
...
source/libs/function/src/builtins.c
浏览文件 @
24042fff
...
@@ -48,8 +48,8 @@ static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
...
@@ -48,8 +48,8 @@ static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
return
TIME_UNIT_INVALID
;
return
TIME_UNIT_INVALID
;
}
}
if
(
TSDB_TIME_PRECISION_MILLI
==
dbPrec
&&
(
0
==
strcasecmp
(
pVal
->
literal
,
"1u"
)
||
if
(
TSDB_TIME_PRECISION_MILLI
==
dbPrec
&&
0
==
strcasecmp
(
pVal
->
literal
,
"1b"
)))
{
(
0
==
strcasecmp
(
pVal
->
literal
,
"1u"
)
||
0
==
strcasecmp
(
pVal
->
literal
,
"1b"
)))
{
return
TIME_UNIT_TOO_SMALL
;
return
TIME_UNIT_TOO_SMALL
;
}
}
...
@@ -57,10 +57,9 @@ static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
...
@@ -57,10 +57,9 @@ static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
return
TIME_UNIT_TOO_SMALL
;
return
TIME_UNIT_TOO_SMALL
;
}
}
if
(
pVal
->
literal
[
0
]
!=
'1'
||
(
pVal
->
literal
[
1
]
!=
'u'
&&
pVal
->
literal
[
1
]
!=
'a'
&&
if
(
pVal
->
literal
[
0
]
!=
'1'
||
pVal
->
literal
[
1
]
!=
's'
&&
pVal
->
literal
[
1
]
!=
'm'
&&
(
pVal
->
literal
[
1
]
!=
'u'
&&
pVal
->
literal
[
1
]
!=
'a'
&&
pVal
->
literal
[
1
]
!=
's'
&&
pVal
->
literal
[
1
]
!=
'm'
&&
pVal
->
literal
[
1
]
!=
'h'
&&
pVal
->
literal
[
1
]
!=
'd'
&&
pVal
->
literal
[
1
]
!=
'h'
&&
pVal
->
literal
[
1
]
!=
'd'
&&
pVal
->
literal
[
1
]
!=
'w'
&&
pVal
->
literal
[
1
]
!=
'b'
))
{
pVal
->
literal
[
1
]
!=
'w'
&&
pVal
->
literal
[
1
]
!=
'b'
))
{
return
TIME_UNIT_INVALID
;
return
TIME_UNIT_INVALID
;
}
}
...
@@ -678,9 +677,10 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
...
@@ -678,9 +677,10 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
SNode
*
pPara1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
if
(
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pPara1
)
||
PRIMARYKEY_TIMESTAMP_COL_ID
!=
((
SColumnNode
*
)
pPara1
)
->
colId
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"The first parameter of the ELAPSED function can only be the timestamp primary key"
);
}
}
// param1
// param1
...
@@ -694,8 +694,7 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
...
@@ -694,8 +694,7 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
pValue
->
notReserved
=
true
;
pValue
->
notReserved
=
true
;
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
if
(
!
IS_INTEGER_TYPE
(
pValue
->
node
.
resType
.
type
))
{
if
(
!
IS_INTEGER_TYPE
(
paraType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
@@ -706,8 +705,9 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
...
@@ -706,8 +705,9 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be greater than db precision"
);
"ELAPSED function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
"ELAPSED function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"ELAPSED function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
}
}
...
@@ -1229,7 +1229,8 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
...
@@ -1229,7 +1229,8 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
"STATEDURATION function time unit parameter should be greater than db precision"
);
"STATEDURATION function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"STATEDURATION function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
"STATEDURATION function time unit parameter should be one of the following: [1b, 1u, 1a, "
"1s, 1m, 1h, 1d, 1w]"
);
}
}
}
}
...
@@ -1740,8 +1741,9 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
...
@@ -1740,8 +1741,9 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be greater than db precision"
);
"TIMETRUNCATE function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
"TIMETRUNCATE function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMETRUNCATE function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
addDbPrecisonParam
(
&
pFunc
->
pParameterList
,
dbPrec
);
...
@@ -1779,8 +1781,9 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
...
@@ -1779,8 +1781,9 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be greater than db precision"
);
"TIMEDIFF function time unit parameter should be greater than db precision"
);
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
}
else
if
(
ret
==
TIME_UNIT_INVALID
)
{
return
buildFuncErrMsg
(
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
return
buildFuncErrMsg
(
"TIMEDIFF function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
pErrBuf
,
len
,
TSDB_CODE_FUNC_FUNTION_ERROR
,
"TIMEDIFF function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"
);
}
}
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
24042fff
...
@@ -1793,7 +1793,7 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
...
@@ -1793,7 +1793,7 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
}
else
if
(
pCol
->
hasIndex
)
{
}
else
if
(
pCol
->
hasIndex
)
{
pCxt
->
hasTagIndexCol
=
true
;
pCxt
->
hasTagIndexCol
=
true
;
pCxt
->
hasTagCol
=
true
;
pCxt
->
hasTagCol
=
true
;
}
else
if
(
COLUMN_TYPE_TAG
==
pCol
->
colType
)
{
}
else
if
(
COLUMN_TYPE_TAG
==
pCol
->
colType
||
COLUMN_TYPE_TBNAME
==
pCol
->
colType
)
{
pCxt
->
hasTagCol
=
true
;
pCxt
->
hasTagCol
=
true
;
}
else
{
}
else
{
pCxt
->
hasOtherCol
=
true
;
pCxt
->
hasOtherCol
=
true
;
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
24042fff
...
@@ -339,6 +339,10 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
...
@@ -339,6 +339,10 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
SNode
*
createPlaceholderValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
)
{
SNode
*
createPlaceholderValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
if
(
NULL
==
pCxt
->
pQueryCxt
->
pStmtCb
)
{
pCxt
->
errCode
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_SYNTAX_ERROR
,
pLiteral
->
z
);
return
NULL
;
}
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
CHECK_OUT_OF_MEM
(
val
);
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
24042fff
...
@@ -461,12 +461,10 @@ static bool isDistinctOrderBy(STranslateContext* pCxt) {
...
@@ -461,12 +461,10 @@ static bool isDistinctOrderBy(STranslateContext* pCxt) {
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isDistinct
);
((
SSelectStmt
*
)
pCxt
->
pCurrStmt
)
->
isDistinct
);
}
}
static
bool
belongTable
(
const
char
*
currentDb
,
const
SColumnNode
*
pCol
,
const
STableNode
*
pTable
)
{
static
bool
belongTable
(
const
SColumnNode
*
pCol
,
const
STableNode
*
pTable
)
{
int
cmp
=
0
;
int
cmp
=
0
;
if
(
'\0'
!=
pCol
->
dbName
[
0
])
{
if
(
'\0'
!=
pCol
->
dbName
[
0
])
{
cmp
=
strcmp
(
pCol
->
dbName
,
pTable
->
dbName
);
cmp
=
strcmp
(
pCol
->
dbName
,
pTable
->
dbName
);
}
else
{
cmp
=
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
)
?
strcmp
(
currentDb
,
pTable
->
dbName
)
:
0
);
}
}
if
(
0
==
cmp
)
{
if
(
0
==
cmp
)
{
cmp
=
strcmp
(
pCol
->
tableAlias
,
pTable
->
tableAlias
);
cmp
=
strcmp
(
pCol
->
tableAlias
,
pTable
->
tableAlias
);
...
@@ -630,7 +628,7 @@ static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode**
...
@@ -630,7 +628,7 @@ static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode**
bool
foundTable
=
false
;
bool
foundTable
=
false
;
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
if
(
belongTable
(
pCxt
->
pParseCxt
->
db
,
(
*
pCol
),
pTable
))
{
if
(
belongTable
((
*
pCol
),
pTable
))
{
foundTable
=
true
;
foundTable
=
true
;
bool
foundCol
=
false
;
bool
foundCol
=
false
;
pCxt
->
errCode
=
findAndSetColumn
(
pCxt
,
pCol
,
pTable
,
&
foundCol
);
pCxt
->
errCode
=
findAndSetColumn
(
pCxt
,
pCol
,
pTable
,
&
foundCol
);
...
@@ -4017,8 +4015,15 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
...
@@ -4017,8 +4015,15 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
if
(
NULL
!=
pStmt
->
pOptions
->
pStreamOptions
)
{
if
(
NULL
!=
pStmt
->
pOptions
->
pStreamOptions
)
{
SStreamOptions
*
pStreamOpt
=
(
SStreamOptions
*
)
pStmt
->
pOptions
->
pStreamOptions
;
SStreamOptions
*
pStreamOpt
=
(
SStreamOptions
*
)
pStmt
->
pOptions
->
pStreamOptions
;
pReq
->
maxDelay
=
(
NULL
!=
pStreamOpt
->
pDelay
?
((
SValueNode
*
)
pStreamOpt
->
pDelay
)
->
datum
.
i
:
0
);
pReq
->
maxDelay
=
(
NULL
!=
pStreamOpt
->
pDelay
?
((
SValueNode
*
)
pStreamOpt
->
pDelay
)
->
datum
.
i
:
-
1
);
pReq
->
watermark
=
(
NULL
!=
pStreamOpt
->
pWatermark
?
((
SValueNode
*
)
pStreamOpt
->
pWatermark
)
->
datum
.
i
:
0
);
pReq
->
watermark
=
(
NULL
!=
pStreamOpt
->
pWatermark
?
((
SValueNode
*
)
pStreamOpt
->
pWatermark
)
->
datum
.
i
:
TSDB_DEFAULT_ROLLUP_WATERMARK
);
if
(
pReq
->
watermark
<
TSDB_MIN_ROLLUP_WATERMARK
)
{
pReq
->
watermark
=
TSDB_MIN_ROLLUP_WATERMARK
;
}
if
(
pReq
->
watermark
>
TSDB_MAX_ROLLUP_WATERMARK
)
{
pReq
->
watermark
=
TSDB_MAX_ROLLUP_WATERMARK
;
}
}
}
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
...
...
source/libs/parser/src/parser.c
浏览文件 @
24042fff
...
@@ -41,7 +41,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
...
@@ -41,7 +41,7 @@ bool qIsInsertValuesSql(const char* pStr, size_t length) {
}
else
if
(
TK_SELECT
==
t
.
type
)
{
}
else
if
(
TK_SELECT
==
t
.
type
)
{
return
false
;
return
false
;
}
}
if
(
0
==
t
.
type
)
{
if
(
0
==
t
.
type
||
0
==
t
.
n
)
{
break
;
break
;
}
}
}
while
(
pStr
-
pSql
<
length
);
}
while
(
pStr
-
pSql
<
length
);
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
24042fff
...
@@ -337,70 +337,69 @@ TEST_F(ParserSelectTest, semanticCheck) {
...
@@ -337,70 +337,69 @@ TEST_F(ParserSelectTest, semanticCheck) {
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
// TSDB_CODE_PAR_INVALID_COLUMN
// TSDB_CODE_PAR_INVALID_COLUMN
run
(
"SELECT c1, cc1 FROM t1"
,
TSDB_CODE_PAR_INVALID_COLUMN
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c1, cc1 FROM t1"
,
TSDB_CODE_PAR_INVALID_COLUMN
);
run
(
"SELECT t1.c1, t1.cc1 FROM t1"
,
TSDB_CODE_PAR_INVALID_COLUMN
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT t1.c1, t1.cc1 FROM t1"
,
TSDB_CODE_PAR_INVALID_COLUMN
);
// TSDB_CODE_PAR_TABLE_NOT_EXIST
// TSDB_CODE_PAR_TABLE_NOT_EXIST
run
(
"SELECT * FROM t10"
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT * FROM t10"
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
);
run
(
"SELECT * FROM test.t10"
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT * FROM test.t10"
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
);
run
(
"SELECT t2.c1 FROM t1"
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT t2.c1 FROM t1"
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
);
// TSDB_CODE_PAR_AMBIGUOUS_COLUMN
// TSDB_CODE_PAR_AMBIGUOUS_COLUMN
run
(
"SELECT c2 FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
);
run
(
"SELECT c2 FROM (SELECT c1 c2, c2 FROM t1)"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM (SELECT c1 c2, c2 FROM t1)"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
);
// TSDB_CODE_PAR_WRONG_VALUE_TYPE
// TSDB_CODE_PAR_WRONG_VALUE_TYPE
run
(
"SELECT timestamp '2010a' FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT timestamp '2010a' FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
);
run
(
"SELECT LAST(*) + SUM(c1) FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT LAST(*) + SUM(c1) FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
);
run
(
"SELECT CEIL(LAST(ts, c1)) FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT CEIL(LAST(ts, c1)) FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
);
// TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
// TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
run
(
"SELECT c2 FROM t1 tt1 join t1 tt2 on COUNT(*) > 0"
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
,
run
(
"SELECT c2 FROM t1 tt1 join t1 tt2 on COUNT(*) > 0"
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
);
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM t1 WHERE COUNT(*) > 0"
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM t1 WHERE COUNT(*) > 0"
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
);
run
(
"SELECT c2 FROM t1 GROUP BY COUNT(*)"
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM t1 GROUP BY COUNT(*)"
,
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
);
// TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
// TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
run
(
"SELECT c2 FROM t1 order by 0"
,
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM t1 order by 0"
,
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
);
run
(
"SELECT c2 FROM t1 order by 2"
,
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM t1 order by 2"
,
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
);
// TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
// TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
run
(
"SELECT COUNT(*) cnt FROM t1 having c1 > 0"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT COUNT(*) cnt FROM t1 having c1 > 0"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
);
run
(
"SELECT COUNT(*) cnt FROM t1 GROUP BY c2 having c1 > 0"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
,
run
(
"SELECT COUNT(*) cnt FROM t1 GROUP BY c2 having c1 > 0"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
);
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT COUNT(*), c1 cnt FROM t1 GROUP BY c2 having c2 > 0"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
,
run
(
"SELECT COUNT(*), c1 cnt FROM t1 GROUP BY c2 having c2 > 0"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
);
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT COUNT(*) cnt FROM t1 GROUP BY c2 having c2 > 0 order by c1"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
,
run
(
"SELECT COUNT(*) cnt FROM t1 GROUP BY c2 having c2 > 0 order by c1"
,
TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION
);
PARSER_STAGE_TRANSLATE
);
// TSDB_CODE_PAR_NOT_SINGLE_GROUP
// TSDB_CODE_PAR_NOT_SINGLE_GROUP
run
(
"SELECT COUNT(*), c1 FROM t1"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT COUNT(*), c1 FROM t1"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
);
run
(
"SELECT COUNT(*) FROM t1 order by c1"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT COUNT(*) FROM t1 order by c1"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
);
run
(
"SELECT c1 FROM t1 order by COUNT(*)"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c1 FROM t1 order by COUNT(*)"
,
TSDB_CODE_PAR_NOT_SINGLE_GROUP
);
// TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
// TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
run
(
"SELECT distinct c1, c2 FROM t1 WHERE c1 > 0 order by ts"
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
,
run
(
"SELECT distinct c1, c2 FROM t1 WHERE c1 > 0 order by ts"
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
);
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT distinct c1 FROM t1 WHERE c1 > 0 order by COUNT(c2)"
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
,
run
(
"SELECT distinct c1 FROM t1 WHERE c1 > 0 order by COUNT(c2)"
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
);
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT distinct c2 FROM t1 WHERE c1 > 0 order by COUNT(c2)"
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
,
run
(
"SELECT distinct c2 FROM t1 WHERE c1 > 0 order by COUNT(c2)"
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
);
PARSER_STAGE_TRANSLATE
);
}
TEST_F
(
ParserSelectTest
,
syntaxError
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT CAST(? AS BINARY(10)) FROM t1"
,
TSDB_CODE_PAR_SYNTAX_ERROR
,
PARSER_STAGE_PARSE
);
}
}
TEST_F
(
ParserSelectTest
,
setOperator
)
{
TEST_F
(
ParserSelectTest
,
setOperator
)
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
24042fff
...
@@ -80,6 +80,23 @@ static void optResetParent(SLogicNode* pNode) {
...
@@ -80,6 +80,23 @@ static void optResetParent(SLogicNode* pNode) {
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
((
SLogicNode
*
)
pChild
)
->
pParent
=
pNode
;
}
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
((
SLogicNode
*
)
pChild
)
->
pParent
=
pNode
;
}
}
}
static
EDealRes
optRebuildTbanme
(
SNode
**
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
)
&&
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
*
pNode
)
->
colType
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
*
(
int32_t
*
)
pContext
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
strcpy
(
pFunc
->
functionName
,
"tbname"
);
pFunc
->
funcType
=
FUNCTION_TYPE_TBNAME
;
pFunc
->
node
.
resType
=
((
SColumnNode
*
)
*
pNode
)
->
node
.
resType
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pFunc
;
return
DEAL_RES_IGNORE_CHILD
;
}
return
DEAL_RES_CONTINUE
;
}
EDealRes
scanPathOptHaveNormalColImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
EDealRes
scanPathOptHaveNormalColImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
// *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType);
// *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType);
...
@@ -312,6 +329,12 @@ static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNo
...
@@ -312,6 +329,12 @@ static int32_t pushDownCondOptCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNo
return
code
;
return
code
;
}
}
static
int32_t
pushDownCondOptRebuildTbanme
(
SNode
**
pTagCond
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
nodesRewriteExpr
(
pTagCond
,
optRebuildTbanme
,
&
code
);
return
code
;
}
static
int32_t
pushDownCondOptDealScan
(
SOptimizeContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
static
int32_t
pushDownCondOptDealScan
(
SOptimizeContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
if
(
NULL
==
pScan
->
node
.
pConditions
||
if
(
NULL
==
pScan
->
node
.
pConditions
||
OPTIMIZE_FLAG_TEST_MASK
(
pScan
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_PUSH_DOWN_CONDE
)
||
OPTIMIZE_FLAG_TEST_MASK
(
pScan
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_PUSH_DOWN_CONDE
)
||
...
@@ -323,6 +346,9 @@ static int32_t pushDownCondOptDealScan(SOptimizeContext* pCxt, SScanLogicNode* p
...
@@ -323,6 +346,9 @@ static int32_t pushDownCondOptDealScan(SOptimizeContext* pCxt, SScanLogicNode* p
SNode
*
pOtherCond
=
NULL
;
SNode
*
pOtherCond
=
NULL
;
int32_t
code
=
nodesPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pScan
->
pTagIndexCond
,
&
pScan
->
pTagCond
,
int32_t
code
=
nodesPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pScan
->
pTagIndexCond
,
&
pScan
->
pTagCond
,
&
pOtherCond
);
&
pOtherCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pScan
->
pTagCond
)
{
code
=
pushDownCondOptRebuildTbanme
(
&
pScan
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrimaryKeyCond
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrimaryKeyCond
)
{
code
=
pushDownCondOptCalcTimeRange
(
pCxt
,
pScan
,
&
pPrimaryKeyCond
,
&
pOtherCond
);
code
=
pushDownCondOptCalcTimeRange
(
pCxt
,
pScan
,
&
pPrimaryKeyCond
,
&
pOtherCond
);
}
}
...
@@ -1386,26 +1412,9 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
...
@@ -1386,26 +1412,9 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
));
return
!
partTagsOptHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
));
}
}
static
EDealRes
partTagsOptRebuildTbanmeImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
)
&&
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
*
pNode
)
->
colType
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
*
(
int32_t
*
)
pContext
=
TSDB_CODE_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
}
strcpy
(
pFunc
->
functionName
,
"tbname"
);
pFunc
->
funcType
=
FUNCTION_TYPE_TBNAME
;
pFunc
->
node
.
resType
=
((
SColumnNode
*
)
*
pNode
)
->
node
.
resType
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pFunc
;
return
DEAL_RES_IGNORE_CHILD
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
partTagsOptRebuildTbanme
(
SNodeList
*
pPartKeys
)
{
static
int32_t
partTagsOptRebuildTbanme
(
SNodeList
*
pPartKeys
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
nodesRewriteExprs
(
pPartKeys
,
partTagsOptRebuildTbanmeImpl
,
&
code
);
nodesRewriteExprs
(
pPartKeys
,
optRebuildTbanme
,
&
code
);
return
code
;
return
code
;
}
}
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
24042fff
...
@@ -37,6 +37,8 @@ TEST_F(PlanOptimizeTest, pushDownCondition) {
...
@@ -37,6 +37,8 @@ TEST_F(PlanOptimizeTest, pushDownCondition) {
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4"
);
run
(
"SELECT ts, c1 FROM st1 WHERE TBNAME = 'st1s1'"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 or tag1 < 2"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 or tag1 < 2"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"
);
...
...
source/libs/planner/test/planTestUtil.cpp
浏览文件 @
24042fff
...
@@ -330,6 +330,10 @@ class PlannerTestBaseImpl {
...
@@ -330,6 +330,10 @@ class PlannerTestBaseImpl {
cxt
.
pMsg
=
stmtEnv_
.
msgBuf_
.
data
();
cxt
.
pMsg
=
stmtEnv_
.
msgBuf_
.
data
();
cxt
.
msgLen
=
stmtEnv_
.
msgBuf_
.
max_size
();
cxt
.
msgLen
=
stmtEnv_
.
msgBuf_
.
max_size
();
cxt
.
svrVer
=
"3.0.0.0"
;
cxt
.
svrVer
=
"3.0.0.0"
;
if
(
prepare
)
{
SStmtCallback
stmtCb
=
{
0
};
cxt
.
pStmtCb
=
&
stmtCb
;
}
DO_WITH_THROW
(
qParseSql
,
&
cxt
,
pQuery
);
DO_WITH_THROW
(
qParseSql
,
&
cxt
,
pQuery
);
if
(
prepare
)
{
if
(
prepare
)
{
...
...
source/libs/qworker/inc/qwInt.h
浏览文件 @
24042fff
...
@@ -316,34 +316,34 @@ typedef struct SQWorkerMgmt {
...
@@ -316,34 +316,34 @@ typedef struct SQWorkerMgmt {
#define QW_LOCK(type, _lock) \
#define QW_LOCK(type, _lock) \
do { \
do { \
if (QW_READ == (type)) { \
if (QW_READ == (type)) { \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
QW_LOCK_DEBUG("QW RLOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW RLOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosRLockLatch(_lock); \
taosRLockLatch(_lock); \
QW_LOCK_DEBUG("QW RLOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW RLOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) > 0); \
assert(atomic_load_
64
((_lock)) > 0); \
} else { \
} else { \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
QW_LOCK_DEBUG("QW WLOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW WLOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosWLockLatch(_lock); \
taosWLockLatch(_lock); \
QW_LOCK_DEBUG("QW WLOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW WLOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
assert(atomic_load_
64
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
} \
} \
} while (0)
} while (0)
#define QW_UNLOCK(type, _lock) \
#define QW_UNLOCK(type, _lock) \
do { \
do { \
if (QW_READ == (type)) { \
if (QW_READ == (type)) { \
assert(atomic_load_
32
((_lock)) > 0); \
assert(atomic_load_
64
((_lock)) > 0); \
QW_LOCK_DEBUG("QW RULOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW RULOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosRUnLockLatch(_lock); \
taosRUnLockLatch(_lock); \
QW_LOCK_DEBUG("QW RULOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW RULOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
} else { \
} else { \
assert(atomic_load_
32
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
assert(atomic_load_
64
((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \
QW_LOCK_DEBUG("QW WULOCK%p:%
d, %s:%d B", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW WULOCK%p:%
" PRIx64 ", %s:%d B", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
taosWUnLockLatch(_lock); \
taosWUnLockLatch(_lock); \
QW_LOCK_DEBUG("QW WULOCK%p:%
d, %s:%d E", (_lock), atomic_load_32
(_lock), __FILE__, __LINE__); \
QW_LOCK_DEBUG("QW WULOCK%p:%
" PRIx64 ", %s:%d E", (_lock), atomic_load_64
(_lock), __FILE__, __LINE__); \
assert(atomic_load_
32
((_lock)) >= 0); \
assert(atomic_load_
64
((_lock)) >= 0); \
} \
} \
} while (0)
} while (0)
...
...
source/libs/scalar/src/filter.c
浏览文件 @
24042fff
...
@@ -3623,7 +3623,8 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
...
@@ -3623,7 +3623,8 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
&&
node
->
opType
>=
OP_TYPE_NOT_EQUAL
)
{
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
&&
(
node
->
opType
>=
OP_TYPE_NOT_EQUAL
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
stat
->
scalarMode
=
true
;
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
...
...
source/libs/scheduler/inc/schInt.h
浏览文件 @
24042fff
...
@@ -54,6 +54,11 @@ typedef enum {
...
@@ -54,6 +54,11 @@ typedef enum {
SCH_OP_GET_STATUS
,
SCH_OP_GET_STATUS
,
}
SCH_OP_TYPE
;
}
SCH_OP_TYPE
;
typedef
struct
SSchDebug
{
bool
lockEnable
;
bool
apiEnable
;
}
SSchDebug
;
typedef
struct
SSchTrans
{
typedef
struct
SSchTrans
{
void
*
pTrans
;
void
*
pTrans
;
void
*
pHandle
;
void
*
pHandle
;
...
@@ -186,7 +191,7 @@ typedef struct SSchTaskProfile {
...
@@ -186,7 +191,7 @@ typedef struct SSchTaskProfile {
typedef
struct
SSchTask
{
typedef
struct
SSchTask
{
uint64_t
taskId
;
// task id
uint64_t
taskId
;
// task id
SRWLatch
lock
;
// task lock
SRWLatch
lock
;
// task
reentrant
lock
int32_t
maxExecTimes
;
// task may exec times
int32_t
maxExecTimes
;
// task may exec times
int32_t
execId
;
// task current execute try index
int32_t
execId
;
// task current execute try index
SSchLevel
*
level
;
// level
SSchLevel
*
level
;
// level
...
@@ -356,8 +361,41 @@ extern SSchedulerMgmt schMgmt;
...
@@ -356,8 +361,41 @@ extern SSchedulerMgmt schMgmt;
#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(_code); } return _code; } while (0)
#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(_code); } return _code; } while (0)
#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(code); goto _return; } } while (0)
#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(code); goto _return; } } while (0)
#define SCH_LOCK(type, _lock) (SCH_READ == (type) ? taosRLockLatch(_lock) : taosWLockLatch(_lock))
#define SCH_LOCK_DEBUG(...) do { if (gSCHDebug.lockEnable) { qDebug(__VA_ARGS__); } } while (0)
#define SCH_UNLOCK(type, _lock) (SCH_READ == (type) ? taosRUnLockLatch(_lock) : taosWUnLockLatch(_lock))
#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000
#define SCH_LOCK(type, _lock) do { \
if (SCH_READ == (type)) { \
assert(atomic_load_64(_lock) >= 0); \
SCH_LOCK_DEBUG("SCH RLOCK%p:%" PRIx64 ", %s:%d B", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
taosRLockLatch(_lock); \
SCH_LOCK_DEBUG("SCH RLOCK%p:%" PRIx64 ", %s:%d E", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
assert(atomic_load_64(_lock) > 0); \
} else { \
assert(atomic_load_64(_lock) >= 0); \
SCH_LOCK_DEBUG("SCH WLOCK%p:%" PRIx64 ", %s:%d B", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
taosWLockLatch(_lock); \
SCH_LOCK_DEBUG("SCH WLOCK%p:%" PRIx64 ", %s:%d E", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
assert(atomic_load_64(_lock) & TD_RWLATCH_WRITE_FLAG_COPY); \
} \
} while (0)
#define SCH_UNLOCK(type, _lock) do { \
if (SCH_READ == (type)) { \
assert(atomic_load_64((_lock)) > 0); \
SCH_LOCK_DEBUG("SCH RULOCK%p:%" PRIx64 ", %s:%d B", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
taosRUnLockLatch(_lock); \
SCH_LOCK_DEBUG("SCH RULOCK%p:%" PRIx64 ", %s:%d E", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
assert(atomic_load_64((_lock)) >= 0); \
} else { \
assert(atomic_load_64((_lock)) & TD_RWLATCH_WRITE_FLAG_COPY); \
SCH_LOCK_DEBUG("SCH WULOCK%p:%" PRIx64 ", %s:%d B", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
taosWUnLockLatch(_lock); \
SCH_LOCK_DEBUG("SCH WULOCK%p:%" PRIx64 ", %s:%d E", (_lock), atomic_load_64(_lock), __FILE__, __LINE__); \
assert(atomic_load_64((_lock)) >= 0); \
} \
} while (0)
void
schDeregisterTaskHb
(
SSchJob
*
pJob
,
SSchTask
*
pTask
);
void
schDeregisterTaskHb
(
SSchJob
*
pJob
,
SSchTask
*
pTask
);
...
@@ -436,6 +474,8 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *
...
@@ -436,6 +474,8 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *
int32_t
schSwitchTaskCandidateAddr
(
SSchJob
*
pJob
,
SSchTask
*
pTask
);
int32_t
schSwitchTaskCandidateAddr
(
SSchJob
*
pJob
,
SSchTask
*
pTask
);
void
schDirectPostJobRes
(
SSchedulerReq
*
pReq
,
int32_t
errCode
);
void
schDirectPostJobRes
(
SSchedulerReq
*
pReq
,
int32_t
errCode
);
extern
SSchDebug
gSCHDebug
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/scheduler/src/schDbg.c
浏览文件 @
24042fff
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "schInt.h"
#include "schInt.h"
tsem_t
schdRspSem
;
tsem_t
schdRspSem
;
SSchDebug
gSCHDebug
=
{
0
};
void
schdExecCallback
(
SExecResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
void
schdExecCallback
(
SExecResult
*
pResult
,
void
*
param
,
int32_t
code
)
{
if
(
code
)
{
if
(
code
)
{
...
...
source/libs/scheduler/src/schJob.c
浏览文件 @
24042fff
...
@@ -337,14 +337,14 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) {
...
@@ -337,14 +337,14 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) {
SCH_SET_JOB_TYPE
(
pJob
,
plan
->
subplanType
);
SCH_SET_JOB_TYPE
(
pJob
,
plan
->
subplanType
);
SSchTask
task
=
{
0
};
SSchTask
task
=
{
0
};
SCH_ERR_JRET
(
schInitTask
(
pJob
,
&
task
,
plan
,
pLevel
,
levelNum
));
SSchTask
*
pTask
=
taosArrayPush
(
pLevel
->
subTasks
,
&
task
);
SSchTask
*
pTask
=
taosArrayPush
(
pLevel
->
subTasks
,
&
task
);
if
(
NULL
==
pTask
)
{
if
(
NULL
==
pTask
)
{
SCH_TASK_ELOG
(
"taosArrayPush task to level failed, level:%d, taskIdx:%d"
,
pLevel
->
level
,
n
);
SCH_TASK_ELOG
(
"taosArrayPush task to level failed, level:%d, taskIdx:%d"
,
pLevel
->
level
,
n
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
SCH_ERR_JRET
(
schInitTask
(
pJob
,
pTask
,
plan
,
pLevel
,
levelNum
));
SCH_ERR_JRET
(
schAppendJobDataSrc
(
pJob
,
pTask
));
SCH_ERR_JRET
(
schAppendJobDataSrc
(
pJob
,
pTask
));
if
(
0
!=
taosHashPut
(
planToTask
,
&
plan
,
POINTER_BYTES
,
&
pTask
,
POINTER_BYTES
))
{
if
(
0
!=
taosHashPut
(
planToTask
,
&
plan
,
POINTER_BYTES
,
&
pTask
,
POINTER_BYTES
))
{
...
@@ -543,9 +543,12 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) {
...
@@ -543,9 +543,12 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) {
int32_t
schSaveJobQueryRes
(
SSchJob
*
pJob
,
SQueryTableRsp
*
rsp
)
{
int32_t
schSaveJobQueryRes
(
SSchJob
*
pJob
,
SQueryTableRsp
*
rsp
)
{
if
(
rsp
->
tbFName
[
0
])
{
if
(
rsp
->
tbFName
[
0
])
{
SCH_LOCK
(
SCH_WRITE
,
&
pJob
->
resLock
);
if
(
NULL
==
pJob
->
execRes
.
res
)
{
if
(
NULL
==
pJob
->
execRes
.
res
)
{
pJob
->
execRes
.
res
=
taosArrayInit
(
pJob
->
taskNum
,
sizeof
(
STbVerInfo
));
pJob
->
execRes
.
res
=
taosArrayInit
(
pJob
->
taskNum
,
sizeof
(
STbVerInfo
));
if
(
NULL
==
pJob
->
execRes
.
res
)
{
if
(
NULL
==
pJob
->
execRes
.
res
)
{
SCH_UNLOCK
(
SCH_WRITE
,
&
pJob
->
resLock
);
SCH_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
SCH_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
}
}
...
@@ -557,6 +560,8 @@ int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp) {
...
@@ -557,6 +560,8 @@ int32_t schSaveJobQueryRes(SSchJob *pJob, SQueryTableRsp *rsp) {
taosArrayPush
((
SArray
*
)
pJob
->
execRes
.
res
,
&
tbInfo
);
taosArrayPush
((
SArray
*
)
pJob
->
execRes
.
res
,
&
tbInfo
);
pJob
->
execRes
.
msgType
=
TDMT_SCH_QUERY
;
pJob
->
execRes
.
msgType
=
TDMT_SCH_QUERY
;
SCH_UNLOCK
(
SCH_WRITE
,
&
pJob
->
resLock
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/scheduler/src/schTask.c
浏览文件 @
24042fff
...
@@ -60,6 +60,7 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *
...
@@ -60,6 +60,7 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *
if
(
NULL
==
pTask
->
execNodes
||
NULL
==
pTask
->
profile
.
execTime
)
{
if
(
NULL
==
pTask
->
execNodes
||
NULL
==
pTask
->
profile
.
execTime
)
{
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCH_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
taosInitReentrantRWLatch
(
&
pTask
->
lock
);
SCH_SET_TASK_STATUS
(
pTask
,
JOB_TASK_STATUS_INIT
);
SCH_SET_TASK_STATUS
(
pTask
,
JOB_TASK_STATUS_INIT
);
...
@@ -263,7 +264,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
...
@@ -263,7 +264,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
SSchTask
*
parent
=
*
(
SSchTask
**
)
taosArrayGet
(
pTask
->
parents
,
i
);
SSchTask
*
parent
=
*
(
SSchTask
**
)
taosArrayGet
(
pTask
->
parents
,
i
);
int32_t
readyNum
=
atomic_add_fetch_32
(
&
parent
->
childReady
,
1
);
int32_t
readyNum
=
atomic_add_fetch_32
(
&
parent
->
childReady
,
1
);
SCH_LOCK
(
SCH_WRITE
,
&
parent
->
lock
);
SCH_LOCK
_TASK
(
parent
);
SDownstreamSourceNode
source
=
{.
type
=
QUERY_NODE_DOWNSTREAM_SOURCE
,
SDownstreamSourceNode
source
=
{.
type
=
QUERY_NODE_DOWNSTREAM_SOURCE
,
.
taskId
=
pTask
->
taskId
,
.
taskId
=
pTask
->
taskId
,
.
schedId
=
schMgmt
.
sId
,
.
schedId
=
schMgmt
.
sId
,
...
@@ -272,7 +273,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
...
@@ -272,7 +273,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
.
fetchMsgType
=
SCH_FETCH_TYPE
(
pTask
),
.
fetchMsgType
=
SCH_FETCH_TYPE
(
pTask
),
};
};
qSetSubplanExecutionNode
(
parent
->
plan
,
pTask
->
plan
->
id
.
groupId
,
&
source
);
qSetSubplanExecutionNode
(
parent
->
plan
,
pTask
->
plan
->
id
.
groupId
,
&
source
);
SCH_UNLOCK
(
SCH_WRITE
,
&
parent
->
lock
);
SCH_UNLOCK
_TASK
(
parent
);
if
(
SCH_TASK_READY_FOR_LAUNCH
(
readyNum
,
parent
))
{
if
(
SCH_TASK_READY_FOR_LAUNCH
(
readyNum
,
parent
))
{
SCH_TASK_DLOG
(
"all %d children task done, start to launch parent task 0x%"
PRIx64
,
readyNum
,
parent
->
taskId
);
SCH_TASK_DLOG
(
"all %d children task done, start to launch parent task 0x%"
PRIx64
,
readyNum
,
parent
->
taskId
);
...
...
source/libs/stream/src/stream.c
浏览文件 @
24042fff
...
@@ -208,7 +208,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
...
@@ -208,7 +208,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S
int32_t
streamProcessDispatchRsp
(
SStreamTask
*
pTask
,
SStreamDispatchRsp
*
pRsp
)
{
int32_t
streamProcessDispatchRsp
(
SStreamTask
*
pTask
,
SStreamDispatchRsp
*
pRsp
)
{
ASSERT
(
pRsp
->
inputStatus
==
TASK_OUTPUT_STATUS__NORMAL
||
pRsp
->
inputStatus
==
TASK_OUTPUT_STATUS__BLOCKED
);
ASSERT
(
pRsp
->
inputStatus
==
TASK_OUTPUT_STATUS__NORMAL
||
pRsp
->
inputStatus
==
TASK_OUTPUT_STATUS__BLOCKED
);
q
Info
(
"task %d receive dispatch rsp"
,
pTask
->
taskId
);
q
Debug
(
"task %d receive dispatch rsp"
,
pTask
->
taskId
);
int8_t
old
=
atomic_exchange_8
(
&
pTask
->
outputStatus
,
pRsp
->
inputStatus
);
int8_t
old
=
atomic_exchange_8
(
&
pTask
->
outputStatus
,
pRsp
->
inputStatus
);
ASSERT
(
old
==
TASK_OUTPUT_STATUS__WAIT
);
ASSERT
(
old
==
TASK_OUTPUT_STATUS__WAIT
);
...
@@ -242,7 +242,7 @@ int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp)
...
@@ -242,7 +242,7 @@ int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp)
}
}
int32_t
streamProcessRetrieveReq
(
SStreamTask
*
pTask
,
SStreamRetrieveReq
*
pReq
,
SRpcMsg
*
pRsp
)
{
int32_t
streamProcessRetrieveReq
(
SStreamTask
*
pTask
,
SStreamRetrieveReq
*
pReq
,
SRpcMsg
*
pRsp
)
{
q
Info
(
"task %d receive retrieve req from node %d task %d"
,
pTask
->
taskId
,
pReq
->
srcNodeId
,
pReq
->
srcTaskId
);
q
Debug
(
"task %d receive retrieve req from node %d task %d"
,
pTask
->
taskId
,
pReq
->
srcNodeId
,
pReq
->
srcTaskId
);
streamTaskEnqueueRetrieve
(
pTask
,
pReq
,
pRsp
);
streamTaskEnqueueRetrieve
(
pTask
,
pReq
,
pRsp
);
...
...
source/libs/stream/src/streamDispatch.c
浏览文件 @
24042fff
...
@@ -303,7 +303,7 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
...
@@ -303,7 +303,7 @@ int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb) {
}
}
ASSERT
(
pBlock
->
type
==
STREAM_INPUT__DATA_BLOCK
);
ASSERT
(
pBlock
->
type
==
STREAM_INPUT__DATA_BLOCK
);
q
Info
(
"stream continue dispatching: task %d"
,
pTask
->
taskId
);
q
Debug
(
"stream continue dispatching: task %d"
,
pTask
->
taskId
);
SRpcMsg
dispatchMsg
=
{
0
};
SRpcMsg
dispatchMsg
=
{
0
};
SEpSet
*
pEpSet
=
NULL
;
SEpSet
*
pEpSet
=
NULL
;
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
24042fff
...
@@ -83,7 +83,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -83,7 +83,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
newCommitIndex
=
index
;
newCommitIndex
=
index
;
if
(
gRaftDetailLog
)
{
if
(
gRaftDetailLog
)
{
sTrace
(
"syncMaybeAdvanceCommitIndex maybe to update, newCommitIndex:%"
PRId64
" commit, pSyncNode->commitIndex:%"
PRId64
,
sTrace
(
"syncMaybeAdvanceCommitIndex maybe to update, newCommitIndex:%"
PRId64
" commit, pSyncNode->commitIndex:%"
PRId64
,
newCommitIndex
,
pSyncNode
->
commitIndex
);
newCommitIndex
,
pSyncNode
->
commitIndex
);
}
}
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
24042fff
...
@@ -824,8 +824,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
...
@@ -824,8 +824,8 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
}
else
{
}
else
{
ret
=
-
1
;
ret
=
-
1
;
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
terrno
=
TSDB_CODE_SYN_INTERNAL_ERROR
;
sError
(
"vgId:%d optimized index:%"
PRId64
" error, msgtype:%s,%d"
,
pSyncNode
->
vgId
,
retIndex
,
TMSG_INFO
(
pMsg
->
msgType
),
sError
(
"vgId:%d optimized index:%"
PRId64
" error, msgtype:%s,%d"
,
pSyncNode
->
vgId
,
retIndex
,
pMsg
->
msgType
);
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
msgType
);
}
}
}
else
{
}
else
{
...
@@ -1527,7 +1527,9 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1527,7 +1527,9 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
char
logBuf
[
256
+
256
];
char
logBuf
[
256
+
256
];
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"strategy:%d, batch:%d, "
"strategy:%d, batch:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
...
@@ -1546,7 +1548,9 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1546,7 +1548,9 @@ void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"strategy:%d, batch:%d, "
"strategy:%d, batch:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
...
@@ -1590,7 +1594,9 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1590,7 +1594,9 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
char
logBuf
[
256
+
256
];
char
logBuf
[
256
+
256
];
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
...
@@ -1607,7 +1613,9 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
...
@@ -1607,7 +1613,9 @@ void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
char
*
s
=
(
char
*
)
taosMemoryMalloc
(
len
);
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
if
(
pSyncNode
!=
NULL
&&
pSyncNode
->
pRaftCfg
!=
NULL
&&
pSyncNode
->
pRaftStore
!=
NULL
)
{
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"vgId:%d, sync %s %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d, %s"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
...
@@ -1636,7 +1644,9 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
...
@@ -1636,7 +1644,9 @@ char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
SyncIndex
logBeginIndex
=
pSyncNode
->
pLogStore
->
syncLogBeginIndex
(
pSyncNode
->
pLogStore
);
SyncIndex
logBeginIndex
=
pSyncNode
->
pLogStore
->
syncLogBeginIndex
(
pSyncNode
->
pLogStore
);
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"vgId:%d, sync %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"vgId:%d, sync %s, term:%"
PRIu64
", commit:%"
PRId64
", beginlog:%"
PRId64
", lastlog:%"
PRId64
", lastsnapshot:%"
PRId64
", standby:%d, "
"replica-num:%d, "
"replica-num:%d, "
"lconfig:%"
PRId64
", changing:%d, restore:%d"
,
"lconfig:%"
PRId64
", changing:%d, restore:%d"
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
...
@@ -1839,8 +1849,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
...
@@ -1839,8 +1849,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
char
tmpbuf
[
512
];
char
tmpbuf
[
512
];
char
*
oldStr
=
syncCfg2SimpleStr
(
&
oldConfig
);
char
*
oldStr
=
syncCfg2SimpleStr
(
&
oldConfig
);
char
*
newStr
=
syncCfg2SimpleStr
(
pNewConfig
);
char
*
newStr
=
syncCfg2SimpleStr
(
pNewConfig
);
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"config change from %d to %d, index:%"
PRId64
", %s --> %s"
,
oldConfig
.
replicaNum
,
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"config change from %d to %d, index:%"
PRId64
", %s --> %s"
,
pNewConfig
->
replicaNum
,
lastConfigChangeIndex
,
oldStr
,
newStr
);
oldConfig
.
replicaNum
,
pNewConfig
->
replicaNum
,
lastConfigChangeIndex
,
oldStr
,
newStr
);
taosMemoryFree
(
oldStr
);
taosMemoryFree
(
oldStr
);
taosMemoryFree
(
newStr
);
taosMemoryFree
(
newStr
);
...
@@ -1863,8 +1873,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
...
@@ -1863,8 +1873,8 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde
char
tmpbuf
[
512
];
char
tmpbuf
[
512
];
char
*
oldStr
=
syncCfg2SimpleStr
(
&
oldConfig
);
char
*
oldStr
=
syncCfg2SimpleStr
(
&
oldConfig
);
char
*
newStr
=
syncCfg2SimpleStr
(
pNewConfig
);
char
*
newStr
=
syncCfg2SimpleStr
(
pNewConfig
);
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"do not config change from %d to %d, index:%"
PRId64
", %s --> %s"
,
oldConfig
.
replicaNum
,
snprintf
(
tmpbuf
,
sizeof
(
tmpbuf
),
"do not config change from %d to %d, index:%"
PRId64
", %s --> %s"
,
pNewConfig
->
replicaNum
,
lastConfigChangeIndex
,
oldStr
,
newStr
);
oldConfig
.
replicaNum
,
pNewConfig
->
replicaNum
,
lastConfigChangeIndex
,
oldStr
,
newStr
);
taosMemoryFree
(
oldStr
);
taosMemoryFree
(
oldStr
);
taosMemoryFree
(
newStr
);
taosMemoryFree
(
newStr
);
syncNodeEventLog
(
pSyncNode
,
tmpbuf
);
syncNodeEventLog
(
pSyncNode
,
tmpbuf
);
...
@@ -2399,7 +2409,8 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
...
@@ -2399,7 +2409,8 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
// log state
// log state
char
logBuf
[
1024
]
=
{
0
};
char
logBuf
[
1024
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%"
PRIu64
" electTimerLogicClock:%"
PRIu64
", "
"==syncNodeOnPingCb== vgId:%d, state: %d, %s, term:%"
PRIu64
" electTimerLogicClock:%"
PRIu64
", "
"electTimerLogicClockUser:%"
PRIu64
", electTimerMS:%d"
,
"electTimerLogicClockUser:%"
PRIu64
", electTimerMS:%d"
,
ths
->
vgId
,
ths
->
state
,
syncUtilState2String
(
ths
->
state
),
ths
->
pRaftStore
->
currentTerm
,
ths
->
vgId
,
ths
->
state
,
syncUtilState2String
(
ths
->
state
),
ths
->
pRaftStore
->
currentTerm
,
ths
->
electTimerLogicClock
,
ths
->
electTimerLogicClockUser
,
ths
->
electTimerMS
);
ths
->
electTimerLogicClock
,
ths
->
electTimerLogicClockUser
,
ths
->
electTimerMS
);
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
24042fff
...
@@ -101,7 +101,7 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) {
...
@@ -101,7 +101,7 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) {
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
)
{
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
pJson
=
syncCfg2Json
(
pSyncCfg
);
cJSON
*
pJson
=
syncCfg2Json
(
pSyncCfg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
return
serialized
;
}
}
...
@@ -109,7 +109,7 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) {
...
@@ -109,7 +109,7 @@ char *syncCfg2Str(SSyncCfg *pSyncCfg) {
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
)
{
char
*
syncCfg2SimpleStr
(
SSyncCfg
*
pSyncCfg
)
{
if
(
pSyncCfg
!=
NULL
)
{
if
(
pSyncCfg
!=
NULL
)
{
int32_t
len
=
512
;
int32_t
len
=
512
;
char
*
s
=
taosMemoryMalloc
(
len
);
char
*
s
=
taosMemoryMalloc
(
len
);
memset
(
s
,
0
,
len
);
memset
(
s
,
0
,
len
);
snprintf
(
s
,
len
,
"{replica-num:%d, my-index:%d, "
,
pSyncCfg
->
replicaNum
,
pSyncCfg
->
myIndex
);
snprintf
(
s
,
len
,
"{replica-num:%d, my-index:%d, "
,
pSyncCfg
->
replicaNum
,
pSyncCfg
->
myIndex
);
...
@@ -206,7 +206,7 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) {
...
@@ -206,7 +206,7 @@ cJSON *raftCfg2Json(SRaftCfg *pRaftCfg) {
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
)
{
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
)
{
cJSON
*
pJson
=
raftCfg2Json
(
pRaftCfg
);
cJSON
*
pJson
=
raftCfg2Json
(
pRaftCfg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
return
serialized
;
}
}
...
@@ -285,7 +285,7 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) {
...
@@ -285,7 +285,7 @@ int32_t raftCfgFromJson(const cJSON *pRoot, SRaftCfg *pRaftCfg) {
(
pRaftCfg
->
configIndexArr
)[
i
]
=
atoll
(
pIndex
->
valuestring
);
(
pRaftCfg
->
configIndexArr
)[
i
]
=
atoll
(
pIndex
->
valuestring
);
}
}
cJSON
*
pJsonSyncCfg
=
cJSON_GetObjectItem
(
pJson
,
"SSyncCfg"
);
cJSON
*
pJsonSyncCfg
=
cJSON_GetObjectItem
(
pJson
,
"SSyncCfg"
);
int32_t
code
=
syncCfgFromJson
(
pJsonSyncCfg
,
&
(
pRaftCfg
->
cfg
));
int32_t
code
=
syncCfgFromJson
(
pJsonSyncCfg
,
&
(
pRaftCfg
->
cfg
));
ASSERT
(
code
==
0
);
ASSERT
(
code
==
0
);
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
24042fff
...
@@ -122,8 +122,8 @@ static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncI
...
@@ -122,8 +122,8 @@ static int32_t raftLogRestoreFromSnapshot(struct SSyncLogStore* pLogStore, SyncI
char
logBuf
[
128
];
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"wal restore from snapshot error, index:%"
PRId64
", err:%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
snapshotIndex
,
err
,
"wal restore from snapshot error, index:%"
PRId64
", err:%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
err
,
errStr
,
sysErr
,
sysErrStr
);
snapshotIndex
,
err
,
err
,
errStr
,
sysErr
,
sysErrStr
);
syncNodeErrorLog
(
pData
->
pSyncNode
,
logBuf
);
syncNodeErrorLog
(
pData
->
pSyncNode
,
logBuf
);
return
-
1
;
return
-
1
;
...
@@ -207,8 +207,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
...
@@ -207,8 +207,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
SyncIndex
writeIndex
=
raftLogWriteIndex
(
pLogStore
);
SyncIndex
writeIndex
=
raftLogWriteIndex
(
pLogStore
);
if
(
pEntry
->
index
!=
writeIndex
)
{
if
(
pEntry
->
index
!=
writeIndex
)
{
sError
(
"vgId:%d wal write index error, entry-index:%"
PRId64
" update to %"
PRId64
,
pData
->
pSyncNode
->
vgId
,
pEntry
->
index
,
sError
(
"vgId:%d wal write index error, entry-index:%"
PRId64
" update to %"
PRId64
,
pData
->
pSyncNode
->
vgId
,
writeIndex
);
pEntry
->
index
,
writeIndex
);
pEntry
->
index
=
writeIndex
;
pEntry
->
index
=
writeIndex
;
}
}
...
@@ -272,8 +272,8 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index,
...
@@ -272,8 +272,8 @@ static int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index,
do
{
do
{
char
logBuf
[
128
];
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"wal read error, index:%"
PRId64
", err:%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
index
,
err
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"wal read error, index:%"
PRId64
", err:%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
err
,
errStr
,
sysErr
,
sysErrStr
);
index
,
err
,
err
,
errStr
,
sysErr
,
sysErrStr
);
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
syncNodeEventLog
(
pData
->
pSyncNode
,
logBuf
);
syncNodeEventLog
(
pData
->
pSyncNode
,
logBuf
);
}
else
{
}
else
{
...
@@ -418,8 +418,8 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -418,8 +418,8 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
do
{
do
{
char
logBuf
[
128
];
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"wal read error, index:%"
PRId64
", err:%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
index
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"wal read error, index:%"
PRId64
", err:%d %X, msg:%s, syserr:%d, sysmsg:%s"
,
err
,
err
,
errStr
,
sysErr
,
sysErrStr
);
index
,
err
,
err
,
errStr
,
sysErr
,
sysErrStr
);
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
if
(
terrno
==
TSDB_CODE_WAL_LOG_NOT_EXIST
)
{
syncNodeEventLog
(
pData
->
pSyncNode
,
logBuf
);
syncNodeEventLog
(
pData
->
pSyncNode
,
logBuf
);
}
else
{
}
else
{
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
24042fff
...
@@ -135,7 +135,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) {
...
@@ -135,7 +135,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot2(SSyncNode* pSyncNode) {
SyncIndex
newNextIndex
=
syncNodeGetLastIndex
(
pSyncNode
)
+
1
;
SyncIndex
newNextIndex
=
syncNodeGetLastIndex
(
pSyncNode
)
+
1
;
syncIndexMgrSetIndex
(
pSyncNode
->
pNextIndex
,
pDestId
,
newNextIndex
);
syncIndexMgrSetIndex
(
pSyncNode
->
pNextIndex
,
pDestId
,
newNextIndex
);
syncIndexMgrSetIndex
(
pSyncNode
->
pMatchIndex
,
pDestId
,
SYNC_INDEX_INVALID
);
syncIndexMgrSetIndex
(
pSyncNode
->
pMatchIndex
,
pDestId
,
SYNC_INDEX_INVALID
);
sError
(
"vgId:%d sync get pre term error, nextIndex:%"
PRId64
", update next-index:%"
PRId64
", match-index:%d, raftid:%"
PRId64
,
sError
(
"vgId:%d sync get pre term error, nextIndex:%"
PRId64
", update next-index:%"
PRId64
", match-index:%d, raftid:%"
PRId64
,
pSyncNode
->
vgId
,
nextIndex
,
newNextIndex
,
SYNC_INDEX_INVALID
,
pDestId
->
addr
);
pSyncNode
->
vgId
,
nextIndex
,
newNextIndex
,
SYNC_INDEX_INVALID
,
pDestId
->
addr
);
return
-
1
;
return
-
1
;
...
@@ -224,7 +225,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) {
...
@@ -224,7 +225,8 @@ int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) {
SyncIndex
newNextIndex
=
syncNodeGetLastIndex
(
pSyncNode
)
+
1
;
SyncIndex
newNextIndex
=
syncNodeGetLastIndex
(
pSyncNode
)
+
1
;
syncIndexMgrSetIndex
(
pSyncNode
->
pNextIndex
,
pDestId
,
newNextIndex
);
syncIndexMgrSetIndex
(
pSyncNode
->
pNextIndex
,
pDestId
,
newNextIndex
);
syncIndexMgrSetIndex
(
pSyncNode
->
pMatchIndex
,
pDestId
,
SYNC_INDEX_INVALID
);
syncIndexMgrSetIndex
(
pSyncNode
->
pMatchIndex
,
pDestId
,
SYNC_INDEX_INVALID
);
sError
(
"vgId:%d sync get pre term error, nextIndex:%"
PRId64
", update next-index:%"
PRId64
", match-index:%d, raftid:%"
PRId64
,
sError
(
"vgId:%d sync get pre term error, nextIndex:%"
PRId64
", update next-index:%"
PRId64
", match-index:%d, raftid:%"
PRId64
,
pSyncNode
->
vgId
,
nextIndex
,
newNextIndex
,
SYNC_INDEX_INVALID
,
pDestId
->
addr
);
pSyncNode
->
vgId
,
nextIndex
,
newNextIndex
,
SYNC_INDEX_INVALID
,
pDestId
->
addr
);
return
-
1
;
return
-
1
;
...
@@ -314,11 +316,12 @@ int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, c
...
@@ -314,11 +316,12 @@ int32_t syncNodeAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, c
char
host
[
128
];
char
host
[
128
];
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
destRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
destRaftId
->
addr
,
host
,
sizeof
(
host
),
&
port
);
sDebug
(
sDebug
(
"vgId:%d, send sync-append-entries to %s:%d, {term:%"
PRIu64
", pre-index:%"
PRId64
", pre-term:%"
PRIu64
"vgId:%d, send sync-append-entries to %s:%d, {term:%"
PRIu64
", pre-index:%"
PRId64
", pre-term:%"
PRIu64
", pterm:%"
PRIu64
", commit:%"
PRId64
", "
", pterm:%"
PRIu64
", commit:%"
PRId64
"datalen:%d}"
,
", "
pSyncNode
->
vgId
,
host
,
port
,
pMsg
->
term
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
privateTerm
,
"datalen:%d}"
,
pMsg
->
commitIndex
,
pMsg
->
dataLen
);
pSyncNode
->
vgId
,
host
,
port
,
pMsg
->
term
,
pMsg
->
prevLogIndex
,
pMsg
->
prevLogTerm
,
pMsg
->
privateTerm
,
pMsg
->
commitIndex
,
pMsg
->
dataLen
);
}
while
(
0
);
}
while
(
0
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
...
...
source/libs/sync/src/syncRequestVote.c
浏览文件 @
24042fff
...
@@ -55,7 +55,8 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
...
@@ -55,7 +55,8 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", maybe replica already dropped"
,
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", maybe replica already dropped"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
);
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
);
syncNodeEventLog
(
ths
,
logBuf
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
while
(
0
);
...
@@ -97,8 +98,9 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
...
@@ -97,8 +98,9 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", reply-grant:%d"
,
host
,
port
,
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
,
pReply
->
voteGranted
);
", reply-grant:%d"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
,
pReply
->
voteGranted
);
syncNodeEventLog
(
ths
,
logBuf
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
while
(
0
);
...
@@ -181,7 +183,8 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
...
@@ -181,7 +183,8 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", maybe replica already dropped"
,
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", maybe replica already dropped"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
);
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
);
syncNodeEventLog
(
ths
,
logBuf
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
while
(
0
);
...
@@ -221,8 +224,9 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
...
@@ -221,8 +224,9 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
uint16_t
port
;
uint16_t
port
;
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
pMsg
->
srcId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
", reply-grant:%d"
,
host
,
port
,
"recv sync-request-vote from %s:%d, term:%"
PRIu64
", lindex:%"
PRId64
", lterm:%"
PRIu64
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
,
pReply
->
voteGranted
);
", reply-grant:%d"
,
host
,
port
,
pMsg
->
term
,
pMsg
->
lastLogIndex
,
pMsg
->
lastLogTerm
,
pReply
->
voteGranted
);
syncNodeEventLog
(
ths
,
logBuf
);
syncNodeEventLog
(
ths
,
logBuf
);
}
while
(
0
);
}
while
(
0
);
...
...
source/libs/sync/src/syncRequestVoteReply.c
浏览文件 @
24042fff
...
@@ -66,8 +66,8 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg)
...
@@ -66,8 +66,8 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg)
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
char
logBuf
[
128
]
=
{
0
};
char
logBuf
[
128
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"syncNodeOnRequestVoteReplyCb error term, receive:%"
PRIu64
" current:%"
PRIu64
,
pMsg
->
term
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"syncNodeOnRequestVoteReplyCb error term, receive:%"
PRIu64
" current:%"
PRIu64
,
ths
->
pRaftStore
->
currentTerm
);
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
);
syncNodePrint2
(
logBuf
,
ths
);
syncNodePrint2
(
logBuf
,
ths
);
sError
(
"%s"
,
logBuf
);
sError
(
"%s"
,
logBuf
);
return
ret
;
return
ret
;
...
@@ -190,8 +190,9 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl
...
@@ -190,8 +190,9 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
if
(
pMsg
->
term
>
ths
->
pRaftStore
->
currentTerm
)
{
char
logBuf
[
128
]
=
{
0
};
char
logBuf
[
128
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"recv SyncRequestVoteReply, error term, receive_term:%"
PRIu64
" current_term:%"
PRIu64
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
);
"recv SyncRequestVoteReply, error term, receive_term:%"
PRIu64
" current_term:%"
PRIu64
,
pMsg
->
term
,
ths
->
pRaftStore
->
currentTerm
);
syncNodePrint2
(
logBuf
,
ths
);
syncNodePrint2
(
logBuf
,
ths
);
sError
(
"%s"
,
logBuf
);
sError
(
"%s"
,
logBuf
);
return
ret
;
return
ret
;
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
24042fff
...
@@ -153,8 +153,8 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapsho
...
@@ -153,8 +153,8 @@ int32_t snapshotSenderStart(SSyncSnapshotSender *pSender, SSnapshotParam snapsho
// event log
// event log
do
{
do
{
char
logBuf
[
128
];
char
logBuf
[
128
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"snapshot sender update lcindex from %"
PRId64
" to %"
PRId64
,
oldLastConfigIndex
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"snapshot sender update lcindex from %"
PRId64
" to %"
PRId64
,
newLastConfigIndex
);
oldLastConfigIndex
,
newLastConfigIndex
);
char
*
eventLog
=
snapshotSender2SimpleStr
(
pSender
,
logBuf
);
char
*
eventLog
=
snapshotSender2SimpleStr
(
pSender
,
logBuf
);
syncNodeEventLog
(
pSender
->
pSyncNode
,
eventLog
);
syncNodeEventLog
(
pSender
->
pSyncNode
,
eventLog
);
taosMemoryFree
(
eventLog
);
taosMemoryFree
(
eventLog
);
...
@@ -389,7 +389,9 @@ char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) {
...
@@ -389,7 +389,9 @@ char *snapshotSender2SimpleStr(SSyncSnapshotSender *pSender, char *event) {
syncUtilU642Addr
(
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"%s {%p s-param:%"
PRId64
" e-param:%"
PRId64
" laindex:%"
PRId64
" laterm:%"
PRIu64
" lcindex:%"
PRId64
" seq:%d ack:%d finish:%d pterm:%"
PRIu64
" "
"%s {%p s-param:%"
PRId64
" e-param:%"
PRId64
" laindex:%"
PRId64
" laterm:%"
PRIu64
" lcindex:%"
PRId64
" seq:%d ack:%d finish:%d pterm:%"
PRIu64
" "
"replica-index:%d %s:%d}"
,
"replica-index:%d %s:%d}"
,
event
,
pSender
,
pSender
->
snapshotParam
.
start
,
pSender
->
snapshotParam
.
end
,
pSender
->
snapshot
.
lastApplyIndex
,
event
,
pSender
,
pSender
->
snapshotParam
.
start
,
pSender
->
snapshotParam
.
end
,
pSender
->
snapshot
.
lastApplyIndex
,
pSender
->
snapshot
.
lastApplyTerm
,
pSender
->
snapshot
.
lastConfigIndex
,
pSender
->
seq
,
pSender
->
ack
,
pSender
->
snapshot
.
lastApplyTerm
,
pSender
->
snapshot
.
lastConfigIndex
,
pSender
->
seq
,
pSender
->
ack
,
...
@@ -692,7 +694,9 @@ char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event)
...
@@ -692,7 +694,9 @@ char *snapshotReceiver2SimpleStr(SSyncSnapshotReceiver *pReceiver, char *event)
syncUtilU642Addr
(
fromId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
syncUtilU642Addr
(
fromId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
snprintf
(
s
,
len
,
snprintf
(
s
,
len
,
"%s {%p start:%d ack:%d term:%"
PRIu64
" pterm:%"
PRIu64
" from:%s:%d s-param:%"
PRId64
" e-param:%"
PRId64
" laindex:%"
PRId64
" laterm:%"
PRIu64
" "
"%s {%p start:%d ack:%d term:%"
PRIu64
" pterm:%"
PRIu64
" from:%s:%d s-param:%"
PRId64
" e-param:%"
PRId64
" laindex:%"
PRId64
" laterm:%"
PRIu64
" "
"lcindex:%"
PRId64
"}"
,
"lcindex:%"
PRId64
"}"
,
event
,
pReceiver
,
pReceiver
->
start
,
pReceiver
->
ack
,
pReceiver
->
term
,
pReceiver
->
privateTerm
,
host
,
port
,
event
,
pReceiver
,
pReceiver
->
start
,
pReceiver
->
ack
,
pReceiver
->
term
,
pReceiver
->
privateTerm
,
host
,
port
,
pReceiver
->
snapshotParam
.
start
,
pReceiver
->
snapshotParam
.
end
,
pReceiver
->
snapshot
.
lastApplyIndex
,
pReceiver
->
snapshotParam
.
start
,
pReceiver
->
snapshotParam
.
end
,
pReceiver
->
snapshot
.
lastApplyIndex
,
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
24042fff
...
@@ -45,7 +45,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -45,7 +45,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
if
(
cbMeta
.
index
>
beginIndex
)
{
if
(
cbMeta
.
index
>
beginIndex
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
"
\n
"
,
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
);
cbMeta
.
flag
,
cbMeta
.
term
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
...
@@ -56,17 +57,19 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -56,17 +57,19 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
logBuf
,
sizeof
(
logBuf
),
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
...
@@ -147,8 +150,8 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_
...
@@ -147,8 +150,8 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==RestoreFinishCb=="
);
}
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==RestoreFinishCb=="
);
}
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
)
{
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
)
{
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
cbMeta
.
flag
,
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
cbMeta
.
index
,
cbMeta
.
code
,
cbMeta
.
currentTerm
,
cbMeta
.
term
);
cbMeta
.
flag
,
cbMeta
.
index
,
cbMeta
.
code
,
cbMeta
.
currentTerm
,
cbMeta
.
term
);
}
}
SSyncFSM
*
createFsm
()
{
SSyncFSM
*
createFsm
()
{
...
@@ -267,7 +270,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
...
@@ -267,7 +270,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
pMsg
->
msgType
=
9999
;
pMsg
->
msgType
=
9999
;
pMsg
->
contLen
=
256
;
pMsg
->
contLen
=
256
;
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
return
pMsg
;
return
pMsg
;
}
}
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
24042fff
...
@@ -44,8 +44,9 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -44,8 +44,9 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
if
(
cbMeta
.
index
>
beginIndex
)
{
if
(
cbMeta
.
index
>
beginIndex
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
@@ -54,17 +55,19 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -54,17 +55,19 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
logBuf
,
sizeof
(
logBuf
),
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
...
@@ -78,8 +81,8 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
...
@@ -78,8 +81,8 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==RestoreFinishCb=="
);
}
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==RestoreFinishCb=="
);
}
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
)
{
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
)
{
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
cbMeta
.
flag
,
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
cbMeta
.
index
,
cbMeta
.
code
,
cbMeta
.
currentTerm
,
cbMeta
.
term
);
cbMeta
.
flag
,
cbMeta
.
index
,
cbMeta
.
code
,
cbMeta
.
currentTerm
,
cbMeta
.
term
);
}
}
SSyncFSM
*
createFsm
()
{
SSyncFSM
*
createFsm
()
{
...
@@ -188,7 +191,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
...
@@ -188,7 +191,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
pMsg
->
msgType
=
9999
;
pMsg
->
msgType
=
9999
;
pMsg
->
contLen
=
256
;
pMsg
->
contLen
=
256
;
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
return
pMsg
;
return
pMsg
;
}
}
...
...
source/libs/sync/test/syncEntryCacheTest.cpp
浏览文件 @
24042fff
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "syncRaftLog.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
#include "syncUtil.h"
#include "tskiplist.h"
void
logTest
()
{
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sTrace
(
"--- sync log test: trace"
);
...
@@ -148,15 +149,131 @@ void test4() {
...
@@ -148,15 +149,131 @@ void test4() {
raftCacheLog2
((
char
*
)
"==test4 after get-and-del entry 3=="
,
pCache
);
raftCacheLog2
((
char
*
)
"==test4 after get-and-del entry 3=="
,
pCache
);
}
}
static
char
*
keyFn
(
const
void
*
pData
)
{
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
pData
;
return
(
char
*
)(
&
(
pEntry
->
index
));
}
static
int
cmpFn
(
const
void
*
p1
,
const
void
*
p2
)
{
return
memcmp
(
p1
,
p2
,
sizeof
(
SyncIndex
));
}
void
printSkipList
(
SSkipList
*
pSkipList
)
{
ASSERT
(
pSkipList
!=
NULL
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pSkipList
);
while
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
syncEntryPrint2
((
char
*
)
""
,
pEntry
);
}
}
void
delSkipListFirst
(
SSkipList
*
pSkipList
,
int
n
)
{
ASSERT
(
pSkipList
!=
NULL
);
sTrace
(
"delete first %d -------------"
,
n
);
SSkipListIterator
*
pIter
=
tSkipListCreateIter
(
pSkipList
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
tSkipListIterNext
(
pIter
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
tSkipListRemoveNode
(
pSkipList
,
pNode
);
}
}
SSyncRaftEntry
*
getLogEntry2
(
SSkipList
*
pSkipList
,
SyncIndex
index
)
{
SyncIndex
index2
=
index
;
SSyncRaftEntry
*
pEntry
=
NULL
;
int
arraySize
=
0
;
SArray
*
entryPArray
=
tSkipListGet
(
pSkipList
,
(
char
*
)(
&
index2
));
arraySize
=
taosArrayGetSize
(
entryPArray
);
if
(
arraySize
>
0
)
{
SSkipListNode
**
ppNode
=
(
SSkipListNode
**
)
taosArrayGet
(
entryPArray
,
0
);
ASSERT
(
*
ppNode
!=
NULL
);
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
*
ppNode
);
}
taosArrayDestroy
(
entryPArray
);
sTrace
(
"get index2: %ld, arraySize:%d -------------"
,
index
,
arraySize
);
syncEntryLog2
((
char
*
)
"getLogEntry2"
,
pEntry
);
return
pEntry
;
}
SSyncRaftEntry
*
getLogEntry
(
SSkipList
*
pSkipList
,
SyncIndex
index
)
{
sTrace
(
"get index: %ld -------------"
,
index
);
SyncIndex
index2
=
index
;
SSyncRaftEntry
*
pEntry
=
NULL
;
SSkipListIterator
*
pIter
=
tSkipListCreateIterFromVal
(
pSkipList
,
(
const
char
*
)
&
index2
,
TSDB_DATA_TYPE_BINARY
,
TSDB_ORDER_ASC
);
if
(
tSkipListIterNext
(
pIter
))
{
SSkipListNode
*
pNode
=
tSkipListIterGet
(
pIter
);
ASSERT
(
pNode
!=
NULL
);
pEntry
=
(
SSyncRaftEntry
*
)
SL_GET_NODE_DATA
(
pNode
);
}
syncEntryLog2
((
char
*
)
"getLogEntry"
,
pEntry
);
return
pEntry
;
}
void
test5
()
{
SSkipList
*
pSkipList
=
tSkipListCreate
(
MAX_SKIP_LIST_LEVEL
,
TSDB_DATA_TYPE_BINARY
,
sizeof
(
SyncIndex
),
cmpFn
,
SL_ALLOW_DUP_KEY
,
keyFn
);
ASSERT
(
pSkipList
!=
NULL
);
sTrace
(
"insert 9 - 5"
);
for
(
int
i
=
9
;
i
>=
5
;
--
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"insert 0 - 4"
);
for
(
int
i
=
0
;
i
<=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
i
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"insert 7 7 7 7 7"
);
for
(
int
i
=
0
;
i
<=
4
;
++
i
)
{
SSyncRaftEntry
*
pEntry
=
createEntry
(
7
);
SSkipListNode
*
pSkipListNode
=
tSkipListPut
(
pSkipList
,
pEntry
);
}
sTrace
(
"print: -------------"
);
printSkipList
(
pSkipList
);
delSkipListFirst
(
pSkipList
,
3
);
sTrace
(
"print: -------------"
);
printSkipList
(
pSkipList
);
getLogEntry
(
pSkipList
,
2
);
getLogEntry
(
pSkipList
,
5
);
getLogEntry
(
pSkipList
,
7
);
getLogEntry
(
pSkipList
,
7
);
getLogEntry2
(
pSkipList
,
2
);
getLogEntry2
(
pSkipList
,
5
);
getLogEntry2
(
pSkipList
,
7
);
getLogEntry2
(
pSkipList
,
7
);
tSkipListDestroy
(
pSkipList
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
gRaftDetailLog
=
true
;
gRaftDetailLog
=
true
;
tsAsyncLog
=
0
;
tsAsyncLog
=
0
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_DEBUG
;
sDebugFlag
=
DEBUG_TRACE
+
DEBUG_SCREEN
+
DEBUG_FILE
+
DEBUG_DEBUG
;
test1
();
/*
test2
();
test1();
test3
();
test2();
test4
();
test3();
test4();
*/
test5
();
return
0
;
return
0
;
}
}
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
24042fff
...
@@ -40,8 +40,9 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -40,8 +40,9 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
if
(
cbMeta
.
index
>
beginIndex
)
{
if
(
cbMeta
.
index
>
beginIndex
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
@@ -51,15 +52,16 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -51,15 +52,16 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
cbMeta
.
i
ndex
,
cbMeta
.
i
sWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
...
@@ -143,7 +145,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
...
@@ -143,7 +145,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
pMsg
->
msgType
=
9999
;
pMsg
->
msgType
=
9999
;
pMsg
->
contLen
=
256
;
pMsg
->
contLen
=
256
;
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
return
pMsg
;
return
pMsg
;
}
}
...
...
source/libs/sync/test/syncRespMgrTest.cpp
浏览文件 @
24042fff
...
@@ -35,8 +35,8 @@ void syncRespMgrDelTest(uint64_t begin, uint64_t end) {
...
@@ -35,8 +35,8 @@ void syncRespMgrDelTest(uint64_t begin, uint64_t end) {
}
}
void
printStub
(
SRespStub
*
p
)
{
void
printStub
(
SRespStub
*
p
)
{
printf
(
"createTime:%"
PRId64
", rpcMsg.code:%d rpcMsg.ahandle:%"
PRId64
" rpcMsg.handle:%"
PRId64
"
\n
"
,
p
->
createTime
,
p
->
rpcMsg
.
code
,
printf
(
"createTime:%"
PRId64
", rpcMsg.code:%d rpcMsg.ahandle:%"
PRId64
" rpcMsg.handle:%"
PRId64
"
\n
"
,
(
int64_t
)(
p
->
rpcMsg
.
info
.
ahandle
),
(
int64_t
)(
p
->
rpcMsg
.
info
.
handle
));
p
->
createTime
,
p
->
rpcMsg
.
code
,
(
int64_t
)(
p
->
rpcMsg
.
info
.
ahandle
),
(
int64_t
)(
p
->
rpcMsg
.
info
.
handle
));
}
}
void
syncRespMgrPrint
()
{
void
syncRespMgrPrint
()
{
printf
(
"
\n
----------------syncRespMgrPrint--------------
\n
"
);
printf
(
"
\n
----------------syncRespMgrPrint--------------
\n
"
);
...
...
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
24042fff
...
@@ -43,8 +43,9 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
...
@@ -43,8 +43,9 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
if
(
cbMeta
.
index
>
beginIndex
)
{
if
(
cbMeta
.
index
>
beginIndex
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
@@ -54,15 +55,16 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
...
@@ -54,15 +55,16 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
cbMeta
.
i
ndex
,
cbMeta
.
i
sWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
...
...
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
24042fff
...
@@ -40,7 +40,9 @@ void cleanup() { walCleanUp(); }
...
@@ -40,7 +40,9 @@ void cleanup() { walCleanUp(); }
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
...
@@ -50,7 +52,9 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
...
@@ -50,7 +52,9 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
...
@@ -60,7 +64,9 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
...
@@ -60,7 +64,9 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
...
@@ -128,7 +134,8 @@ int32_t SnapshotStopWrite(struct SSyncFSM* pFsm, void* pWriter, bool isApply) {
...
@@ -128,7 +134,8 @@ int32_t SnapshotStopWrite(struct SSyncFSM* pFsm, void* pWriter, bool isApply) {
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==SnapshotStopWrite== pFsm:%p, pWriter:%p, isApply:%d, gSnapshotLastApplyIndex:%"
PRId64
", "
"==callback== ==SnapshotStopWrite== pFsm:%p, pWriter:%p, isApply:%d, gSnapshotLastApplyIndex:%"
PRId64
", "
"gSnapshotLastApplyTerm:%"
PRId64
,
"gSnapshotLastApplyTerm:%"
PRId64
,
pFsm
,
pWriter
,
isApply
,
gSnapshotLastApplyIndex
,
gSnapshotLastApplyTerm
);
pFsm
,
pWriter
,
isApply
,
gSnapshotLastApplyIndex
,
gSnapshotLastApplyTerm
);
sTrace
(
"%s"
,
logBuf
);
sTrace
(
"%s"
,
logBuf
);
...
@@ -148,7 +155,8 @@ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFini
...
@@ -148,7 +155,8 @@ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFini
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
)
{
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
)
{
char
*
s
=
syncCfg2Str
(
&
(
cbMeta
.
newCfg
));
char
*
s
=
syncCfg2Str
(
&
(
cbMeta
.
newCfg
));
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
", newCfg:%s"
,
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
", newCfg:%s"
,
cbMeta
.
flag
,
cbMeta
.
index
,
cbMeta
.
code
,
cbMeta
.
currentTerm
,
cbMeta
.
term
,
s
);
cbMeta
.
flag
,
cbMeta
.
index
,
cbMeta
.
code
,
cbMeta
.
currentTerm
,
cbMeta
.
term
,
s
);
taosMemoryFree
(
s
);
taosMemoryFree
(
s
);
}
}
...
@@ -156,7 +164,9 @@ void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMe
...
@@ -156,7 +164,9 @@ void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta cbMe
void
LeaderTransferCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
LeaderTransferCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==LeaderTransferCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"==callback== ==LeaderTransferCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
...
@@ -300,7 +310,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
...
@@ -300,7 +310,8 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
pMsg
->
msgType
=
TDMT_VND_SUBMIT
;
pMsg
->
msgType
=
TDMT_VND_SUBMIT
;
pMsg
->
contLen
=
256
;
pMsg
->
contLen
=
256
;
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
pMsg
->
pCont
=
rpcMallocCont
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-myIndex:%u-%d-%d-"
PRId64
,
myIndex
,
i
,
count
,
taosGetTimestampMs
());
return
pMsg
;
return
pMsg
;
}
}
...
...
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
24042fff
...
@@ -33,23 +33,25 @@ const char *pDir = "./syncWriteTest";
...
@@ -33,23 +33,25 @@ const char *pDir = "./syncWriteTest";
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
cbMeta
.
i
ndex
,
cbMeta
.
i
sWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
];
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
snprintf
(
logBuf
,
sizeof
(
logBuf
),
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
}
...
...
source/libs/wal/src/walMeta.c
浏览文件 @
24042fff
...
@@ -141,34 +141,32 @@ int walCheckAndRepairMeta(SWal* pWal) {
...
@@ -141,34 +141,32 @@ int walCheckAndRepairMeta(SWal* pWal) {
regfree
(
&
idxRegPattern
);
regfree
(
&
idxRegPattern
);
taosArraySort
(
pLogInfoArray
,
compareWalFileInfo
);
taosArraySort
(
pLogInfoArray
,
compareWalFileInfo
);
int
oldSz
=
0
;
if
(
pWal
->
fileInfoSet
)
{
oldSz
=
taosArrayGetSize
(
pWal
->
fileInfoSet
);
}
int
newSz
=
taosArrayGetSize
(
pLogInfoArray
);
if
(
oldSz
>
newSz
)
{
int
metaFileNum
=
taosArrayGetSize
(
pWal
->
fileInfoSet
);
taosArrayPopFrontBatch
(
pWal
->
fileInfoSet
,
oldSz
-
newSz
);
int
actualFileNum
=
taosArrayGetSize
(
pLogInfoArray
);
}
else
if
(
oldSz
<
newSz
)
{
for
(
int
i
=
oldSz
;
i
<
newSz
;
i
++
)
{
if
(
metaFileNum
>
actualFileNum
)
{
taosArrayPopFrontBatch
(
pWal
->
fileInfoSet
,
metaFileNum
-
actualFileNum
);
}
else
if
(
metaFileNum
<
actualFileNum
)
{
for
(
int
i
=
metaFileNum
;
i
<
actualFileNum
;
i
++
)
{
SWalFileInfo
*
pFileInfo
=
taosArrayGet
(
pLogInfoArray
,
i
);
SWalFileInfo
*
pFileInfo
=
taosArrayGet
(
pLogInfoArray
,
i
);
taosArrayPush
(
pWal
->
fileInfoSet
,
pFileInfo
);
taosArrayPush
(
pWal
->
fileInfoSet
,
pFileInfo
);
}
}
}
}
taosArrayDestroy
(
pLogInfoArray
);
taosArrayDestroy
(
pLogInfoArray
);
pWal
->
writeCur
=
newSz
-
1
;
pWal
->
writeCur
=
actualFileNum
-
1
;
if
(
newSz
>
0
)
{
if
(
actualFileNum
>
0
)
{
pWal
->
vers
.
firstVer
=
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
0
))
->
firstVer
;
pWal
->
vers
.
firstVer
=
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
0
))
->
firstVer
;
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
newSz
-
1
);
SWalFileInfo
*
pLastFileInfo
=
taosArrayGet
(
pWal
->
fileInfoSet
,
actualFileNum
-
1
);
char
fnameStr
[
WAL_FILE_LEN
];
char
fnameStr
[
WAL_FILE_LEN
];
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
pLastFileInfo
->
firstVer
,
fnameStr
);
int64_t
file
_s
ize
=
0
;
int64_t
file
S
ize
=
0
;
taosStatFile
(
fnameStr
,
&
file
_s
ize
,
NULL
);
taosStatFile
(
fnameStr
,
&
file
S
ize
,
NULL
);
if
(
oldSz
!=
newSz
||
pLastFileInfo
->
fileSize
!=
file_s
ize
)
{
if
(
metaFileNum
!=
actualFileNum
||
pLastFileInfo
->
fileSize
!=
fileS
ize
)
{
pLastFileInfo
->
fileSize
=
file
_s
ize
;
pLastFileInfo
->
fileSize
=
file
S
ize
;
pWal
->
vers
.
lastVer
=
walScanLogGetLastVer
(
pWal
);
pWal
->
vers
.
lastVer
=
walScanLogGetLastVer
(
pWal
);
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
pWal
->
vers
.
lastVer
;
((
SWalFileInfo
*
)
taosArrayGetLast
(
pWal
->
fileInfoSet
))
->
lastVer
=
pWal
->
vers
.
lastVer
;
ASSERT
(
pWal
->
vers
.
lastVer
!=
-
1
);
ASSERT
(
pWal
->
vers
.
lastVer
!=
-
1
);
...
...
source/libs/wal/src/walWrite.c
浏览文件 @
24042fff
...
@@ -99,7 +99,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
...
@@ -99,7 +99,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
// delete files
// delete files
int
fileSetSize
=
taosArrayGetSize
(
pWal
->
fileInfoSet
);
int
fileSetSize
=
taosArrayGetSize
(
pWal
->
fileInfoSet
);
for
(
int
i
=
pWal
->
writeCur
;
i
<
fileSetSize
;
i
++
)
{
for
(
int
i
=
pWal
->
writeCur
+
1
;
i
<
fileSetSize
;
i
++
)
{
walBuildLogName
(
pWal
,
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
i
))
->
firstVer
,
fnameStr
);
walBuildLogName
(
pWal
,
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
i
))
->
firstVer
,
fnameStr
);
taosRemoveFile
(
fnameStr
);
taosRemoveFile
(
fnameStr
);
walBuildIdxName
(
pWal
,
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
i
))
->
firstVer
,
fnameStr
);
walBuildIdxName
(
pWal
,
((
SWalFileInfo
*
)
taosArrayGet
(
pWal
->
fileInfoSet
,
i
))
->
firstVer
,
fnameStr
);
...
@@ -113,18 +113,21 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
...
@@ -113,18 +113,21 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
TdFilePtr
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_APPEND
);
TdFilePtr
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_APPEND
);
if
(
pIdxTFile
==
NULL
)
{
if
(
pIdxTFile
==
NULL
)
{
ASSERT
(
0
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
return
-
1
;
}
}
int64_t
idxOff
=
walGetVerIdxOffset
(
pWal
,
ver
);
int64_t
idxOff
=
walGetVerIdxOffset
(
pWal
,
ver
);
code
=
taosLSeekFile
(
pIdxTFile
,
idxOff
,
SEEK_SET
);
code
=
taosLSeekFile
(
pIdxTFile
,
idxOff
,
SEEK_SET
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
ASSERT
(
0
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
return
-
1
;
}
}
// read idx file and get log file pos
// read idx file and get log file pos
SWalIdxEntry
entry
;
SWalIdxEntry
entry
;
if
(
taosReadFile
(
pIdxTFile
,
&
entry
,
sizeof
(
SWalIdxEntry
))
!=
sizeof
(
SWalIdxEntry
))
{
if
(
taosReadFile
(
pIdxTFile
,
&
entry
,
sizeof
(
SWalIdxEntry
))
!=
sizeof
(
SWalIdxEntry
))
{
ASSERT
(
0
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
return
-
1
;
}
}
...
@@ -133,12 +136,14 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
...
@@ -133,12 +136,14 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
walBuildLogName
(
pWal
,
walGetCurFileFirstVer
(
pWal
),
fnameStr
);
walBuildLogName
(
pWal
,
walGetCurFileFirstVer
(
pWal
),
fnameStr
);
TdFilePtr
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_APPEND
);
TdFilePtr
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_APPEND
);
if
(
pLogTFile
==
NULL
)
{
if
(
pLogTFile
==
NULL
)
{
ASSERT
(
0
);
// TODO
// TODO
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
return
-
1
;
}
}
code
=
taosLSeekFile
(
pLogTFile
,
entry
.
offset
,
SEEK_SET
);
code
=
taosLSeekFile
(
pLogTFile
,
entry
.
offset
,
SEEK_SET
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
ASSERT
(
0
);
// TODO
// TODO
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
return
-
1
;
...
@@ -148,6 +153,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
...
@@ -148,6 +153,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) {
ASSERT
(
taosValidFile
(
pLogTFile
));
ASSERT
(
taosValidFile
(
pLogTFile
));
int64_t
size
=
taosReadFile
(
pLogTFile
,
&
head
,
sizeof
(
SWalCkHead
));
int64_t
size
=
taosReadFile
(
pLogTFile
,
&
head
,
sizeof
(
SWalCkHead
));
if
(
size
!=
sizeof
(
SWalCkHead
))
{
if
(
size
!=
sizeof
(
SWalCkHead
))
{
ASSERT
(
0
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
-
1
;
return
-
1
;
}
}
...
@@ -205,15 +211,22 @@ int32_t walBeginSnapshot(SWal *pWal, int64_t ver) {
...
@@ -205,15 +211,22 @@ int32_t walBeginSnapshot(SWal *pWal, int64_t ver) {
pWal
->
vers
.
verInSnapshotting
=
ver
;
pWal
->
vers
.
verInSnapshotting
=
ver
;
// check file rolling
// check file rolling
if
(
pWal
->
cfg
.
retentionPeriod
==
0
)
{
if
(
pWal
->
cfg
.
retentionPeriod
==
0
)
{
taosThreadMutexLock
(
&
pWal
->
mutex
);
walRoll
(
pWal
);
walRoll
(
pWal
);
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
}
}
return
0
;
return
0
;
}
}
int32_t
walEndSnapshot
(
SWal
*
pWal
)
{
int32_t
walEndSnapshot
(
SWal
*
pWal
)
{
int32_t
code
=
0
;
taosThreadMutexLock
(
&
pWal
->
mutex
);
int64_t
ver
=
pWal
->
vers
.
verInSnapshotting
;
int64_t
ver
=
pWal
->
vers
.
verInSnapshotting
;
if
(
ver
==
-
1
)
return
0
;
if
(
ver
==
-
1
)
{
code
=
-
1
;
goto
END
;
};
pWal
->
vers
.
snapshotVer
=
ver
;
pWal
->
vers
.
snapshotVer
=
ver
;
int
ts
=
taosGetTimestampSec
();
int
ts
=
taosGetTimestampSec
();
...
@@ -229,7 +242,7 @@ int32_t walEndSnapshot(SWal *pWal) {
...
@@ -229,7 +242,7 @@ int32_t walEndSnapshot(SWal *pWal) {
}
}
// iterate files, until the searched result
// iterate files, until the searched result
for
(
SWalFileInfo
*
iter
=
pWal
->
fileInfoSet
->
pData
;
iter
<
pInfo
;
iter
++
)
{
for
(
SWalFileInfo
*
iter
=
pWal
->
fileInfoSet
->
pData
;
iter
<
pInfo
;
iter
++
)
{
if
((
pWal
->
cfg
.
retentionSize
!=
-
1
&&
pWal
->
t
otSize
>
pWal
->
cfg
.
retentionSize
)
||
if
((
pWal
->
cfg
.
retentionSize
!=
-
1
&&
newT
otSize
>
pWal
->
cfg
.
retentionSize
)
||
(
pWal
->
cfg
.
retentionPeriod
!=
-
1
&&
iter
->
closeTs
+
pWal
->
cfg
.
retentionPeriod
>
ts
))
{
(
pWal
->
cfg
.
retentionPeriod
!=
-
1
&&
iter
->
closeTs
+
pWal
->
cfg
.
retentionPeriod
>
ts
))
{
// delete according to file size or close time
// delete according to file size or close time
deleteCnt
++
;
deleteCnt
++
;
...
@@ -259,12 +272,14 @@ int32_t walEndSnapshot(SWal *pWal) {
...
@@ -259,12 +272,14 @@ int32_t walEndSnapshot(SWal *pWal) {
pWal
->
vers
.
verInSnapshotting
=
-
1
;
pWal
->
vers
.
verInSnapshotting
=
-
1
;
// save snapshot ver, commit ver
// save snapshot ver, commit ver
int
code
=
walSaveMeta
(
pWal
);
code
=
walSaveMeta
(
pWal
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
return
-
1
;
goto
END
;
}
}
return
0
;
END:
taosThreadMutexUnlock
(
&
pWal
->
mutex
);
return
code
;
}
}
int
walRoll
(
SWal
*
pWal
)
{
int
walRoll
(
SWal
*
pWal
)
{
...
@@ -273,14 +288,14 @@ int walRoll(SWal *pWal) {
...
@@ -273,14 +288,14 @@ int walRoll(SWal *pWal) {
code
=
taosCloseFile
(
&
pWal
->
pWriteIdxTFile
);
code
=
taosCloseFile
(
&
pWal
->
pWriteIdxTFile
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
goto
END
;
}
}
}
}
if
(
pWal
->
pWriteLogTFile
!=
NULL
)
{
if
(
pWal
->
pWriteLogTFile
!=
NULL
)
{
code
=
taosCloseFile
(
&
pWal
->
pWriteLogTFile
);
code
=
taosCloseFile
(
&
pWal
->
pWriteLogTFile
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
goto
END
;
}
}
}
}
TdFilePtr
pIdxTFile
,
pLogTFile
;
TdFilePtr
pIdxTFile
,
pLogTFile
;
...
@@ -291,18 +306,20 @@ int walRoll(SWal *pWal) {
...
@@ -291,18 +306,20 @@ int walRoll(SWal *pWal) {
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
pIdxTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pIdxTFile
==
NULL
)
{
if
(
pIdxTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
code
=
-
1
;
goto
END
;
}
}
walBuildLogName
(
pWal
,
newFileFirstVersion
,
fnameStr
);
walBuildLogName
(
pWal
,
newFileFirstVersion
,
fnameStr
);
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
pLogTFile
=
taosOpenFile
(
fnameStr
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_APPEND
);
if
(
pLogTFile
==
NULL
)
{
if
(
pLogTFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
code
=
-
1
;
goto
END
;
}
}
//
terrno
set inner
//
error code was
set inner
code
=
walRollFileInfo
(
pWal
);
code
=
walRollFileInfo
(
pWal
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
-
1
;
goto
END
;
}
}
// switch file
// switch file
...
@@ -312,7 +329,9 @@ int walRoll(SWal *pWal) {
...
@@ -312,7 +329,9 @@ int walRoll(SWal *pWal) {
ASSERT
(
pWal
->
writeCur
>=
0
);
ASSERT
(
pWal
->
writeCur
>=
0
);
pWal
->
lastRollSeq
=
walGetSeq
();
pWal
->
lastRollSeq
=
walGetSeq
();
return
0
;
END:
return
code
;
}
}
static
int
walWriteIndex
(
SWal
*
pWal
,
int64_t
ver
,
int64_t
offset
)
{
static
int
walWriteIndex
(
SWal
*
pWal
,
int64_t
ver
,
int64_t
offset
)
{
...
...
source/util/src/tlockfree.c
浏览文件 @
24042fff
...
@@ -17,8 +17,10 @@
...
@@ -17,8 +17,10 @@
#include "tlockfree.h"
#include "tlockfree.h"
#define TD_RWLATCH_WRITE_FLAG 0x40000000
#define TD_RWLATCH_WRITE_FLAG 0x40000000
#define TD_RWLATCH_REENTRANT_FLAG 0x4000000000000000
void
taosInitRWLatch
(
SRWLatch
*
pLatch
)
{
*
pLatch
=
0
;
}
void
taosInitRWLatch
(
SRWLatch
*
pLatch
)
{
*
pLatch
=
0
;
}
void
taosInitReentrantRWLatch
(
SRWLatch
*
pLatch
)
{
*
pLatch
=
TD_RWLATCH_REENTRANT_FLAG
;
}
void
taosWLockLatch
(
SRWLatch
*
pLatch
)
{
void
taosWLockLatch
(
SRWLatch
*
pLatch
)
{
SRWLatch
oLatch
,
nLatch
;
SRWLatch
oLatch
,
nLatch
;
...
@@ -26,8 +28,14 @@ void taosWLockLatch(SRWLatch *pLatch) {
...
@@ -26,8 +28,14 @@ void taosWLockLatch(SRWLatch *pLatch) {
// Set write flag
// Set write flag
while
(
1
)
{
while
(
1
)
{
oLatch
=
atomic_load_
32
(
pLatch
);
oLatch
=
atomic_load_
64
(
pLatch
);
if
(
oLatch
&
TD_RWLATCH_WRITE_FLAG
)
{
if
(
oLatch
&
TD_RWLATCH_WRITE_FLAG
)
{
if
(
oLatch
&
TD_RWLATCH_REENTRANT_FLAG
)
{
nLatch
=
(((
oLatch
>>
32
)
+
1
)
<<
32
)
|
(
oLatch
&
0xFFFFFFFF
);
if
(
atomic_val_compare_exchange_64
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
continue
;
}
nLoops
++
;
nLoops
++
;
if
(
nLoops
>
1000
)
{
if
(
nLoops
>
1000
)
{
sched_yield
();
sched_yield
();
...
@@ -37,14 +45,14 @@ void taosWLockLatch(SRWLatch *pLatch) {
...
@@ -37,14 +45,14 @@ void taosWLockLatch(SRWLatch *pLatch) {
}
}
nLatch
=
oLatch
|
TD_RWLATCH_WRITE_FLAG
;
nLatch
=
oLatch
|
TD_RWLATCH_WRITE_FLAG
;
if
(
atomic_val_compare_exchange_
32
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
if
(
atomic_val_compare_exchange_
64
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
}
}
// wait for all reads end
// wait for all reads end
nLoops
=
0
;
nLoops
=
0
;
while
(
1
)
{
while
(
1
)
{
oLatch
=
atomic_load_
32
(
pLatch
);
oLatch
=
atomic_load_
64
(
pLatch
);
if
(
oLatch
==
TD_RWLATCH_WRITE_FLAG
)
break
;
if
(
0
==
(
oLatch
&
0xFFFFFFF
)
)
break
;
nLoops
++
;
nLoops
++
;
if
(
nLoops
>
1000
)
{
if
(
nLoops
>
1000
)
{
sched_yield
();
sched_yield
();
...
@@ -53,29 +61,50 @@ void taosWLockLatch(SRWLatch *pLatch) {
...
@@ -53,29 +61,50 @@ void taosWLockLatch(SRWLatch *pLatch) {
}
}
}
}
// no reentrant
int32_t
taosWTryLockLatch
(
SRWLatch
*
pLatch
)
{
int32_t
taosWTryLockLatch
(
SRWLatch
*
pLatch
)
{
SRWLatch
oLatch
,
nLatch
;
SRWLatch
oLatch
,
nLatch
;
oLatch
=
atomic_load_
32
(
pLatch
);
oLatch
=
atomic_load_
64
(
pLatch
);
if
(
oLatch
)
{
if
(
oLatch
<<
2
)
{
return
-
1
;
return
-
1
;
}
}
nLatch
=
oLatch
|
TD_RWLATCH_WRITE_FLAG
;
nLatch
=
oLatch
|
TD_RWLATCH_WRITE_FLAG
;
if
(
atomic_val_compare_exchange_
32
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
{
if
(
atomic_val_compare_exchange_
64
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
{
return
0
;
return
0
;
}
}
return
-
1
;
return
-
1
;
}
}
void
taosWUnLockLatch
(
SRWLatch
*
pLatch
)
{
atomic_store_32
(
pLatch
,
0
);
}
void
taosWUnLockLatch
(
SRWLatch
*
pLatch
)
{
SRWLatch
oLatch
,
nLatch
,
wLatch
;
while
(
1
)
{
oLatch
=
atomic_load_64
(
pLatch
);
if
(
0
==
(
oLatch
&
TD_RWLATCH_REENTRANT_FLAG
))
{
atomic_store_64
(
pLatch
,
0
);
break
;
}
wLatch
=
((
oLatch
<<
2
)
>>
34
);
if
(
wLatch
)
{
nLatch
=
((
--
wLatch
)
<<
32
)
|
TD_RWLATCH_REENTRANT_FLAG
|
TD_RWLATCH_WRITE_FLAG
;
}
else
{
nLatch
=
TD_RWLATCH_REENTRANT_FLAG
;
}
if
(
atomic_val_compare_exchange_64
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
}
}
void
taosRLockLatch
(
SRWLatch
*
pLatch
)
{
void
taosRLockLatch
(
SRWLatch
*
pLatch
)
{
SRWLatch
oLatch
,
nLatch
;
SRWLatch
oLatch
,
nLatch
;
int32_t
nLoops
=
0
;
int32_t
nLoops
=
0
;
while
(
1
)
{
while
(
1
)
{
oLatch
=
atomic_load_
32
(
pLatch
);
oLatch
=
atomic_load_
64
(
pLatch
);
if
(
oLatch
&
TD_RWLATCH_WRITE_FLAG
)
{
if
(
oLatch
&
TD_RWLATCH_WRITE_FLAG
)
{
nLoops
++
;
nLoops
++
;
if
(
nLoops
>
1000
)
{
if
(
nLoops
>
1000
)
{
...
@@ -86,8 +115,8 @@ void taosRLockLatch(SRWLatch *pLatch) {
...
@@ -86,8 +115,8 @@ void taosRLockLatch(SRWLatch *pLatch) {
}
}
nLatch
=
oLatch
+
1
;
nLatch
=
oLatch
+
1
;
if
(
atomic_val_compare_exchange_
32
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
if
(
atomic_val_compare_exchange_
64
(
pLatch
,
oLatch
,
nLatch
)
==
oLatch
)
break
;
}
}
}
}
void
taosRUnLockLatch
(
SRWLatch
*
pLatch
)
{
atomic_fetch_sub_32
(
pLatch
,
1
);
}
void
taosRUnLockLatch
(
SRWLatch
*
pLatch
)
{
atomic_fetch_sub_64
(
pLatch
,
1
);
}
\ No newline at end of file
tests/script/jenkins/basic.txt
浏览文件 @
24042fff
...
@@ -164,8 +164,8 @@
...
@@ -164,8 +164,8 @@
# --- sma
# --- sma
./test.sh -f tsim/sma/drop_sma.sim
./test.sh -f tsim/sma/drop_sma.sim
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim
#
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim
#
./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim
# --- valgrind
# --- valgrind
./test.sh -f tsim/valgrind/checkError1.sim
./test.sh -f tsim/valgrind/checkError1.sim
...
...
tests/script/tsim/sync/vnodesnapshot-test.sim
0 → 100644
浏览文件 @
24042fff
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c supportVnodes -v 0
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
print ===> $rows $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
print ===> $rows $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6]
print ===> $rows $data[3][0] $data[3][1] $data[3][2] $data[3][3] $data[3][4] $data[3][5] $data[3][6]
if $data[0][0] != 1 then
return -1
endi
if $data[0][4] != ready then
goto check_dnode_ready
endi
sql connect
sql create dnode $hostname port 7200
sql create dnode $hostname port 7300
sql create dnode $hostname port 7400
$loop_cnt = 0
check_dnode_ready_1:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnodes not ready!
return -1
endi
sql show dnodes
print ===> $rows $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6]
print ===> $rows $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] $data[1][5] $data[1][6]
print ===> $rows $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6]
print ===> $rows $data[3][0] $data[3][1] $data[3][2] $data[3][3] $data[3][4] $data[3][5] $data[3][6]
if $data[0][4] != ready then
goto check_dnode_ready_1
endi
if $data[1][4] != ready then
goto check_dnode_ready_1
endi
if $data[2][4] != ready then
goto check_dnode_ready_1
endi
if $data[3][4] != ready then
goto check_dnode_ready_1
endi
$replica = 3
$vgroups = 1
print ============= create database
sql create database db replica $replica vgroups $vgroups
$loop_cnt = 0
check_db_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 100 then
print ====> db not ready!
return -1
endi
sql show databases
print ===> rows: $rows
print $data[2][0] $data[2][1] $data[2][2] $data[2][3] $data[2][4] $data[2][5] $data[2][6] $data[2][7] $data[2][8] $data[2][9] $data[2][6] $data[2][11] $data[2][12] $data[2][13] $data[2][14] $data[2][15] $data[2][16] $data[2][17] $data[2][18] $data[2][19]
if $rows != 3 then
return -1
endi
if $data[2][19] != ready then
goto check_db_ready
endi
sql use db
$loop_cnt = 0
check_vg_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 300 then
print ====> vgroups not ready!
return -1
endi
sql show vgroups
print ===> rows: $rows
print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] $data[0][5] $data[0][6] $data[0][7] $data[0][8] $data[0][9] $data[0][10] $data[0][11]
if $rows != $vgroups then
return -1
endi
if $data[0][4] == leader then
if $data[0][6] == follower then
if $data[0][8] == follower then
print ---- vgroup $data[0][0] leader locate on dnode $data[0][3]
endi
endi
elif $data[0][6] == leader then
if $data[0][4] == follower then
if $data[0][8] == follower then
print ---- vgroup $data[0][0] leader locate on dnode $data[0][5]
endi
endi
elif $data[0][8] == leader then
if $data[0][4] == follower then
if $data[0][6] == follower then
print ---- vgroup $data[0][0] leader locate on dnode $data[0][7]
endi
endi
else
goto check_vg_ready
endi
vg_ready:
print ====> create stable/child table
sql create table stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int)
sql show stables
if $rows != 1 then
return -1
endi
sql create table ct1 using stb tags(1000)
print ===> stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep 3000
print ===> write 100 records
$N = 100
$count = 0
while $count < $N
$ms = 1591200000000 + $count
sql insert into ct1 values( $ms , $count , 2.1, 3.1)
$count = $count + 1
endw
#sql flush database db;
sleep 3000
print ===> stop dnode1 dnode2 dnode3
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
print ===> start dnode1 dnode2 dnode3 dnode4
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
tests/system-test/2-query/function_diff.py
浏览文件 @
24042fff
...
@@ -360,15 +360,15 @@ class TDTestCase:
...
@@ -360,15 +360,15 @@ class TDTestCase:
tdSql
.
checkRows
(
229
)
tdSql
.
checkRows
(
229
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
checkData
(
0
,
0
,
0
)
tdSql
.
query
(
"select diff(c1) from stb1 partition by tbname "
)
tdSql
.
query
(
"select diff(c1) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
19
9
)
tdSql
.
checkRows
(
19
0
)
# tdSql.query("select diff(st1) from stb1 partition by tbname")
# tdSql.query("select diff(st1) from stb1 partition by tbname")
# tdSql.checkRows(229)
# tdSql.checkRows(229)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
19
9
)
tdSql
.
checkRows
(
19
0
)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
19
9
)
tdSql
.
checkRows
(
19
0
)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
19
9
)
tdSql
.
checkRows
(
19
0
)
# # bug need fix
# # bug need fix
# tdSql.query("select diff(st1+c1) from stb1 partition by tbname slimit 1 ")
# tdSql.query("select diff(st1+c1) from stb1 partition by tbname slimit 1 ")
...
@@ -378,7 +378,7 @@ class TDTestCase:
...
@@ -378,7 +378,7 @@ class TDTestCase:
# bug need fix
# bug need fix
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
query
(
"select diff(st1+c1) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
19
9
)
tdSql
.
checkRows
(
19
0
)
# bug need fix
# bug need fix
# tdSql.query("select tbname , diff(c1) from stb1 partition by tbname")
# tdSql.query("select tbname , diff(c1) from stb1 partition by tbname")
...
...
tests/system-test/2-query/mavg.py
浏览文件 @
24042fff
...
@@ -678,15 +678,15 @@ class TDTestCase:
...
@@ -678,15 +678,15 @@ class TDTestCase:
tdSql
.
checkRows
(
68
)
tdSql
.
checkRows
(
68
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
checkData
(
0
,
0
,
1.000000000
)
tdSql
.
query
(
"select mavg(c1,3) from stb1 partition by tbname "
)
tdSql
.
query
(
"select mavg(c1,3) from stb1 partition by tbname "
)
tdSql
.
checkRows
(
38
)
tdSql
.
checkRows
(
20
)
# tdSql.query("select mavg(st1,3) from stb1 partition by tbname")
# tdSql.query("select mavg(st1,3) from stb1 partition by tbname")
# tdSql.checkRows(38)
# tdSql.checkRows(38)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
38
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
38
)
tdSql
.
checkRows
(
20
)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
38
)
tdSql
.
checkRows
(
20
)
# # bug need fix
# # bug need fix
# tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname slimit 1 ")
# tdSql.query("select mavg(st1+c1,3) from stb1 partition by tbname slimit 1 ")
...
@@ -696,7 +696,7 @@ class TDTestCase:
...
@@ -696,7 +696,7 @@ class TDTestCase:
# bug need fix
# bug need fix
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
query
(
"select mavg(st1+c1,3) from stb1 partition by tbname"
)
tdSql
.
checkRows
(
38
)
tdSql
.
checkRows
(
20
)
# bug need fix
# bug need fix
# tdSql.query("select tbname , mavg(c1,3) from stb1 partition by tbname")
# tdSql.query("select tbname , mavg(c1,3) from stb1 partition by tbname")
...
...
tests/system-test/2-query/queryQnode.py
浏览文件 @
24042fff
...
@@ -32,9 +32,9 @@ class TDTestCase:
...
@@ -32,9 +32,9 @@ class TDTestCase:
#
#
# --------------- main frame -------------------
# --------------- main frame -------------------
#
#
clientCfgDict
=
{
'queryPolicy'
:
'1'
,
'debugFlag'
:
1
35
}
clientCfgDict
=
{
'queryPolicy'
:
'1'
,
'debugFlag'
:
1
43
}
clientCfgDict
[
"queryPolicy"
]
=
'1'
clientCfgDict
[
"queryPolicy"
]
=
'1'
clientCfgDict
[
"debugFlag"
]
=
1
31
clientCfgDict
[
"debugFlag"
]
=
1
43
updatecfgDict
=
{
'clientCfg'
:
{}}
updatecfgDict
=
{
'clientCfg'
:
{}}
updatecfgDict
=
{
'debugFlag'
:
143
}
updatecfgDict
=
{
'debugFlag'
:
143
}
...
@@ -480,4 +480,4 @@ class TDTestCase:
...
@@ -480,4 +480,4 @@ class TDTestCase:
# add case with filename
# add case with filename
#
#
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录