Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
949fbe3b
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看板
提交
949fbe3b
编写于
8月 18, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into refact/tsdb_last
上级
e75c4000
c7427474
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
84 addition
and
107 deletion
+84
-107
docs/zh/17-operation/03-tolerance.md
docs/zh/17-operation/03-tolerance.md
+0
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+3
-3
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+9
-8
source/libs/transport/src/thttp.c
source/libs/transport/src/thttp.c
+72
-94
未找到文件。
docs/zh/17-operation/03-tolerance.md
浏览文件 @
949fbe3b
...
...
@@ -26,5 +26,3 @@ TDengine 集群中的时序数据的副本数是与数据库关联的,一个
TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。
当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。
另外一种灾备方式是通过
`taosX`
将一个 TDengine 集群的数据同步复制到物理上位于不同数据中心的另一个 TDengine 集群。其详细使用方法请参考
[
taosX 参考手册
](
../../reference/taosX
)
source/common/src/tglobal.c
浏览文件 @
949fbe3b
...
...
@@ -75,7 +75,7 @@ int32_t tsMonitorMaxLogs = 100;
bool
tsMonitorComp
=
false
;
// telem
bool
tsEnableTelem
=
fals
e
;
bool
tsEnableTelem
=
tru
e
;
int32_t
tsTelemInterval
=
86400
;
char
tsTelemServer
[
TSDB_FQDN_LEN
]
=
"telemetry.taosdata.com"
;
uint16_t
tsTelemPort
=
80
;
...
...
@@ -166,7 +166,7 @@ int32_t tsTtlPushInterval = 86400;
int32_t
tsGrantHBInterval
=
60
;
#ifndef _STORAGE
int32_t
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
int32_t
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
memset
(
tsDataDir
,
0
,
PATH_MAX
);
...
...
@@ -180,7 +180,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) {
uError
(
"failed to create dataDir:%s"
,
tsDataDir
);
return
-
1
;
}
return
0
;
return
0
;
}
#else
int32_t
taosSetTfsCfg
(
SConfig
*
pCfg
);
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
949fbe3b
...
...
@@ -3970,16 +3970,16 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
TSKEY
*
ptsList
=
(
int64_t
*
)
colDataGetData
(
pCol
,
0
);
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
if
(
pCtx
->
start
.
key
==
INT64_MIN
)
{
pInfo
->
max
=
(
pInfo
->
max
<
ptsList
[
start
+
pInput
->
numOfRows
-
1
])
?
ptsList
[
start
+
pInput
->
numOfRows
-
1
]
:
pInfo
->
max
;
pInfo
->
max
=
(
pInfo
->
max
<
ptsList
[
start
])
?
ptsList
[
start
]
:
pInfo
->
max
;
}
else
{
pInfo
->
max
=
pCtx
->
start
.
key
+
1
;
}
if
(
pCtx
->
end
.
key
!=
INT64_MIN
)
{
pInfo
->
min
=
pCtx
->
end
.
key
;
if
(
pCtx
->
end
.
key
==
INT64_MIN
)
{
pInfo
->
min
=
(
pInfo
->
min
>
ptsList
[
start
+
pInput
->
numOfRows
-
1
])
?
ptsList
[
start
+
pInput
->
numOfRows
-
1
]
:
pInfo
->
min
;
}
else
{
pInfo
->
min
=
p
tsList
[
start
]
;
pInfo
->
min
=
p
Ctx
->
end
.
key
;
}
}
else
{
if
(
pCtx
->
start
.
key
==
INT64_MIN
)
{
...
...
@@ -3988,10 +3988,11 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
pInfo
->
min
=
pCtx
->
start
.
key
;
}
if
(
pCtx
->
end
.
key
!=
INT64_MIN
)
{
pInfo
->
max
=
pCtx
->
end
.
key
+
1
;
if
(
pCtx
->
end
.
key
==
INT64_MIN
)
{
pInfo
->
max
=
(
pInfo
->
max
<
ptsList
[
start
+
pInput
->
numOfRows
-
1
])
?
ptsList
[
start
+
pInput
->
numOfRows
-
1
]
:
pInfo
->
max
;
}
else
{
pInfo
->
max
=
p
tsList
[
start
+
pInput
->
numOfRows
-
1
]
;
pInfo
->
max
=
p
Ctx
->
end
.
key
+
1
;
}
}
}
...
...
source/libs/transport/src/thttp.c
浏览文件 @
949fbe3b
...
...
@@ -14,15 +14,22 @@
*/
#define _DEFAULT_SOURCE
#ifdef USE_UV
#include <uv.h>
#endif
// clang-format off
#include <uv.h>
#include "zlib.h"
#include "thttp.h"
#include "taoserror.h"
#include "tlog.h"
typedef
struct
SHttpClient
{
uv_connect_t
conn
;
uv_tcp_t
tcp
;
uv_write_t
req
;
uv_buf_t
*
buf
;
char
*
addr
;
uint16_t
port
;
}
SHttpClient
;
static
int32_t
taosBuildHttpHeader
(
const
char
*
server
,
int32_t
contLen
,
char
*
pHead
,
int32_t
headLen
,
EHttpCompFlag
flag
)
{
if
(
flag
==
HTTP_FLAT
)
{
...
...
@@ -45,7 +52,7 @@ static int32_t taosBuildHttpHeader(const char* server, int32_t contLen, char* pH
}
}
int32_t
taosCompressHttpRport
(
char
*
pSrc
,
int32_t
srcLen
)
{
static
int32_t
taosCompressHttpRport
(
char
*
pSrc
,
int32_t
srcLen
)
{
int32_t
code
=
-
1
;
int32_t
destLen
=
srcLen
;
void
*
pDest
=
taosMemoryMalloc
(
destLen
);
...
...
@@ -114,84 +121,53 @@ _OVER:
return
code
;
}
#ifdef USE_UV
static
void
destroyHttpClient
(
SHttpClient
*
cli
)
{
taosMemoryFree
(
cli
->
buf
);
taosMemoryFree
(
cli
->
addr
);
taosMemoryFree
(
cli
);
}
static
void
clientCloseCb
(
uv_handle_t
*
handle
)
{
SHttpClient
*
cli
=
handle
->
data
;
destroyHttpClient
(
cli
);
}
static
void
clientSentCb
(
uv_write_t
*
req
,
int32_t
status
)
{
SHttpClient
*
cli
=
req
->
data
;
if
(
status
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
status
);
uError
(
"http-report failed to send data %s"
,
uv_strerror
(
status
));
}
else
{
uInfo
(
"http-report succ to send data"
);
}
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
}
static
void
clientConnCb
(
uv_connect_t
*
req
,
int32_t
status
)
{
if
(
status
<
0
)
{
SHttpClient
*
cli
=
req
->
data
;
if
(
status
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
status
);
uError
(
"
connection error %s"
,
uv_strerror
(
status
)
);
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
uError
(
"
http-report failed to conn to server, reason:%s, dst:%s:%d"
,
uv_strerror
(
status
),
cli
->
addr
,
cli
->
port
);
uv_close
((
uv_handle_t
*
)
&
cli
->
tcp
,
clientCloseCb
);
return
;
}
uv_buf_t
*
wb
=
req
->
data
;
assert
(
wb
!=
NULL
);
uv_write_t
write_req
;
uv_write
(
&
write_req
,
req
->
handle
,
wb
,
2
,
NULL
);
uv_close
((
uv_handle_t
*
)
req
->
handle
,
NULL
);
uv_write
(
&
cli
->
req
,
(
uv_stream_t
*
)
&
cli
->
tcp
,
cli
->
buf
,
2
,
clientSentCb
);
}
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
uint32_t
ip
v4
=
taosGetIpv4FromFqdn
(
server
);
if
(
ip
v4
==
0xffffffff
)
{
static
int32_t
taosBuildDstAddr
(
const
char
*
server
,
uint16_t
port
,
struct
sockaddr_in
*
dest
)
{
uint32_t
ip
=
taosGetIpv4FromFqdn
(
server
);
if
(
ip
==
0xffffffff
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to get http server:%s ip since %s"
,
server
,
terrstr
());
uError
(
"
http-report
failed to get http server:%s ip since %s"
,
server
,
terrstr
());
return
-
1
;
}
char
ipv4Buf
[
128
]
=
{
0
};
tinet_ntoa
(
ipv4Buf
,
ipv4
);
struct
sockaddr_in
dest
=
{
0
};
uv_ip4_addr
(
ipv4Buf
,
port
,
&
dest
);
uv_tcp_t
socket_tcp
=
{
0
};
uv_loop_t
*
loop
=
uv_default_loop
();
uv_tcp_init
(
loop
,
&
socket_tcp
);
uv_connect_t
*
connect
=
(
uv_connect_t
*
)
taosMemoryMalloc
(
sizeof
(
uv_connect_t
));
if
(
flag
==
HTTP_GZIP
)
{
int32_t
dstLen
=
taosCompressHttpRport
(
pCont
,
contLen
);
if
(
dstLen
>
0
)
{
contLen
=
dstLen
;
}
else
{
flag
=
HTTP_FLAT
;
}
}
char
header
[
1024
]
=
{
0
};
int32_t
headLen
=
taosBuildHttpHeader
(
server
,
contLen
,
header
,
sizeof
(
header
),
flag
);
uv_buf_t
wb
[
2
];
wb
[
0
]
=
uv_buf_init
((
char
*
)
header
,
headLen
);
wb
[
1
]
=
uv_buf_init
((
char
*
)
pCont
,
contLen
);
connect
->
data
=
wb
;
terrno
=
0
;
uv_tcp_connect
(
connect
,
&
socket_tcp
,
(
const
struct
sockaddr
*
)
&
dest
,
clientConnCb
);
uv_run
(
loop
,
UV_RUN_DEFAULT
);
uv_loop_close
(
loop
);
taosMemoryFree
(
connect
);
return
terrno
;
char
buf
[
128
]
=
{
0
};
tinet_ntoa
(
buf
,
ip
);
uv_ip4_addr
(
buf
,
port
,
dest
);
return
0
;
}
#else
int32_t
taosSendHttpReport
(
const
char
*
server
,
uint16_t
port
,
char
*
pCont
,
int32_t
contLen
,
EHttpCompFlag
flag
)
{
int32_t
code
=
-
1
;
TdSocketPtr
pSocket
=
NULL
;
uint32_t
ip
=
taosGetIpv4FromFqdn
(
server
);
if
(
ip
==
0xffffffff
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to get http server:%s ip since %s"
,
server
,
terrstr
());
goto
SEND_OVER
;
}
pSocket
=
taosOpenTcpClientSocket
(
ip
,
port
,
0
);
if
(
pSocket
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to create http socket to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
struct
sockaddr_in
dest
=
{
0
};
if
(
taosBuildDstAddr
(
server
,
port
,
&
dest
)
<
0
)
{
return
-
1
;
}
if
(
flag
==
HTTP_GZIP
)
{
int32_t
dstLen
=
taosCompressHttpRport
(
pCont
,
contLen
);
if
(
dstLen
>
0
)
{
...
...
@@ -200,36 +176,38 @@ int32_t taosSendHttpReport(const char* server, uint16_t port, char* pCont, int32
flag
=
HTTP_FLAT
;
}
}
terrno
=
0
;
char
header
[
1024
]
=
{
0
};
char
header
[
2048
]
=
{
0
};
int32_t
headLen
=
taosBuildHttpHeader
(
server
,
contLen
,
header
,
sizeof
(
header
),
flag
);
if
(
taosWriteMsg
(
pSocket
,
header
,
headLen
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to send http header to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
}
if
(
taosWriteMsg
(
pSocket
,
(
void
*
)
pCont
,
contLen
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to send http content to %s:%u since %s"
,
server
,
port
,
terrstr
());
goto
SEND_OVER
;
}
uv_buf_t
*
wb
=
taosMemoryCalloc
(
2
,
sizeof
(
uv_buf_t
));
wb
[
0
]
=
uv_buf_init
((
char
*
)
header
,
headLen
);
// stack var
wb
[
1
]
=
uv_buf_init
((
char
*
)
pCont
,
contLen
);
// heap var
// read something to avoid nginx error 499
if
(
taosWriteMsg
(
pSocket
,
header
,
10
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
)
;
uError
(
"failed to receive response from %s:%u since %s"
,
server
,
port
,
terrstr
())
;
goto
SEND_OVER
;
}
c
ode
=
0
;
SHttpClient
*
cli
=
taosMemoryCalloc
(
1
,
sizeof
(
SHttpClient
));
cli
->
conn
.
data
=
cli
;
cli
->
tcp
.
data
=
cli
;
cli
->
req
.
data
=
cli
;
cli
->
buf
=
wb
;
cli
->
addr
=
tstrdup
(
server
);
c
li
->
port
=
port
;
SEND_OVER:
if
(
pSocket
!=
NULL
)
{
taosCloseSocket
(
&
pSocket
);
uv_loop_t
*
loop
=
uv_default_loop
();
uv_tcp_init
(
loop
,
&
cli
->
tcp
);
// set up timeout to avoid stuck;
int32_t
fd
=
taosCreateSocketWithTimeout
(
5
);
uv_tcp_open
((
uv_tcp_t
*
)
&
cli
->
tcp
,
fd
);
int32_t
ret
=
uv_tcp_connect
(
&
cli
->
conn
,
&
cli
->
tcp
,
(
const
struct
sockaddr
*
)
&
dest
,
clientConnCb
);
if
(
ret
!=
0
)
{
uError
(
"http-report failed to connect to server, reason:%s, dst:%s:%d"
,
uv_strerror
(
ret
),
cli
->
addr
,
cli
->
port
);
destroyHttpClient
(
cli
);
}
return
code
;
uv_run
(
loop
,
UV_RUN_DEFAULT
);
uv_loop_close
(
loop
);
return
terrno
;
}
// clang-format on
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录