Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
~笨蛋陪你哭
TDengine
提交
b286a296
T
TDengine
项目概览
~笨蛋陪你哭
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b286a296
编写于
4月 14, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-52] first version mpeer
上级
1fb5a8c2
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
87 addition
and
76 deletion
+87
-76
src/dnode/CMakeLists.txt
src/dnode/CMakeLists.txt
+4
-0
src/dnode/inc/dnodeMgmt.h
src/dnode/inc/dnodeMgmt.h
+1
-0
src/dnode/src/dnodeMClient.c
src/dnode/src/dnodeMClient.c
+1
-1
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+4
-0
src/inc/mnode.h
src/inc/mnode.h
+0
-1
src/inc/mpeer.h
src/inc/mpeer.h
+5
-0
src/mnode/inc/mgmtSdb.h
src/mnode/inc/mgmtSdb.h
+12
-0
src/mnode/src/mgmtMain.c
src/mnode/src/mgmtMain.c
+5
-5
src/mnode/src/mgmtMnode.c
src/mnode/src/mgmtMnode.c
+2
-3
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+53
-66
未找到文件。
src/dnode/CMakeLists.txt
浏览文件 @
b286a296
...
@@ -31,6 +31,10 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
...
@@ -31,6 +31,10 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
TARGET_LINK_LIBRARIES
(
taosd balance sync
)
TARGET_LINK_LIBRARIES
(
taosd balance sync
)
ENDIF
()
ENDIF
()
IF
(
TD_MPEER
)
TARGET_LINK_LIBRARIES
(
taosd mpeer sync
)
ENDIF
()
SET
(
PREPARE_ENV_CMD
"prepare_env_cmd"
)
SET
(
PREPARE_ENV_CMD
"prepare_env_cmd"
)
SET
(
PREPARE_ENV_TARGET
"prepare_env_target"
)
SET
(
PREPARE_ENV_TARGET
"prepare_env_target"
)
ADD_CUSTOM_COMMAND
(
OUTPUT
${
PREPARE_ENV_CMD
}
ADD_CUSTOM_COMMAND
(
OUTPUT
${
PREPARE_ENV_CMD
}
...
...
src/dnode/inc/dnodeMgmt.h
浏览文件 @
b286a296
...
@@ -24,6 +24,7 @@ int32_t dnodeInitMgmt();
...
@@ -24,6 +24,7 @@ int32_t dnodeInitMgmt();
void
dnodeCleanupMgmt
();
void
dnodeCleanupMgmt
();
void
dnodeMgmt
(
SRpcMsg
*
rpcMsg
);
void
dnodeMgmt
(
SRpcMsg
*
rpcMsg
);
void
dnodeUpdateDnodeId
(
int32_t
dnodeId
);
void
dnodeUpdateDnodeId
(
int32_t
dnodeId
);
int32_t
dnodeGetDnodeId
();
void
*
dnodeGetVnode
(
int32_t
vgId
);
void
*
dnodeGetVnode
(
int32_t
vgId
);
int32_t
dnodeGetVnodeStatus
(
void
*
pVnode
);
int32_t
dnodeGetVnodeStatus
(
void
*
pVnode
);
...
...
src/dnode/src/dnodeMClient.c
浏览文件 @
b286a296
...
@@ -294,4 +294,4 @@ uint32_t dnodeGetMnodeMasteIp() {
...
@@ -294,4 +294,4 @@ uint32_t dnodeGetMnodeMasteIp() {
void
*
dnodeGetMpeerInfos
()
{
void
*
dnodeGetMpeerInfos
()
{
return
&
tsMnodeInfos
;
return
&
tsMnodeInfos
;
}
}
\ No newline at end of file
src/dnode/src/dnodeMgmt.c
浏览文件 @
b286a296
...
@@ -299,3 +299,7 @@ void dnodeUpdateDnodeId(int32_t dnodeId) {
...
@@ -299,3 +299,7 @@ void dnodeUpdateDnodeId(int32_t dnodeId) {
dnodeSaveDnodeId
();
dnodeSaveDnodeId
();
}
}
}
}
int32_t
dnodeGetDnodeId
()
{
return
tsDnodeId
;
}
\ No newline at end of file
src/inc/mnode.h
浏览文件 @
b286a296
...
@@ -45,7 +45,6 @@ struct _mnode_obj;
...
@@ -45,7 +45,6 @@ struct _mnode_obj;
typedef
struct
_mnode_obj
{
typedef
struct
_mnode_obj
{
int32_t
mnodeId
;
int32_t
mnodeId
;
int32_t
dnodeId
;
int64_t
createdTime
;
int64_t
createdTime
;
int8_t
reserved
[
14
];
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int8_t
updateEnd
[
1
];
...
...
src/inc/mpeer.h
浏览文件 @
b286a296
...
@@ -45,6 +45,11 @@ void mpeerGetMpeerInfos(void *mpeers);
...
@@ -45,6 +45,11 @@ void mpeerGetMpeerInfos(void *mpeers);
char
*
mpeerGetMnodeStatusStr
(
int32_t
status
);
char
*
mpeerGetMnodeStatusStr
(
int32_t
status
);
char
*
mpeerGetMnodeRoleStr
(
int32_t
role
);
char
*
mpeerGetMnodeRoleStr
(
int32_t
role
);
int32_t
mpeerAddMnode
(
int32_t
dnodeId
);
int32_t
mpeerRemoveMnode
(
int32_t
dnodeId
);
int32_t
sdbForwardDbReqToPeer
(
void
*
pHead
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/mnode/inc/mgmtSdb.h
浏览文件 @
b286a296
...
@@ -34,6 +34,7 @@ typedef enum {
...
@@ -34,6 +34,7 @@ typedef enum {
typedef
enum
{
typedef
enum
{
SDB_KEY_STRING
,
SDB_KEY_STRING
,
SDB_KEY_INT
,
SDB_KEY_AUTO
SDB_KEY_AUTO
}
ESdbKeyType
;
}
ESdbKeyType
;
...
@@ -66,8 +67,19 @@ typedef struct {
...
@@ -66,8 +67,19 @@ typedef struct {
int32_t
(
*
updateAllFp
)();
int32_t
(
*
updateAllFp
)();
}
SSdbTableDesc
;
}
SSdbTableDesc
;
typedef
struct
{
int32_t
code
;
int64_t
version
;
void
*
sync
;
void
*
wal
;
sem_t
sem
;
pthread_mutex_t
mutex
;
}
SSdbObject
;
int32_t
sdbInit
();
int32_t
sdbInit
();
void
sdbCleanUp
();
void
sdbCleanUp
();
SSdbObject
*
sdbGetObj
();
int
sdbProcessWrite
(
void
*
param
,
void
*
data
,
int
type
);
void
*
sdbOpenTable
(
SSdbTableDesc
*
desc
);
void
*
sdbOpenTable
(
SSdbTableDesc
*
desc
);
void
sdbCloseTable
(
void
*
handle
);
void
sdbCloseTable
(
void
*
handle
);
...
...
src/mnode/src/mgmtMain.c
浏览文件 @
b286a296
...
@@ -109,6 +109,11 @@ int32_t mgmtStartSystem() {
...
@@ -109,6 +109,11 @@ int32_t mgmtStartSystem() {
return
-
1
;
return
-
1
;
}
}
if
(
mpeerInit
()
<
0
)
{
mError
(
"failed to init mpeers"
);
return
-
1
;
}
if
(
sdbInit
()
<
0
)
{
if
(
sdbInit
()
<
0
)
{
mError
(
"failed to init sdb"
);
mError
(
"failed to init sdb"
);
return
-
1
;
return
-
1
;
...
@@ -122,11 +127,6 @@ int32_t mgmtStartSystem() {
...
@@ -122,11 +127,6 @@ int32_t mgmtStartSystem() {
return
-
1
;
return
-
1
;
}
}
if
(
mpeerInit
()
<
0
)
{
mError
(
"failed to init mpeers"
);
return
-
1
;
}
if
(
balanceInit
()
<
0
)
{
if
(
balanceInit
()
<
0
)
{
mError
(
"failed to init dnode balance"
)
mError
(
"failed to init dnode balance"
)
}
}
...
...
src/mnode/src/mgmtMnode.c
浏览文件 @
b286a296
...
@@ -79,7 +79,7 @@ void mpeerGetMpeerInfos(void *param) {
...
@@ -79,7 +79,7 @@ void mpeerGetMpeerInfos(void *param) {
strcpy
(
mpeers
->
nodeInfos
[
0
].
nodeName
,
tsMnodeObj
.
mnodeName
);
strcpy
(
mpeers
->
nodeInfos
[
0
].
nodeName
,
tsMnodeObj
.
mnodeName
);
}
}
void
mpeerCleanup
D
nodes
()
{}
void
mpeerCleanup
M
nodes
()
{}
int32_t
mpeerGetMnodesNum
()
{
return
1
;
}
int32_t
mpeerGetMnodesNum
()
{
return
1
;
}
void
mpeerReleaseMnode
(
struct
_mnode_obj
*
pMnode
)
{}
void
mpeerReleaseMnode
(
struct
_mnode_obj
*
pMnode
)
{}
bool
mpeerInServerStatus
()
{
return
tsMnodeObj
.
status
==
TAOS_MN_STATUS_READY
;
}
bool
mpeerInServerStatus
()
{
return
tsMnodeObj
.
status
==
TAOS_MN_STATUS_READY
;
}
...
@@ -91,12 +91,11 @@ bool mpeerCheckRedirect() { return false; }
...
@@ -91,12 +91,11 @@ bool mpeerCheckRedirect() { return false; }
int32_t
mpeerInit
()
{
int32_t
mpeerInit
()
{
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtGetMnodeMeta
);
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtGetMnodeMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtRetrieveMnodes
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_MNODE
,
mgmtRetrieveMnodes
);
return
mpeerInitMnodes
();
return
mpeerInitMnodes
();
}
}
void
mpeerCleanup
()
{
void
mpeerCleanup
()
{
mpeerCleanup
D
nodes
();
mpeerCleanup
M
nodes
();
}
}
char
*
mpeerGetMnodeStatusStr
(
int32_t
status
)
{
char
*
mpeerGetMnodeStatusStr
(
int32_t
status
)
{
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
b286a296
...
@@ -24,19 +24,11 @@
...
@@ -24,19 +24,11 @@
#include "tutil.h"
#include "tutil.h"
#include "twal.h"
#include "twal.h"
#include "tsync.h"
#include "tsync.h"
#include "mpeer.h"
#include "hashint.h"
#include "hashint.h"
#include "hashstr.h"
#include "hashstr.h"
#include "mgmtSdb.h"
#include "mgmtSdb.h"
typedef
struct
{
int32_t
code
;
int64_t
version
;
void
*
sync
;
void
*
wal
;
sem_t
sem
;
pthread_mutex_t
mutex
;
}
SSdbSync
;
typedef
struct
_SSdbTable
{
typedef
struct
_SSdbTable
{
char
tableName
[
TSDB_DB_NAME_LEN
+
1
];
char
tableName
[
TSDB_DB_NAME_LEN
+
1
];
ESdbTable
tableId
;
ESdbTable
tableId
;
...
@@ -70,17 +62,16 @@ typedef enum {
...
@@ -70,17 +62,16 @@ typedef enum {
static
SSdbTable
*
tsSdbTableList
[
SDB_TABLE_MAX
]
=
{
0
};
static
SSdbTable
*
tsSdbTableList
[
SDB_TABLE_MAX
]
=
{
0
};
static
int32_t
tsSdbNumOfTables
=
0
;
static
int32_t
tsSdbNumOfTables
=
0
;
static
SSdb
Sync
*
tsSdbSync
;
static
SSdb
Object
*
tsSdbObj
;
static
void
*
(
*
sdbInitIndexFp
[])(
int32_t
maxRows
,
int32_t
dataSize
)
=
{
sdbOpenStrHash
,
sdbOpenIntHash
};
static
void
*
(
*
sdbInitIndexFp
[])(
int32_t
maxRows
,
int32_t
dataSize
)
=
{
sdbOpenStrHash
,
sdbOpenIntHash
,
sdbOpenIntHash
};
static
void
*
(
*
sdbAddIndexFp
[])(
void
*
handle
,
void
*
key
,
void
*
data
)
=
{
sdbAddStrHash
,
sdbAddIntHash
};
static
void
*
(
*
sdbAddIndexFp
[])(
void
*
handle
,
void
*
key
,
void
*
data
)
=
{
sdbAddStrHash
,
sdbAddIntHash
,
sdbAddIntHash
};
static
void
(
*
sdbDeleteIndexFp
[])(
void
*
handle
,
void
*
key
)
=
{
sdbDeleteStrHash
,
sdbDeleteIntHash
};
static
void
(
*
sdbDeleteIndexFp
[])(
void
*
handle
,
void
*
key
)
=
{
sdbDeleteStrHash
,
sdbDeleteIntHash
,
sdbDeleteIntHash
};
static
void
*
(
*
sdbGetIndexFp
[])(
void
*
handle
,
void
*
key
)
=
{
sdbGetStrHashData
,
sdbGetIntHashData
};
static
void
*
(
*
sdbGetIndexFp
[])(
void
*
handle
,
void
*
key
)
=
{
sdbGetStrHashData
,
sdbGetIntHashData
,
sdbGetIntHashData
};
static
void
(
*
sdbCleanUpIndexFp
[])(
void
*
handle
)
=
{
sdbCloseStrHash
,
sdbCloseIntHash
};
static
void
(
*
sdbCleanUpIndexFp
[])(
void
*
handle
)
=
{
sdbCloseStrHash
,
sdbCloseIntHash
,
sdbCloseIntHash
};
static
void
*
(
*
sdbFetchRowFp
[])(
void
*
handle
,
void
*
ptr
,
void
**
ppRow
)
=
{
sdbFetchStrHashData
,
sdbFetchIntHashData
};
static
void
*
(
*
sdbFetchRowFp
[])(
void
*
handle
,
void
*
ptr
,
void
**
ppRow
)
=
{
sdbFetchStrHashData
,
sdbFetchIntHashData
,
sdbFetchIntHashData
};
static
int
sdbProcessWrite
(
void
*
param
,
void
*
data
,
int
type
);
uint64_t
sdbGetVersion
()
{
return
tsSdb
Sync
->
version
;
}
uint64_t
sdbGetVersion
()
{
return
tsSdb
Obj
->
version
;
}
int64_t
sdbGetId
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
autoIndex
;
}
int64_t
sdbGetId
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
autoIndex
;
}
int64_t
sdbGetNumOfRows
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
numOfRows
;
}
int64_t
sdbGetNumOfRows
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
numOfRows
;
}
...
@@ -101,6 +92,7 @@ static char *sdbGetkeyStr(SSdbTable *pTable, void *row) {
...
@@ -101,6 +92,7 @@ static char *sdbGetkeyStr(SSdbTable *pTable, void *row) {
switch
(
pTable
->
keyType
)
{
switch
(
pTable
->
keyType
)
{
case
SDB_KEY_STRING
:
case
SDB_KEY_STRING
:
return
(
char
*
)
row
;
return
(
char
*
)
row
;
case
SDB_KEY_INT
:
case
SDB_KEY_AUTO
:
case
SDB_KEY_AUTO
:
sprintf
(
str
,
"%d"
,
*
(
int32_t
*
)
row
);
sprintf
(
str
,
"%d"
,
*
(
int32_t
*
)
row
);
return
str
;
return
str
;
...
@@ -113,40 +105,30 @@ static void *sdbGetTableFromId(int32_t tableId) {
...
@@ -113,40 +105,30 @@ static void *sdbGetTableFromId(int32_t tableId) {
return
tsSdbTableList
[
tableId
];
return
tsSdbTableList
[
tableId
];
}
}
// static void mpeerConfirmForward(void *ahandle, void *param, int32_t code) {
#ifndef _MPEER
// sem_post(&tsSdbSync->sem);
int32_t
sdbForwardDbReqToPeer
(
void
*
pHead
)
{
// mPrint("mpeerConfirmForward");
// }
static
int32_t
sdbForwardDbReqToPeer
(
SWalHead
*
pHead
)
{
// int32_t code = syncForwardToPeer(NULL, pHead, NULL);
// if (code < 0) {
// return code;
// }
// sem_wait(&tsSdbSync->sem);
// return tsSdbSync->code;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
#endif
int32_t
sdbInit
()
{
int32_t
sdbInit
()
{
tsSdb
Sync
=
calloc
(
1
,
sizeof
(
SSdbSync
));
tsSdb
Obj
=
calloc
(
1
,
sizeof
(
SSdbObject
));
sem_init
(
&
tsSdb
Sync
->
sem
,
0
,
0
);
sem_init
(
&
tsSdb
Obj
->
sem
,
0
,
0
);
pthread_mutex_init
(
&
tsSdb
Sync
->
mutex
,
NULL
);
pthread_mutex_init
(
&
tsSdb
Obj
->
mutex
,
NULL
);
SWalCfg
walCfg
=
{.
commitLog
=
2
,
.
wals
=
2
,
.
keep
=
1
};
SWalCfg
walCfg
=
{.
commitLog
=
2
,
.
wals
=
2
,
.
keep
=
1
};
tsSdb
Sync
->
wal
=
walOpen
(
tsMnodeDir
,
&
walCfg
);
tsSdb
Obj
->
wal
=
walOpen
(
tsMnodeDir
,
&
walCfg
);
if
(
tsSdb
Sync
->
wal
==
NULL
)
{
if
(
tsSdb
Obj
->
wal
==
NULL
)
{
sdbError
(
"failed to open sdb in %s"
,
tsMnodeDir
);
sdbError
(
"failed to open sdb in %s"
,
tsMnodeDir
);
return
-
1
;
return
-
1
;
}
}
sdbTrace
(
"open sdb file for read"
);
sdbTrace
(
"open sdb file for read"
);
walRestore
(
tsSdb
Sync
->
wal
,
tsSdbSync
,
sdbProcessWrite
);
walRestore
(
tsSdb
Obj
->
wal
,
tsSdbObj
,
sdbProcessWrite
);
int32_t
totalRows
=
0
;
int32_t
totalRows
=
0
;
int32_t
numOfTables
=
0
;
int32_t
numOfTables
=
0
;
for
(
int32_t
tableId
=
SDB_TABLE_
D
NODE
;
tableId
<
SDB_TABLE_MAX
;
++
tableId
)
{
for
(
int32_t
tableId
=
SDB_TABLE_
M
NODE
;
tableId
<
SDB_TABLE_MAX
;
++
tableId
)
{
SSdbTable
*
pTable
=
sdbGetTableFromId
(
tableId
);
SSdbTable
*
pTable
=
sdbGetTableFromId
(
tableId
);
if
(
pTable
==
NULL
)
continue
;
if
(
pTable
==
NULL
)
continue
;
if
(
pTable
->
updateAllFp
)
{
if
(
pTable
->
updateAllFp
)
{
...
@@ -158,20 +140,24 @@ int32_t sdbInit() {
...
@@ -158,20 +140,24 @@ int32_t sdbInit() {
sdbTrace
(
"table:%s, is initialized, numOfRows:%d"
,
pTable
->
tableName
,
pTable
->
numOfRows
);
sdbTrace
(
"table:%s, is initialized, numOfRows:%d"
,
pTable
->
tableName
,
pTable
->
numOfRows
);
}
}
sdbTrace
(
"sdb is initialized, version:%d totalRows:%d numOfTables:%d"
,
tsSdb
Sync
->
version
,
totalRows
,
numOfTables
);
sdbTrace
(
"sdb is initialized, version:%d totalRows:%d numOfTables:%d"
,
tsSdb
Obj
->
version
,
totalRows
,
numOfTables
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
sdbCleanUp
()
{
void
sdbCleanUp
()
{
if
(
tsSdb
Sync
)
{
if
(
tsSdb
Obj
)
{
sem_destroy
(
&
tsSdb
Sync
->
sem
);
sem_destroy
(
&
tsSdb
Obj
->
sem
);
pthread_mutex_destroy
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_destroy
(
&
tsSdb
Obj
->
mutex
);
walClose
(
tsSdb
Sync
->
wal
);
walClose
(
tsSdb
Obj
->
wal
);
free
(
tsSdb
Sync
);
free
(
tsSdb
Obj
);
tsSdb
Sync
=
NULL
;
tsSdb
Obj
=
NULL
;
}
}
}
}
SSdbObject
*
sdbGetObj
()
{
return
tsSdbObj
;
}
void
sdbIncRef
(
void
*
handle
,
void
*
pRow
)
{
void
sdbIncRef
(
void
*
handle
,
void
*
pRow
)
{
if
(
pRow
)
{
if
(
pRow
)
{
SSdbTable
*
pTable
=
handle
;
SSdbTable
*
pTable
=
handle
;
...
@@ -278,20 +264,20 @@ static int32_t sdbUpdateLocal(SSdbTable *pTable, SSdbOperDesc *pOper) {
...
@@ -278,20 +264,20 @@ static int32_t sdbUpdateLocal(SSdbTable *pTable, SSdbOperDesc *pOper) {
static
int32_t
sdbProcessWriteFromApp
(
SSdbTable
*
pTable
,
SWalHead
*
pHead
,
int32_t
action
)
{
static
int32_t
sdbProcessWriteFromApp
(
SSdbTable
*
pTable
,
SWalHead
*
pHead
,
int32_t
action
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
pthread_mutex_lock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_lock
(
&
tsSdb
Obj
->
mutex
);
tsSdb
Sync
->
version
++
;
tsSdb
Obj
->
version
++
;
pHead
->
version
=
tsSdb
Sync
->
version
;
pHead
->
version
=
tsSdb
Obj
->
version
;
code
=
sdbForwardDbReqToPeer
(
pHead
);
code
=
sdbForwardDbReqToPeer
(
pHead
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
sdbError
(
"table:%s, failed to forward %s record:%s from file, version:%"
PRId64
", reason:%s"
,
pTable
->
tableName
,
sdbError
(
"table:%s, failed to forward %s record:%s from file, version:%"
PRId64
", reason:%s"
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
tstrerror
(
code
));
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
tstrerror
(
code
));
return
code
;
return
code
;
}
}
code
=
walWrite
(
tsSdb
Sync
->
wal
,
pHead
);
code
=
walWrite
(
tsSdb
Obj
->
wal
,
pHead
);
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
sdbError
(
"table:%s, failed to %s record:%s to file, version:%"
PRId64
", reason:%s"
,
pTable
->
tableName
,
sdbError
(
"table:%s, failed to %s record:%s to file, version:%"
PRId64
", reason:%s"
,
pTable
->
tableName
,
...
@@ -301,26 +287,26 @@ static int32_t sdbProcessWriteFromApp(SSdbTable *pTable, SWalHead *pHead, int32_
...
@@ -301,26 +287,26 @@ static int32_t sdbProcessWriteFromApp(SSdbTable *pTable, SWalHead *pHead, int32_
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
}
}
walFsync
(
tsSdb
Sync
->
wal
);
walFsync
(
tsSdb
Obj
->
wal
);
free
(
pHead
);
free
(
pHead
);
return
code
;
return
code
;
}
}
static
int32_t
sdbProcessWriteFromWal
(
SSdbTable
*
pTable
,
SWalHead
*
pHead
,
int32_t
action
)
{
static
int32_t
sdbProcessWriteFromWal
(
SSdbTable
*
pTable
,
SWalHead
*
pHead
,
int32_t
action
)
{
pthread_mutex_lock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_lock
(
&
tsSdb
Obj
->
mutex
);
if
(
pHead
->
version
<=
tsSdb
Sync
->
version
)
{
if
(
pHead
->
version
<=
tsSdb
Obj
->
version
)
{
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pHead
->
version
!=
tsSdb
Sync
->
version
+
1
)
{
}
else
if
(
pHead
->
version
!=
tsSdb
Obj
->
version
+
1
)
{
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
sdbError
(
"table:%s, failed to restore %s record:%s from file, version:%"
PRId64
" too large, sdb version:%"
PRId64
,
sdbError
(
"table:%s, failed to restore %s record:%s from file, version:%"
PRId64
" too large, sdb version:%"
PRId64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
,
tsSdb
Sync
->
version
);
tsSdb
Obj
->
version
);
return
TSDB_CODE_OTHERS
;
return
TSDB_CODE_OTHERS
;
}
}
tsSdb
Sync
->
version
=
pHead
->
version
;
tsSdb
Obj
->
version
=
pHead
->
version
;
sdbTrace
(
"table:%s, success to restore %s record:%s from file, version:%"
PRId64
,
pTable
->
tableName
,
sdbTrace
(
"table:%s, success to restore %s record:%s from file, version:%"
PRId64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
...
@@ -335,7 +321,7 @@ static int32_t sdbProcessWriteFromWal(SSdbTable *pTable, SWalHead *pHead, int32_
...
@@ -335,7 +321,7 @@ static int32_t sdbProcessWriteFromWal(SSdbTable *pTable, SWalHead *pHead, int32_
if
(
code
<
0
)
{
if
(
code
<
0
)
{
sdbTrace
(
"table:%s, failed to decode %s record:%s from file, version:%"
PRId64
,
pTable
->
tableName
,
sdbTrace
(
"table:%s, failed to decode %s record:%s from file, version:%"
PRId64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
return
code
;
return
code
;
}
}
...
@@ -369,17 +355,17 @@ static int32_t sdbProcessWriteFromWal(SSdbTable *pTable, SWalHead *pHead, int32_
...
@@ -369,17 +355,17 @@ static int32_t sdbProcessWriteFromWal(SSdbTable *pTable, SWalHead *pHead, int32_
if
(
code
<
0
)
{
if
(
code
<
0
)
{
sdbTrace
(
"table:%s, failed to decode %s record:%s from file, version:%"
PRId64
,
pTable
->
tableName
,
sdbTrace
(
"table:%s, failed to decode %s record:%s from file, version:%"
PRId64
,
pTable
->
tableName
,
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
sdbGetActionStr
(
action
),
sdbGetkeyStr
(
pTable
,
pHead
->
cont
),
pHead
->
version
);
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
return
code
;
return
code
;
}
}
code
=
sdbInsertLocal
(
pTable
,
&
oper2
);
code
=
sdbInsertLocal
(
pTable
,
&
oper2
);
}
}
pthread_mutex_unlock
(
&
tsSdb
Sync
->
mutex
);
pthread_mutex_unlock
(
&
tsSdb
Obj
->
mutex
);
return
code
;
return
code
;
}
}
static
int
sdbProcessWrite
(
void
*
param
,
void
*
data
,
int
type
)
{
int
sdbProcessWrite
(
void
*
param
,
void
*
data
,
int
type
)
{
SWalHead
*
pHead
=
data
;
SWalHead
*
pHead
=
data
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
int32_t
action
=
pHead
->
msgType
%
10
;
int32_t
action
=
pHead
->
msgType
%
10
;
...
@@ -426,7 +412,7 @@ int32_t sdbInsertRow(SSdbOperDesc *pOper) {
...
@@ -426,7 +412,7 @@ int32_t sdbInsertRow(SSdbOperDesc *pOper) {
(
*
pTable
->
encodeFp
)(
pOper
);
(
*
pTable
->
encodeFp
)(
pOper
);
pHead
->
len
=
pOper
->
rowSize
;
pHead
->
len
=
pOper
->
rowSize
;
int32_t
code
=
sdbProcessWrite
(
tsSdb
Sync
,
pHead
,
pHead
->
msgType
);
int32_t
code
=
sdbProcessWrite
(
tsSdb
Obj
,
pHead
,
pHead
->
msgType
);
if
(
code
<
0
)
return
code
;
if
(
code
<
0
)
return
code
;
}
}
...
@@ -453,6 +439,7 @@ int32_t sdbDeleteRow(SSdbOperDesc *pOper) {
...
@@ -453,6 +439,7 @@ int32_t sdbDeleteRow(SSdbOperDesc *pOper) {
case
SDB_KEY_STRING
:
case
SDB_KEY_STRING
:
rowSize
=
strlen
((
char
*
)
pOper
->
pObj
)
+
1
;
rowSize
=
strlen
((
char
*
)
pOper
->
pObj
)
+
1
;
break
;
break
;
case
SDB_KEY_INT
:
case
SDB_KEY_AUTO
:
case
SDB_KEY_AUTO
:
rowSize
=
sizeof
(
uint64_t
);
rowSize
=
sizeof
(
uint64_t
);
break
;
break
;
...
@@ -467,7 +454,7 @@ int32_t sdbDeleteRow(SSdbOperDesc *pOper) {
...
@@ -467,7 +454,7 @@ int32_t sdbDeleteRow(SSdbOperDesc *pOper) {
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_DELETE
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_DELETE
;
memcpy
(
pHead
->
cont
,
pOper
->
pObj
,
rowSize
);
memcpy
(
pHead
->
cont
,
pOper
->
pObj
,
rowSize
);
int32_t
code
=
sdbProcessWrite
(
tsSdb
Sync
,
pHead
,
pHead
->
msgType
);
int32_t
code
=
sdbProcessWrite
(
tsSdb
Obj
,
pHead
,
pHead
->
msgType
);
if
(
code
<
0
)
return
code
;
if
(
code
<
0
)
return
code
;
}
}
...
@@ -497,7 +484,7 @@ int32_t sdbUpdateRow(SSdbOperDesc *pOper) {
...
@@ -497,7 +484,7 @@ int32_t sdbUpdateRow(SSdbOperDesc *pOper) {
(
*
pTable
->
encodeFp
)(
pOper
);
(
*
pTable
->
encodeFp
)(
pOper
);
pHead
->
len
=
pOper
->
rowSize
;
pHead
->
len
=
pOper
->
rowSize
;
int32_t
code
=
sdbProcessWrite
(
tsSdb
Sync
,
pHead
,
pHead
->
msgType
);
int32_t
code
=
sdbProcessWrite
(
tsSdb
Obj
,
pHead
,
pHead
->
msgType
);
if
(
code
<
0
)
return
code
;
if
(
code
<
0
)
return
code
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录