Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
684dd823
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
684dd823
编写于
7月 21, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix read concurrency
上级
bb2e923f
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
1429 addition
and
1059 deletion
+1429
-1059
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+18
-29
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+485
-483
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+23
-19
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+833
-436
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+3
-14
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+0
-45
source/dnode/vnode/src/tsdb/tsdbOpen.c
source/dnode/vnode/src/tsdb/tsdbOpen.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+20
-17
source/dnode/vnode/src/tsdb/tsdbRetention.c
source/dnode/vnode/src/tsdb/tsdbRetention.c
+6
-2
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+39
-12
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
684dd823
...
...
@@ -62,7 +62,6 @@ typedef struct SDelFReader SDelFReader;
typedef
struct
SRowIter
SRowIter
;
typedef
struct
STsdbFS
STsdbFS
;
typedef
struct
SRowMerger
SRowMerger
;
typedef
struct
STsdbFSState
STsdbFSState
;
typedef
struct
STsdbSnapHdr
STsdbSnapHdr
;
typedef
struct
STsdbReadSnap
STsdbReadSnap
;
...
...
@@ -177,8 +176,6 @@ void tsdbMemTableDestroy(SMemTable *pMemTable);
void
tsdbGetTbDataFromMemTable
(
SMemTable
*
pMemTable
,
tb_uid_t
suid
,
tb_uid_t
uid
,
STbData
**
ppTbData
);
void
tsdbRefMemTable
(
SMemTable
*
pMemTable
);
void
tsdbUnrefMemTable
(
SMemTable
*
pMemTable
);
int32_t
tsdbTakeMemSnapshot
(
STsdb
*
pTsdb
,
SMemTable
**
ppMem
,
SMemTable
**
ppIMem
);
void
tsdbUntakeMemSnapshot
(
STsdb
*
pTsdb
,
SMemTable
*
pMem
,
SMemTable
*
pIMem
);
// STbDataIter
int32_t
tsdbTbDataIterCreate
(
STbData
*
pTbData
,
TSDBKEY
*
pFrom
,
int8_t
backward
,
STbDataIter
**
ppIter
);
void
*
tsdbTbDataIterDestroy
(
STbDataIter
*
pIter
);
...
...
@@ -208,17 +205,20 @@ void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, ch
// SDelFile
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[]);
// tsdbFS.c ==============================================================================================
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
,
STsdbFS
**
ppFS
);
int32_t
tsdbFSClose
(
STsdbFS
*
pFS
);
int32_t
tsdbFSBegin
(
STsdbFS
*
pFS
);
int32_t
tsdbFSCommit
(
STsdbFS
*
pFS
);
int32_t
tsdbFSOpen
(
STsdb
*
pTsdb
);
int32_t
tsdbFSClose
(
STsdb
*
pTsdb
);
int32_t
tsdbFSCopy
(
STsdb
*
pTsdb
,
STsdbFS
*
pFS
);
void
tsdbFSDestroy
(
STsdbFS
*
pFS
);
int32_t
tDFileSetCmprFn
(
const
void
*
p1
,
const
void
*
p2
);
int32_t
tsdbFSCommit1
(
STsdb
*
pTsdb
,
STsdbFS
*
pFS
);
int32_t
tsdbFSCommit2
(
STsdb
*
pTsdb
,
STsdbFS
*
pFS
);
int32_t
tsdbFSRef
(
STsdb
*
pTsdb
,
STsdbFS
*
pFS
);
void
tsdbFSUnref
(
STsdb
*
pTsdb
,
STsdbFS
*
pFS
);
int32_t
tsdbFSRollback
(
STsdbFS
*
pFS
);
int32_t
tsdbFSStateUpsertDelFile
(
STsdbFSState
*
pState
,
SDelFile
*
pDelFile
);
int32_t
tsdbFSStateUpsertDFileSet
(
STsdbFSState
*
pState
,
SDFileSet
*
pSet
);
void
tsdbFSStateDeleteDFileSet
(
STsdbFSState
*
pState
,
int32_t
fid
);
SDelFile
*
tsdbFSStateGetDelFile
(
STsdbFSState
*
pState
);
SDFileSet
*
tsdbFSStateGetDFileSet
(
STsdbFSState
*
pState
,
int32_t
fid
,
int32_t
flag
);
int32_t
tsdbFSUpsertFSet
(
STsdbFS
*
pFS
,
SDFileSet
*
pSet
);
int32_t
tsdbFSUpsertDelFile
(
STsdbFS
*
pFS
,
SDelFile
*
pDelFile
);
// tsdbReaderWriter.c ==============================================================================================
// SDataFWriter
int32_t
tsdbDataFWriterOpen
(
SDataFWriter
**
ppWriter
,
STsdb
*
pTsdb
,
SDFileSet
*
pSet
);
...
...
@@ -285,6 +285,11 @@ typedef struct {
TSKEY
minKey
;
}
SRtn
;
struct
STsdbFS
{
SDelFile
*
pDelFile
;
SArray
*
aDFileSet
;
// SArray<SDFileSet>
};
struct
STsdb
{
char
*
path
;
SVnode
*
pVnode
;
...
...
@@ -292,7 +297,7 @@ struct STsdb {
TdThreadRwlock
rwLock
;
SMemTable
*
mem
;
SMemTable
*
imem
;
STsdbFS
*
pFS
;
STsdbFS
fs
;
SLRUCache
*
lruCache
;
};
...
...
@@ -540,22 +545,6 @@ struct SRowMerger {
SArray
*
pArray
;
// SArray<SColVal>
};
struct
STsdbFSState
{
SDelFile
*
pDelFile
;
SArray
*
aDFileSet
;
// SArray<aDFileSet>
SDelFile
delFile
;
};
struct
STsdbFS
{
STsdb
*
pTsdb
;
STsdbFSState
*
cState
;
STsdbFSState
*
nState
;
// new
SDelFile
*
pDelFile
;
SArray
aDFileSetP
;
// SArray<SDFileSet *>
};
struct
SDelFWriter
{
STsdb
*
pTsdb
;
SDelFile
fDel
;
...
...
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
684dd823
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
684dd823
...
...
@@ -29,6 +29,7 @@ typedef struct {
int32_t
minRow
;
int32_t
maxRow
;
int8_t
cmprAlg
;
STsdbFS
fs
;
// --------------
TSKEY
nextKey
;
// reset by each table commit
int32_t
commitFid
;
...
...
@@ -119,9 +120,6 @@ int32_t tsdbCommit(STsdb *pTsdb) {
code
=
tsdbCommitDel
(
&
commith
);
if
(
code
)
goto
_err
;
code
=
tsdbCommitCache
(
&
commith
);
if
(
code
)
goto
_err
;
// end commit
code
=
tsdbEndCommit
(
&
commith
,
0
);
if
(
code
)
goto
_err
;
...
...
@@ -158,7 +156,7 @@ static int32_t tsdbCommitDelStart(SCommitter *pCommitter) {
goto
_err
;
}
SDelFile
*
pDelFileR
=
p
Tsdb
->
pFS
->
nState
->
pDelFile
;
SDelFile
*
pDelFileR
=
p
Committer
->
fs
.
pDelFile
;
if
(
pDelFileR
)
{
code
=
tsdbDelFReaderOpen
(
&
pCommitter
->
pDelFReader
,
pDelFileR
,
pTsdb
,
NULL
);
if
(
code
)
goto
_err
;
...
...
@@ -247,7 +245,7 @@ static int32_t tsdbCommitDelEnd(SCommitter *pCommitter) {
code
=
tsdbUpdateDelFileHdr
(
pCommitter
->
pDelFWriter
);
if
(
code
)
goto
_err
;
code
=
tsdbFS
StateUpsertDelFile
(
pTsdb
->
pFS
->
nState
,
&
pCommitter
->
pDelFWriter
->
fDel
);
code
=
tsdbFS
UpsertDelFile
(
&
pCommitter
->
fs
,
&
pCommitter
->
pDelFWriter
->
fDel
);
if
(
code
)
goto
_err
;
code
=
tsdbDelFWriterClose
(
&
pCommitter
->
pDelFWriter
,
1
);
...
...
@@ -281,7 +279,8 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
taosArrayClear
(
pCommitter
->
aBlockIdx
);
tMapDataReset
(
&
pCommitter
->
oBlockMap
);
tBlockDataReset
(
&
pCommitter
->
oBlockData
);
pRSet
=
tsdbFSStateGetDFileSet
(
pTsdb
->
pFS
->
nState
,
pCommitter
->
commitFid
,
TD_EQ
);
pRSet
=
(
SDFileSet
*
)
taosArraySearch
(
pCommitter
->
fs
.
aDFileSet
,
&
(
SDFileSet
){.
fid
=
pCommitter
->
commitFid
},
tDFileSetCmprFn
,
TD_EQ
);
if
(
pRSet
)
{
code
=
tsdbDataFReaderOpen
(
&
pCommitter
->
pReader
,
pTsdb
,
pRSet
);
if
(
code
)
goto
_err
;
...
...
@@ -860,7 +859,7 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
if
(
code
)
goto
_err
;
// upsert SDFileSet
code
=
tsdbFS
StateUpsertDFileSet
(
pCommitter
->
pTsdb
->
pFS
->
nState
,
&
pCommitter
->
pWriter
->
wSet
);
code
=
tsdbFS
UpsertFSet
(
&
pCommitter
->
fs
,
&
pCommitter
->
pWriter
->
wSet
);
if
(
code
)
goto
_err
;
// close and sync
...
...
@@ -978,7 +977,7 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
pCommitter
->
maxRow
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
maxRows
;
pCommitter
->
cmprAlg
=
pTsdb
->
pVnode
->
config
.
tsdbCfg
.
compression
;
code
=
tsdbFS
Begin
(
pTsdb
->
pFS
);
code
=
tsdbFS
Copy
(
pTsdb
,
&
pCommitter
->
fs
);
if
(
code
)
goto
_err
;
return
code
;
...
...
@@ -1147,28 +1146,33 @@ _err:
return
code
;
}
static
int32_t
tsdbCommitCache
(
SCommitter
*
pCommitter
)
{
int32_t
code
=
0
;
// TODO
return
code
;
}
static
int32_t
tsdbEndCommit
(
SCommitter
*
pCommitter
,
int32_t
eno
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pCommitter
->
pTsdb
;
SMemTable
*
pMemTable
=
pTsdb
->
imem
;
if
(
eno
==
0
)
{
code
=
tsdbFSCommit
(
pTsdb
->
pFS
);
}
else
{
code
=
tsdbFSRollback
(
pTsdb
->
pFS
);
}
ASSERT
(
eno
);
code
=
tsdbFSCommit1
(
pTsdb
,
&
pCommitter
->
fs
);
if
(
code
)
goto
_err
;
// lock
taosThreadRwlockWrlock
(
&
pTsdb
->
rwLock
);
// commit or rollback
code
=
tsdbFSCommit2
(
pTsdb
,
&
pCommitter
->
fs
);
if
(
code
)
{
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
goto
_err
;
}
pTsdb
->
imem
=
NULL
;
// unlock
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
tsdbUnrefMemTable
(
pMemTable
);
tsdbFSDestroy
(
&
pCommitter
->
fs
);
tsdbInfo
(
"vgId:%d tsdb end commit"
,
TD_VID
(
pTsdb
->
pVnode
));
return
code
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
684dd823
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
684dd823
...
...
@@ -122,21 +122,11 @@ int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype) {
// truncate
switch
(
ftype
)
{
case
TSDB_HEAD_FILE
:
size
=
pSet
->
pHeadF
->
size
;
tsdbHeadFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pHeadF
,
fname
);
tPutHeadFile
(
hdr
,
pSet
->
pHeadF
);
break
;
case
TSDB_DATA_FILE
:
size
=
pSet
->
pDataF
->
size
;
tsdbDataFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pDataF
,
fname
);
tPutDataFile
(
hdr
,
pSet
->
pDataF
);
break
;
case
TSDB_LAST_FILE
:
size
=
pSet
->
pLastF
->
size
;
tsdbLastFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pLastF
,
fname
);
tPutLastFile
(
hdr
,
pSet
->
pLastF
);
break
;
case
TSDB_SMA_FILE
:
size
=
pSet
->
pSmaF
->
size
;
tsdbSmaFileName
(
pTsdb
,
pSet
->
diskId
,
pSet
->
fid
,
pSet
->
pSmaF
,
fname
);
...
...
@@ -186,6 +176,7 @@ int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype) {
return
code
;
_err:
tsdbError
(
"vgId:%d tsdb rollback file failed since %s"
,
TD_VID
(
pTsdb
->
pVnode
),
tstrerror
(
code
));
return
code
;
}
...
...
@@ -219,10 +210,8 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
// SDelFile ===============================================
void
tsdbDelFileName
(
STsdb
*
pTsdb
,
SDelFile
*
pFile
,
char
fname
[])
{
STfs
*
pTfs
=
pTsdb
->
pVnode
->
pTfs
;
snprintf
(
fname
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sv%dver%"
PRId64
"%s"
,
tfsGetPrimaryPath
(
pTfs
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
pFile
->
commitID
,
".del"
);
snprintf
(
fname
,
TSDB_FILENAME_LEN
-
1
,
"%s%s%s%sv%dver%"
PRId64
"%s"
,
tfsGetPrimaryPath
(
pTsdb
->
pVnode
->
pTfs
),
TD_DIRSEP
,
pTsdb
->
path
,
TD_DIRSEP
,
TD_VID
(
pTsdb
->
pVnode
),
pFile
->
commitID
,
".del"
);
}
int32_t
tPutDelFile
(
uint8_t
*
p
,
SDelFile
*
pDelFile
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
684dd823
...
...
@@ -605,48 +605,3 @@ void tsdbUnrefMemTable(SMemTable *pMemTable) {
tsdbMemTableDestroy
(
pMemTable
);
}
}
int32_t
tsdbTakeMemSnapshot
(
STsdb
*
pTsdb
,
SMemTable
**
ppMem
,
SMemTable
**
ppIMem
)
{
ASSERT
(
0
);
int32_t
code
=
0
;
// lock
code
=
taosThreadRwlockRdlock
(
&
pTsdb
->
rwLock
);
if
(
code
)
{
code
=
TAOS_SYSTEM_ERROR
(
code
);
goto
_exit
;
}
// take snapshot
*
ppMem
=
pTsdb
->
mem
;
*
ppIMem
=
pTsdb
->
imem
;
if
(
*
ppMem
)
{
tsdbRefMemTable
(
*
ppMem
);
}
if
(
*
ppIMem
)
{
tsdbRefMemTable
(
*
ppIMem
);
}
// unlock
code
=
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
if
(
code
)
{
code
=
TAOS_SYSTEM_ERROR
(
code
);
goto
_exit
;
}
_exit:
return
code
;
}
void
tsdbUntakeMemSnapshot
(
STsdb
*
pTsdb
,
SMemTable
*
pMem
,
SMemTable
*
pIMem
)
{
ASSERT
(
0
);
if
(
pMem
)
{
tsdbUnrefMemTable
(
pMem
);
}
if
(
pIMem
)
{
tsdbUnrefMemTable
(
pIMem
);
}
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbOpen.c
浏览文件 @
684dd823
...
...
@@ -66,7 +66,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
tfsMkdir
(
pVnode
->
pTfs
,
pTsdb
->
path
);
// open tsdb
if
(
tsdbFSOpen
(
pTsdb
,
&
pTsdb
->
pFS
)
<
0
)
{
if
(
tsdbFSOpen
(
pTsdb
)
<
0
)
{
goto
_err
;
}
...
...
@@ -88,7 +88,7 @@ _err:
int
tsdbClose
(
STsdb
**
pTsdb
)
{
if
(
*
pTsdb
)
{
taosThreadRwlockDestroy
(
&
(
*
pTsdb
)
->
rwLock
);
tsdbFSClose
(
(
*
pTsdb
)
->
pFS
);
tsdbFSClose
(
*
pTsdb
);
tsdbCloseCache
((
*
pTsdb
)
->
lruCache
);
taosMemoryFreeClear
(
*
pTsdb
);
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
684dd823
...
...
@@ -118,8 +118,7 @@ struct STsdbReader {
char
*
idStr
;
// query info handle, for debug purpose
int32_t
type
;
// query type: 1. retrieve all data blocks, 2. retrieve direct prev|next rows
SBlockLoadSuppInfo
suppInfo
;
SMemTable
*
pMem
;
SMemTable
*
pIMem
;
STsdbReadSnap
*
pReadSnap
;
SIOCostSummary
cost
;
STSchema
*
pSchema
;
...
...
@@ -275,12 +274,12 @@ static void limitOutputBufferSize(const SQueryTableDataCond* pCond, int32_t* cap
}
// init file iterator
static
int32_t
initFilesetIterator
(
SFilesetIter
*
pIter
,
const
STsdbFSState
*
pFState
,
int32_t
order
,
const
char
*
idstr
)
{
size_t
numOfFileset
=
taosArrayGetSize
(
pFState
->
aDFileSet
);
static
int32_t
initFilesetIterator
(
SFilesetIter
*
pIter
,
SArray
*
aDFileSet
,
int32_t
order
,
const
char
*
idstr
)
{
size_t
numOfFileset
=
taosArrayGetSize
(
aDFileSet
);
pIter
->
index
=
ASCENDING_TRAVERSE
(
order
)
?
-
1
:
numOfFileset
;
pIter
->
order
=
order
;
pIter
->
pFileList
=
taosArrayDup
(
pFState
->
aDFileSet
)
;
pIter
->
pFileList
=
aDFileSet
;
pIter
->
numOfFiles
=
numOfFileset
;
tsdbDebug
(
"init fileset iterator, total files:%d %s"
,
pIter
->
numOfFiles
,
idstr
);
...
...
@@ -1881,8 +1880,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
int32_t
backward
=
(
!
ASCENDING_TRAVERSE
(
pReader
->
order
));
STbData
*
d
=
NULL
;
if
(
pReader
->
pMem
!=
NULL
)
{
tsdbGetTbDataFromMemTable
(
pReader
->
pMem
,
pReader
->
suid
,
pBlockScanInfo
->
uid
,
&
d
);
if
(
pReader
->
p
ReadSnap
->
p
Mem
!=
NULL
)
{
tsdbGetTbDataFromMemTable
(
pReader
->
p
ReadSnap
->
p
Mem
,
pReader
->
suid
,
pBlockScanInfo
->
uid
,
&
d
);
if
(
d
!=
NULL
)
{
code
=
tsdbTbDataIterCreate
(
d
,
&
startKey
,
backward
,
&
pBlockScanInfo
->
iter
.
iter
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1902,8 +1901,8 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
}
STbData
*
di
=
NULL
;
if
(
pReader
->
pIMem
!=
NULL
)
{
tsdbGetTbDataFromMemTable
(
pReader
->
pIMem
,
pReader
->
suid
,
pBlockScanInfo
->
uid
,
&
di
);
if
(
pReader
->
p
ReadSnap
->
p
IMem
!=
NULL
)
{
tsdbGetTbDataFromMemTable
(
pReader
->
p
ReadSnap
->
p
IMem
,
pReader
->
suid
,
pBlockScanInfo
->
uid
,
&
di
);
if
(
di
!=
NULL
)
{
code
=
tsdbTbDataIterCreate
(
di
,
&
startKey
,
backward
,
&
pBlockScanInfo
->
iiter
.
iter
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1939,7 +1938,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
SArray
*
pDelData
=
taosArrayInit
(
4
,
sizeof
(
SDelData
));
SDelFile
*
pDelFile
=
tsdbFSStateGetDelFile
(
pTsdb
->
pFS
->
cState
)
;
SDelFile
*
pDelFile
=
pReader
->
pReadSnap
->
fs
.
pDelFile
;
if
(
pDelFile
)
{
SDelFReader
*
pDelFReader
=
NULL
;
code
=
tsdbDelFReaderOpen
(
&
pDelFReader
,
pDelFile
,
pTsdb
,
NULL
);
...
...
@@ -2830,8 +2829,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
SDataBlockIter
*
pBlockIter
=
&
pReader
->
status
.
blockIter
;
STsdbFSState
*
pFState
=
pReader
->
pTsdb
->
pFS
->
cState
;
initFilesetIterator
(
&
pReader
->
status
.
fileIter
,
pFState
,
pReader
->
order
,
pReader
->
idStr
);
initFilesetIterator
(
&
pReader
->
status
.
fileIter
,
(
*
ppReader
)
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
->
order
,
pReader
->
idStr
);
resetDataBlockIterator
(
&
pReader
->
status
.
blockIter
,
pReader
->
order
);
// no data in files, let's try buffer in memory
...
...
@@ -2844,7 +2842,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
}
}
tsdbTakeMemSnapshot
(
pReader
->
pTsdb
,
&
pReader
->
pMem
,
&
pReader
->
pIMem
);
code
=
tsdbTakeReadSnap
(
pVnode
->
pTsdb
,
&
pReader
->
pReadSnap
);
if
(
code
)
goto
_err
;
tsdbDebug
(
"%p total numOfTable:%d in this query %s"
,
pReader
,
numOfTables
,
pReader
->
idStr
);
return
code
;
...
...
@@ -2861,7 +2860,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
SBlockLoadSuppInfo
*
pSupInfo
=
&
pReader
->
suppInfo
;
tsdbUntake
MemSnapshot
(
pReader
->
pTsdb
,
pReader
->
pMem
,
pReader
->
pIMem
);
tsdbUntake
ReadSnap
(
pReader
->
pTsdb
,
pReader
->
pReadSnap
);
taosMemoryFreeClear
(
pSupInfo
->
plist
);
taosMemoryFree
(
pSupInfo
->
colIds
);
...
...
@@ -3081,8 +3080,7 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
tsdbDataFReaderClose
(
&
pReader
->
pFileReader
);
STsdbFSState
*
pFState
=
pReader
->
pTsdb
->
pFS
->
cState
;
initFilesetIterator
(
&
pReader
->
status
.
fileIter
,
pFState
,
pReader
->
order
,
pReader
->
idStr
);
initFilesetIterator
(
&
pReader
->
status
.
fileIter
,
pReader
->
pReadSnap
->
fs
.
aDFileSet
,
pReader
->
order
,
pReader
->
idStr
);
resetDataBlockIterator
(
&
pReader
->
status
.
blockIter
,
pReader
->
order
);
resetDataBlockScanInfo
(
pReader
->
status
.
pTableMap
);
...
...
@@ -3275,6 +3273,11 @@ int32_t tsdbTakeReadSnap(STsdb* pTsdb, STsdbReadSnap** ppSnap) {
}
// fs (todo)
code
=
tsdbFSRef
(
pTsdb
,
&
(
*
ppSnap
)
->
fs
);
if
(
code
)
{
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
goto
_exit
;
}
// unlock
code
=
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
...
...
@@ -3297,6 +3300,6 @@ void tsdbUntakeReadSnap(STsdb* pTsdb, STsdbReadSnap* pSnap) {
tsdbUnrefMemTable
(
pSnap
->
pIMem
);
}
// fs (todo)
tsdbFSUnref
(
pTsdb
,
&
pSnap
->
fs
);
}
}
source/dnode/vnode/src/tsdb/tsdbRetention.c
浏览文件 @
684dd823
...
...
@@ -16,7 +16,8 @@
#include "tsdb.h"
static
int32_t
tsdbDoRetentionImpl
(
STsdb
*
pTsdb
,
int64_t
now
,
int8_t
try
,
int8_t
*
canDo
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
#if 0
STsdbFSState *pState;
if (try) {
...
...
@@ -64,18 +65,20 @@ static int32_t tsdbDoRetentionImpl(STsdb *pTsdb, int64_t now, int8_t try, int8_t
code = tsdbDFileSetCopy(pTsdb, pDFileSet, &nDFileSet);
if (code) goto _exit;
code
=
tsdbFS
StateUpsertDFile
Set
(
pState
,
&
nDFileSet
);
code = tsdbFS
UpsertF
Set(pState, &nDFileSet);
if (code) goto _exit;
}
}
}
#endif
_exit:
return
code
;
}
int32_t
tsdbDoRetention
(
STsdb
*
pTsdb
,
int64_t
now
)
{
int32_t
code
=
0
;
#if 0
int8_t canDo;
// try
...
...
@@ -100,5 +103,6 @@ _exit:
_err:
tsdbError("vgId:%d tsdb do retention failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
tsdbFSRollback(pTsdb->pFS);
#endif
return
code
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
浏览文件 @
684dd823
...
...
@@ -20,6 +20,7 @@ struct STsdbSnapReader {
STsdb
*
pTsdb
;
int64_t
sver
;
int64_t
ever
;
STsdbFS
fs
;
// for data file
int8_t
dataDone
;
int32_t
fid
;
...
...
@@ -45,7 +46,8 @@ static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
while
(
true
)
{
if
(
pReader
->
pDataFReader
==
NULL
)
{
SDFileSet
*
pSet
=
tsdbFSStateGetDFileSet
(
pTsdb
->
pFS
->
cState
,
pReader
->
fid
,
TD_GT
);
SDFileSet
*
pSet
=
taosArraySearch
(
pReader
->
fs
.
aDFileSet
,
&
(
SDFileSet
){.
fid
=
pReader
->
fid
},
tDFileSetCmprFn
,
TD_GT
);
if
(
pSet
==
NULL
)
goto
_exit
;
...
...
@@ -159,7 +161,7 @@ _err:
static
int32_t
tsdbSnapReadDel
(
STsdbSnapReader
*
pReader
,
uint8_t
**
ppData
)
{
int32_t
code
=
0
;
STsdb
*
pTsdb
=
pReader
->
pTsdb
;
SDelFile
*
pDelFile
=
p
Tsdb
->
pFS
->
cState
->
pDelFile
;
SDelFile
*
pDelFile
=
p
Reader
->
fs
.
pDelFile
;
if
(
pReader
->
pDelFReader
==
NULL
)
{
if
(
pDelFile
==
NULL
)
{
...
...
@@ -254,6 +256,24 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapRe
pReader
->
sver
=
sver
;
pReader
->
ever
=
ever
;
code
=
taosThreadRwlockRdlock
(
&
pTsdb
->
rwLock
);
if
(
code
)
{
code
=
TAOS_SYSTEM_ERROR
(
code
);
goto
_err
;
}
code
=
tsdbFSRef
(
pTsdb
,
&
pReader
->
fs
);
if
(
code
)
{
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
goto
_err
;
}
code
=
taosThreadRwlockUnlock
(
&
pTsdb
->
rwLock
);
if
(
code
)
{
code
=
TAOS_SYSTEM_ERROR
(
code
);
goto
_err
;
}
pReader
->
fid
=
INT32_MIN
;
pReader
->
aBlockIdx
=
taosArrayInit
(
0
,
sizeof
(
SBlockIdx
));
if
(
pReader
->
aBlockIdx
==
NULL
)
{
...
...
@@ -305,6 +325,8 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
taosArrayDestroy
(
pReader
->
aDelIdx
);
taosArrayDestroy
(
pReader
->
aDelData
);
tsdbFSUnref
(
pReader
->
pTsdb
,
&
pReader
->
fs
);
tsdbInfo
(
"vgId:%d vnode snapshot tsdb reader closed"
,
TD_VID
(
pReader
->
pTsdb
->
pVnode
));
taosMemoryFree
(
pReader
);
...
...
@@ -358,6 +380,7 @@ struct STsdbSnapWriter {
STsdb
*
pTsdb
;
int64_t
sver
;
int64_t
ever
;
STsdbFS
fs
;
// config
int32_t
minutes
;
...
...
@@ -798,7 +821,7 @@ static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
code
=
tsdbWriteBlockIdx
(
pWriter
->
pDataFWriter
,
pWriter
->
aBlockIdxW
,
NULL
);
if
(
code
)
goto
_err
;
code
=
tsdbFS
StateUpsertDFileSet
(
pTsdb
->
pFS
->
nState
,
&
pWriter
->
pDataFWriter
->
wSet
);
code
=
tsdbFS
UpsertFSet
(
&
pWriter
->
fs
,
&
pWriter
->
pDataFWriter
->
wSet
);
if
(
code
)
goto
_err
;
code
=
tsdbDataFWriterClose
(
&
pWriter
->
pDataFWriter
,
1
);
...
...
@@ -843,7 +866,7 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
pWriter
->
fid
=
fid
;
// read
SDFileSet
*
pSet
=
t
sdbFSStateGetDFileSet
(
pTsdb
->
pFS
->
nState
,
fid
,
TD_EQ
);
SDFileSet
*
pSet
=
t
aosArraySearch
(
pWriter
->
fs
.
aDFileSet
,
&
(
SDFileSet
){.
fid
=
fid
},
tDFileSetCmprFn
,
TD_EQ
);
if
(
pSet
)
{
code
=
tsdbDataFReaderOpen
(
&
pWriter
->
pDataFReader
,
pTsdb
,
pSet
);
if
(
code
)
goto
_err
;
...
...
@@ -911,7 +934,7 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
STsdb
*
pTsdb
=
pWriter
->
pTsdb
;
if
(
pWriter
->
pDelFWriter
==
NULL
)
{
SDelFile
*
pDelFile
=
tsdbFSStateGetDelFile
(
pTsdb
->
pFS
->
nState
)
;
SDelFile
*
pDelFile
=
pWriter
->
fs
.
pDelFile
;
// reader
if
(
pDelFile
)
{
...
...
@@ -1021,7 +1044,7 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
code
=
tsdbUpdateDelFileHdr
(
pWriter
->
pDelFWriter
);
if
(
code
)
goto
_err
;
code
=
tsdbFS
StateUpsertDelFile
(
pTsdb
->
pFS
->
nState
,
&
pWriter
->
pDelFWriter
->
fDel
);
code
=
tsdbFS
UpsertDelFile
(
&
pWriter
->
fs
,
&
pWriter
->
pDelFWriter
->
fDel
);
if
(
code
)
goto
_err
;
code
=
tsdbDelFWriterClose
(
&
pWriter
->
pDelFWriter
,
1
);
...
...
@@ -1055,6 +1078,9 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
pWriter
->
sver
=
sver
;
pWriter
->
ever
=
ever
;
code
=
tsdbFSCopy
(
pTsdb
,
&
pWriter
->
fs
);
if
(
code
)
goto
_err
;
// config
pWriter
->
minutes
=
pTsdb
->
keepCfg
.
days
;
pWriter
->
precision
=
pTsdb
->
keepCfg
.
precision
;
...
...
@@ -1100,9 +1126,6 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
goto
_err
;
}
code
=
tsdbFSBegin
(
pTsdb
->
pFS
);
if
(
code
)
goto
_err
;
*
ppWriter
=
pWriter
;
return
code
;
...
...
@@ -1117,8 +1140,9 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
STsdbSnapWriter
*
pWriter
=
*
ppWriter
;
if
(
rollback
)
{
code
=
tsdbFSRollback
(
pWriter
->
pTsdb
->
pFS
);
if
(
code
)
goto
_err
;
ASSERT
(
0
);
// code = tsdbFSRollback(pWriter->pTsdb->pFS);
// if (code) goto _err;
}
else
{
code
=
tsdbSnapWriteDataEnd
(
pWriter
);
if
(
code
)
goto
_err
;
...
...
@@ -1126,7 +1150,10 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
code
=
tsdbSnapWriteDelEnd
(
pWriter
);
if
(
code
)
goto
_err
;
code
=
tsdbFSCommit
(
pWriter
->
pTsdb
->
pFS
);
code
=
tsdbFSCommit1
(
pWriter
->
pTsdb
,
&
pWriter
->
fs
);
if
(
code
)
goto
_err
;
code
=
tsdbFSCommit2
(
pWriter
->
pTsdb
,
&
pWriter
->
fs
);
if
(
code
)
goto
_err
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录