Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
82132cdf
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
82132cdf
编写于
10月 18, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
meta: new metaFinishCommit api & rollback parameter with metaOpen
上级
0ca2d9e9
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
106 addition
and
51 deletion
+106
-51
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/meta/metaCommit.c
source/dnode/vnode/src/meta/metaCommit.c
+1
-0
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+11
-11
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+2
-0
source/dnode/vnode/src/tq/tqMeta.c
source/dnode/vnode/src/tq/tqMeta.c
+3
-3
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+5
-0
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+3
-3
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+4
-4
source/libs/tdb/inc/tdb.h
source/libs/tdb/inc/tdb.h
+4
-2
source/libs/tdb/src/db/tdbDb.c
source/libs/tdb/src/db/tdbDb.c
+17
-2
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+22
-0
source/libs/tdb/src/db/tdbTable.c
source/libs/tdb/src/db/tdbTable.c
+10
-5
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+2
-0
source/libs/tdb/test/tdbExOVFLTest.cpp
source/libs/tdb/test/tdbExOVFLTest.cpp
+8
-8
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+13
-13
未找到文件。
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
82132cdf
...
...
@@ -101,6 +101,7 @@ int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback);
int
metaClose
(
SMeta
*
pMeta
);
int
metaBegin
(
SMeta
*
pMeta
,
int8_t
fromSys
);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaFinishCommit
(
SMeta
*
pMeta
);
int
metaCreateSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaAlterSTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
,
SArray
*
tbUidList
);
...
...
source/dnode/vnode/src/meta/metaCommit.c
浏览文件 @
82132cdf
...
...
@@ -34,6 +34,7 @@ int metaBegin(SMeta *pMeta, int8_t fromSys) {
// commit the meta txn
int
metaCommit
(
SMeta
*
pMeta
)
{
return
tdbCommit
(
pMeta
->
pEnv
,
&
pMeta
->
txn
);
}
int
metaFinishCommit
(
SMeta
*
pMeta
)
{
return
tdbPostCommit
(
pMeta
->
pEnv
,
&
pMeta
->
txn
);
}
// abort the meta txn
int
metaAbort
(
SMeta
*
pMeta
)
{
return
tdbAbort
(
pMeta
->
pEnv
,
&
pMeta
->
txn
);
}
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
82132cdf
...
...
@@ -60,49 +60,49 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
taosMkDir
(
pMeta
->
path
);
// open env
ret
=
tdbOpen
(
pMeta
->
path
,
pVnode
->
config
.
szPage
,
pVnode
->
config
.
szCache
,
&
pMeta
->
pEnv
);
ret
=
tdbOpen
(
pMeta
->
path
,
pVnode
->
config
.
szPage
,
pVnode
->
config
.
szCache
,
&
pMeta
->
pEnv
,
rollback
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta env since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pTbDb
ret
=
tdbTbOpen
(
"table.db"
,
sizeof
(
STbDbKey
),
-
1
,
tbDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTbDb
);
ret
=
tdbTbOpen
(
"table.db"
,
sizeof
(
STbDbKey
),
-
1
,
tbDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTbDb
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta table db since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pSkmDb
ret
=
tdbTbOpen
(
"schema.db"
,
sizeof
(
SSkmDbKey
),
-
1
,
skmDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSkmDb
);
ret
=
tdbTbOpen
(
"schema.db"
,
sizeof
(
SSkmDbKey
),
-
1
,
skmDbKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSkmDb
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta schema db since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pUidIdx
ret
=
tdbTbOpen
(
"uid.idx"
,
sizeof
(
tb_uid_t
),
sizeof
(
SUidIdxVal
),
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pUidIdx
);
ret
=
tdbTbOpen
(
"uid.idx"
,
sizeof
(
tb_uid_t
),
sizeof
(
SUidIdxVal
),
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pUidIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta uid idx since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pNameIdx
ret
=
tdbTbOpen
(
"name.idx"
,
-
1
,
sizeof
(
tb_uid_t
),
NULL
,
pMeta
->
pEnv
,
&
pMeta
->
pNameIdx
);
ret
=
tdbTbOpen
(
"name.idx"
,
-
1
,
sizeof
(
tb_uid_t
),
NULL
,
pMeta
->
pEnv
,
&
pMeta
->
pNameIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta name index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pCtbIdx
ret
=
tdbTbOpen
(
"ctb.idx"
,
sizeof
(
SCtbIdxKey
),
-
1
,
ctbIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pCtbIdx
);
ret
=
tdbTbOpen
(
"ctb.idx"
,
sizeof
(
SCtbIdxKey
),
-
1
,
ctbIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pCtbIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta child table index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pSuidIdx
ret
=
tdbTbOpen
(
"suid.idx"
,
sizeof
(
tb_uid_t
),
0
,
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSuidIdx
);
ret
=
tdbTbOpen
(
"suid.idx"
,
sizeof
(
tb_uid_t
),
0
,
uidIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSuidIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta super table index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
...
...
@@ -119,27 +119,27 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
goto
_err
;
}
ret
=
tdbTbOpen
(
"tag.idx"
,
-
1
,
0
,
tagIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTagIdx
);
ret
=
tdbTbOpen
(
"tag.idx"
,
-
1
,
0
,
tagIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTagIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta tag index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pTtlIdx
ret
=
tdbTbOpen
(
"ttl.idx"
,
sizeof
(
STtlIdxKey
),
0
,
ttlIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTtlIdx
);
ret
=
tdbTbOpen
(
"ttl.idx"
,
sizeof
(
STtlIdxKey
),
0
,
ttlIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pTtlIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta ttl index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
// open pSmaIdx
ret
=
tdbTbOpen
(
"sma.idx"
,
sizeof
(
SSmaIdxKey
),
0
,
smaIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSmaIdx
);
ret
=
tdbTbOpen
(
"sma.idx"
,
sizeof
(
SSmaIdxKey
),
0
,
smaIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pSmaIdx
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta sma index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
}
ret
=
tdbTbOpen
(
"stream.task.db"
,
sizeof
(
int64_t
),
-
1
,
taskIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pStreamDb
);
ret
=
tdbTbOpen
(
"stream.task.db"
,
sizeof
(
int64_t
),
-
1
,
taskIdxKeyCmpr
,
pMeta
->
pEnv
,
&
pMeta
->
pStreamDb
,
0
);
if
(
ret
<
0
)
{
metaError
(
"vgId:%d, failed to open meta stream task index since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
82132cdf
...
...
@@ -165,6 +165,8 @@ int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) {
}
else
{
code
=
metaCommit
(
pWriter
->
pMeta
);
if
(
code
)
goto
_err
;
code
=
metaFinishCommit
(
pWriter
->
pMeta
);
if
(
code
)
goto
_err
;
}
taosMemoryFree
(
pWriter
);
*
ppWriter
=
NULL
;
...
...
source/dnode/vnode/src/tq/tqMeta.c
浏览文件 @
82132cdf
...
...
@@ -70,17 +70,17 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle) {
}
int32_t
tqMetaOpen
(
STQ
*
pTq
)
{
if
(
tdbOpen
(
pTq
->
path
,
16
*
1024
,
1
,
&
pTq
->
pMetaDB
)
<
0
)
{
if
(
tdbOpen
(
pTq
->
path
,
16
*
1024
,
1
,
&
pTq
->
pMetaDB
,
0
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
if
(
tdbTbOpen
(
"tq.db"
,
-
1
,
-
1
,
NULL
,
pTq
->
pMetaDB
,
&
pTq
->
pExecStore
)
<
0
)
{
if
(
tdbTbOpen
(
"tq.db"
,
-
1
,
-
1
,
NULL
,
pTq
->
pMetaDB
,
&
pTq
->
pExecStore
,
0
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
if
(
tdbTbOpen
(
"tq.check.db"
,
-
1
,
-
1
,
NULL
,
pTq
->
pMetaDB
,
&
pTq
->
pCheckStore
)
<
0
)
{
if
(
tdbTbOpen
(
"tq.check.db"
,
-
1
,
-
1
,
NULL
,
pTq
->
pMetaDB
,
&
pTq
->
pCheckStore
,
0
)
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
82132cdf
...
...
@@ -289,6 +289,11 @@ int vnodeCommit(SVnode *pVnode) {
tsdbFinishCommit
(
pVnode
->
pTsdb
);
if
(
metaFinishCommit
(
pVnode
->
pMeta
)
<
0
)
{
code
=
terrno
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pVnode
->
state
.
committed
=
info
.
state
.
committed
;
// postCommit
...
...
source/libs/stream/src/streamMeta.c
浏览文件 @
82132cdf
...
...
@@ -27,7 +27,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
char
*
streamPath
=
taosMemoryCalloc
(
1
,
len
);
sprintf
(
streamPath
,
"%s/%s"
,
path
,
"stream"
);
pMeta
->
path
=
strdup
(
streamPath
);
if
(
tdbOpen
(
pMeta
->
path
,
16
*
1024
,
1
,
&
pMeta
->
db
)
<
0
)
{
if
(
tdbOpen
(
pMeta
->
path
,
16
*
1024
,
1
,
&
pMeta
->
db
,
0
)
<
0
)
{
taosMemoryFree
(
streamPath
);
goto
_err
;
}
...
...
@@ -36,11 +36,11 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
taosMulModeMkDir
(
streamPath
,
0755
);
taosMemoryFree
(
streamPath
);
if
(
tdbTbOpen
(
"task.db"
,
sizeof
(
int32_t
),
-
1
,
NULL
,
pMeta
->
db
,
&
pMeta
->
pTaskDb
)
<
0
)
{
if
(
tdbTbOpen
(
"task.db"
,
sizeof
(
int32_t
),
-
1
,
NULL
,
pMeta
->
db
,
&
pMeta
->
pTaskDb
,
0
)
<
0
)
{
goto
_err
;
}
if
(
tdbTbOpen
(
"checkpoint.db"
,
sizeof
(
int32_t
),
-
1
,
NULL
,
pMeta
->
db
,
&
pMeta
->
pCheckpointDb
)
<
0
)
{
if
(
tdbTbOpen
(
"checkpoint.db"
,
sizeof
(
int32_t
),
-
1
,
NULL
,
pMeta
->
db
,
&
pMeta
->
pCheckpointDb
,
0
)
<
0
)
{
goto
_err
;
}
...
...
source/libs/stream/src/streamState.c
浏览文件 @
82132cdf
...
...
@@ -65,21 +65,21 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int
memset
(
statePath
,
0
,
300
);
tstrncpy
(
statePath
,
path
,
300
);
}
if
(
tdbOpen
(
statePath
,
szPage
,
pages
,
&
pState
->
db
)
<
0
)
{
if
(
tdbOpen
(
statePath
,
szPage
,
pages
,
&
pState
->
db
,
0
)
<
0
)
{
goto
_err
;
}
// open state storage backend
if
(
tdbTbOpen
(
"state.db"
,
sizeof
(
SStateKey
),
-
1
,
stateKeyCmpr
,
pState
->
db
,
&
pState
->
pStateDb
)
<
0
)
{
if
(
tdbTbOpen
(
"state.db"
,
sizeof
(
SStateKey
),
-
1
,
stateKeyCmpr
,
pState
->
db
,
&
pState
->
pStateDb
,
0
)
<
0
)
{
goto
_err
;
}
// todo refactor
if
(
tdbTbOpen
(
"fill.state.db"
,
sizeof
(
SWinKey
),
-
1
,
winKeyCmpr
,
pState
->
db
,
&
pState
->
pFillStateDb
)
<
0
)
{
if
(
tdbTbOpen
(
"fill.state.db"
,
sizeof
(
SWinKey
),
-
1
,
winKeyCmpr
,
pState
->
db
,
&
pState
->
pFillStateDb
,
0
)
<
0
)
{
goto
_err
;
}
if
(
tdbTbOpen
(
"func.state.db"
,
sizeof
(
STupleKey
),
-
1
,
STupleKeyCmpr
,
pState
->
db
,
&
pState
->
pFuncStateDb
)
<
0
)
{
if
(
tdbTbOpen
(
"func.state.db"
,
sizeof
(
STupleKey
),
-
1
,
STupleKeyCmpr
,
pState
->
db
,
&
pState
->
pFuncStateDb
,
0
)
<
0
)
{
goto
_err
;
}
...
...
source/libs/tdb/inc/tdb.h
浏览文件 @
82132cdf
...
...
@@ -31,15 +31,17 @@ typedef struct STBC TBC;
typedef
struct
STxn
TXN
;
// TDB
int32_t
tdbOpen
(
const
char
*
dbname
,
int
szPage
,
int
pages
,
TDB
**
ppDb
);
int32_t
tdbOpen
(
const
char
*
dbname
,
int
szPage
,
int
pages
,
TDB
**
ppDb
,
int8_t
rollback
);
int32_t
tdbClose
(
TDB
*
pDb
);
int32_t
tdbBegin
(
TDB
*
pDb
,
TXN
*
pTxn
);
int32_t
tdbCommit
(
TDB
*
pDb
,
TXN
*
pTxn
);
int32_t
tdbPostCommit
(
TDB
*
pDb
,
TXN
*
pTxn
);
int32_t
tdbAbort
(
TDB
*
pDb
,
TXN
*
pTxn
);
int32_t
tdbAlter
(
TDB
*
pDb
,
int
pages
);
// TTB
int32_t
tdbTbOpen
(
const
char
*
tbname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TDB
*
pEnv
,
TTB
**
ppTb
);
int32_t
tdbTbOpen
(
const
char
*
tbname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TDB
*
pEnv
,
TTB
**
ppTb
,
int8_t
rollback
);
int32_t
tdbTbClose
(
TTB
*
pTb
);
int32_t
tdbTbDrop
(
TTB
*
pTb
);
int32_t
tdbTbInsert
(
TTB
*
pTb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
,
TXN
*
pTxn
);
...
...
source/libs/tdb/src/db/tdbDb.c
浏览文件 @
82132cdf
...
...
@@ -15,7 +15,7 @@
#include "tdbInt.h"
int32_t
tdbOpen
(
const
char
*
dbname
,
int32_t
szPage
,
int32_t
pages
,
TDB
**
ppDb
)
{
int32_t
tdbOpen
(
const
char
*
dbname
,
int32_t
szPage
,
int32_t
pages
,
TDB
**
ppDb
,
int8_t
rollback
)
{
TDB
*
pDb
;
int
dsize
;
int
zsize
;
...
...
@@ -66,7 +66,7 @@ int32_t tdbOpen(const char *dbname, int32_t szPage, int32_t pages, TDB **ppDb) {
#ifdef USE_MAINDB
// open main db
ret
=
tdbTbOpen
(
TDB_MAINDB_NAME
,
-
1
,
sizeof
(
SBtInfo
),
NULL
,
pDb
,
&
pDb
->
pMainDb
);
ret
=
tdbTbOpen
(
TDB_MAINDB_NAME
,
-
1
,
sizeof
(
SBtInfo
),
NULL
,
pDb
,
&
pDb
->
pMainDb
,
rollback
);
if
(
ret
<
0
)
{
return
-
1
;
}
...
...
@@ -129,6 +129,21 @@ int32_t tdbCommit(TDB *pDb, TXN *pTxn) {
return
0
;
}
int32_t
tdbPostCommit
(
TDB
*
pDb
,
TXN
*
pTxn
)
{
SPager
*
pPager
;
int
ret
;
for
(
pPager
=
pDb
->
pgrList
;
pPager
;
pPager
=
pPager
->
pNext
)
{
ret
=
tdbPagerPostCommit
(
pPager
,
pTxn
);
if
(
ret
<
0
)
{
tdbError
(
"failed to commit pager since %s. dbName:%s, txnId:%d"
,
tstrerror
(
terrno
),
pDb
->
dbName
,
pTxn
->
txnId
);
return
-
1
;
}
}
return
0
;
}
int32_t
tdbAbort
(
TDB
*
pDb
,
TXN
*
pTxn
)
{
SPager
*
pPager
;
int
ret
;
...
...
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
82132cdf
...
...
@@ -305,6 +305,18 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
return
0
;
}
int
tdbPagerPostCommit
(
SPager
*
pPager
,
TXN
*
pTxn
)
{
if
(
tdbOsRemove
(
pPager
->
jFileName
)
<
0
&&
errno
!=
ENOENT
)
{
tdbError
(
"failed to remove file due to %s. file:%s"
,
strerror
(
errno
),
pPager
->
jFileName
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
pPager
->
inTran
=
0
;
return
0
;
}
// recovery dirty pages
int
tdbPagerAbort
(
SPager
*
pPager
,
TXN
*
pTxn
)
{
SPage
*
pPage
;
...
...
@@ -657,3 +669,13 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
return
0
;
}
int
tdbPagerRollback
(
SPager
*
pPager
)
{
if
(
tdbOsRemove
(
pPager
->
jFileName
)
<
0
&&
errno
!=
ENOENT
)
{
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
pPager
->
jFileName
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
return
0
;
}
source/libs/tdb/src/db/tdbTable.c
浏览文件 @
82132cdf
...
...
@@ -24,7 +24,8 @@ struct STBC {
SBTC
btc
;
};
int
tdbTbOpen
(
const
char
*
tbname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TDB
*
pEnv
,
TTB
**
ppTb
)
{
int
tdbTbOpen
(
const
char
*
tbname
,
int
keyLen
,
int
valLen
,
tdb_cmpr_fn_t
keyCmprFn
,
TDB
*
pEnv
,
TTB
**
ppTb
,
int8_t
rollback
)
{
TTB
*
pTb
;
SPager
*
pPager
;
int
ret
;
...
...
@@ -110,10 +111,14 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
return
-
1
;
}
ret
=
tdbPagerRestore
(
pPager
,
pTb
->
pBt
);
if
(
ret
<
0
)
{
tdbOsFree
(
pTb
);
return
-
1
;
if
(
rollback
)
{
tdbPagerRollback
(
pPager
);
}
else
{
ret
=
tdbPagerRestore
(
pPager
,
pTb
->
pBt
);
if
(
ret
<
0
)
{
tdbOsFree
(
pTb
);
return
-
1
;
}
}
*
ppTb
=
pTb
;
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
82132cdf
...
...
@@ -190,12 +190,14 @@ int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate, SBTree *pBt);
int
tdbPagerWrite
(
SPager
*
pPager
,
SPage
*
pPage
);
int
tdbPagerBegin
(
SPager
*
pPager
,
TXN
*
pTxn
);
int
tdbPagerCommit
(
SPager
*
pPager
,
TXN
*
pTxn
);
int
tdbPagerPostCommit
(
SPager
*
pPager
,
TXN
*
pTxn
);
int
tdbPagerAbort
(
SPager
*
pPager
,
TXN
*
pTxn
);
int
tdbPagerFetchPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
,
int
),
void
*
arg
,
TXN
*
pTxn
);
void
tdbPagerReturnPage
(
SPager
*
pPager
,
SPage
*
pPage
,
TXN
*
pTxn
);
int
tdbPagerAllocPage
(
SPager
*
pPager
,
SPgno
*
ppgno
);
int
tdbPagerRestore
(
SPager
*
pPager
,
SBTree
*
pBt
);
int
tdbPagerRollback
(
SPager
*
pPager
);
// tdbPCache.c ====================================
#define TDB_PCACHE_PAGE \
...
...
source/libs/tdb/test/tdbExOVFLTest.cpp
浏览文件 @
82132cdf
...
...
@@ -140,7 +140,7 @@ static void generateBigVal(char *val, int valLen) {
static
TDB
*
openEnv
(
char
const
*
envName
,
int
const
pageSize
,
int
const
pageNum
)
{
TDB
*
pEnv
=
NULL
;
int
ret
=
tdbOpen
(
envName
,
pageSize
,
pageNum
,
&
pEnv
);
int
ret
=
tdbOpen
(
envName
,
pageSize
,
pageNum
,
&
pEnv
,
0
);
if
(
ret
)
{
pEnv
=
NULL
;
}
...
...
@@ -162,8 +162,8 @@ static void insertOfp(void) {
// open db
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
// ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb);
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
// ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb
, 0
);
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open the pool
...
...
@@ -211,8 +211,8 @@ TEST(TdbOVFLPagesTest, TbGetTest) {
// open db
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
// int ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb);
int
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
// int ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb
, 0
);
int
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// generate value payload
...
...
@@ -253,7 +253,7 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) {
// open db
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open the pool
...
...
@@ -354,12 +354,12 @@ TEST(tdb_test, simple_insert1) {
taosRemoveDir
(
"tdb"
);
// Open Env
ret
=
tdbOpen
(
"tdb"
,
pageSize
,
64
,
&
pEnv
);
ret
=
tdbOpen
(
"tdb"
,
pageSize
,
64
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Create a database
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
{
...
...
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
82132cdf
...
...
@@ -130,12 +130,12 @@ TEST(tdb_test, DISABLED_simple_insert1) {
taosRemoveDir
(
"tdb"
);
// Open Env
ret
=
tdbOpen
(
"tdb"
,
4096
,
64
,
&
pEnv
);
ret
=
tdbOpen
(
"tdb"
,
4096
,
64
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Create a database
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
{
...
...
@@ -250,12 +250,12 @@ TEST(tdb_test, DISABLED_simple_insert2) {
taosRemoveDir
(
"tdb"
);
// Open Env
ret
=
tdbOpen
(
"tdb"
,
1024
,
10
,
&
pEnv
);
ret
=
tdbOpen
(
"tdb"
,
1024
,
10
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Create a database
compFunc
=
tDefaultKeyCmpr
;
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
{
...
...
@@ -346,11 +346,11 @@ TEST(tdb_test, DISABLED_simple_delete1) {
pPool
=
openPool
();
// open env
ret
=
tdbOpen
(
"tdb"
,
1024
,
256
,
&
pEnv
);
ret
=
tdbOpen
(
"tdb"
,
1024
,
256
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open database
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
tKeyCmpr
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
tKeyCmpr
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
tdbTxnOpen
(
&
txn
,
0
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
...
...
@@ -435,11 +435,11 @@ TEST(tdb_test, DISABLED_simple_upsert1) {
taosRemoveDir
(
"tdb"
);
// open env
ret
=
tdbOpen
(
"tdb"
,
4096
,
64
,
&
pEnv
);
ret
=
tdbOpen
(
"tdb"
,
4096
,
64
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open database
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
NULL
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
NULL
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
pPool
=
openPool
();
...
...
@@ -497,12 +497,12 @@ TEST(tdb_test, multi_thread_query) {
taosRemoveDir
(
"tdb"
);
// Open Env
ret
=
tdbOpen
(
"tdb"
,
4096
,
10
,
&
pEnv
);
ret
=
tdbOpen
(
"tdb"
,
4096
,
10
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Create a database
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
char
key
[
64
];
...
...
@@ -614,10 +614,10 @@ TEST(tdb_test, DISABLED_multi_thread1) {
taosRemoveDir("tdb");
// Open Env
ret = tdbOpen("tdb", 512, 1, &pDb);
ret = tdbOpen("tdb", 512, 1, &pDb
, 0
);
GTEST_ASSERT_EQ(ret, 0);
ret = tdbTbOpen("db.db", -1, -1, NULL, pDb, &pTb);
ret = tdbTbOpen("db.db", -1, -1, NULL, pDb, &pTb
, 0
);
GTEST_ASSERT_EQ(ret, 0);
auto insert = [](TDB *pDb, TTB *pTb, int nData, int *stop, std::shared_timed_mutex *mu) {
...
...
@@ -726,4 +726,4 @@ TEST(tdb_test, DISABLED_multi_thread1) {
ret = tdbClose(pDb);
GTEST_ASSERT_EQ(ret, 0);
#endif
}
\ No newline at end of file
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录