Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4a24d4bf
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看板
提交
4a24d4bf
编写于
12月 20, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile error
上级
66b6e147
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
64 deletion
+68
-64
source/dnode/vnode/tq/src/tq.c
source/dnode/vnode/tq/src/tq.c
+3
-0
source/util/src/tlog.c
source/util/src/tlog.c
+65
-64
未找到文件。
source/dnode/vnode/tq/src/tq.c
浏览文件 @
4a24d4bf
...
...
@@ -56,6 +56,9 @@ STQ* tqOpen(const char* path, STqCfg* tqConfig, STqLogReader* tqLogReader, SMemA
}
return
pTq
;
}
void
tqClose
(
STQ
*
pTq
)
{
// TODO
}
static
int
tqProtoCheck
(
STqMsgHead
*
pMsg
)
{
return
pMsg
->
protoVer
==
0
;
}
...
...
source/util/src/tlog.c
浏览文件 @
4a24d4bf
...
...
@@ -14,21 +14,21 @@
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "ulog.h"
#include "tlog.h"
#include "os.h"
#include "tnote.h"
#include "tutil.h"
#include "ulog.h"
#include "zlib.h"
#define MAX_LOGLINE_SIZE
(1000)
#define MAX_LOGLINE_BUFFER_SIZE
(MAX_LOGLINE_SIZE + 10)
#define MAX_LOGLINE_CONTENT_SIZE
(MAX_LOGLINE_SIZE - 100)
#define MAX_LOGLINE_DUMP_SIZE
(65 * 1024)
#define MAX_LOGLINE_DUMP_BUFFER_SIZE
(MAX_LOGLINE_DUMP_SIZE + 10)
#define MAX_LOGLINE_SIZE (1000)
#define MAX_LOGLINE_BUFFER_SIZE (MAX_LOGLINE_SIZE + 10)
#define MAX_LOGLINE_CONTENT_SIZE (MAX_LOGLINE_SIZE - 100)
#define MAX_LOGLINE_DUMP_SIZE (65 * 1024)
#define MAX_LOGLINE_DUMP_BUFFER_SIZE (MAX_LOGLINE_DUMP_SIZE + 10)
#define MAX_LOGLINE_DUMP_CONTENT_SIZE (MAX_LOGLINE_DUMP_SIZE - 100)
#define LOG_FILE_NAME_LEN
300
#define LOG_FILE_NAME_LEN 300
#define TSDB_DEFAULT_LOG_BUF_SIZE (20 * 1024 * 1024) // 20MB
#define DEFAULT_LOG_INTERVAL 25
...
...
@@ -38,13 +38,13 @@
#define LOG_MAX_WAIT_MSEC 1000
#define LOG_BUF_BUFFER(x) ((x)->buffer)
#define LOG_BUF_START(x)
((x)->buffStart)
#define LOG_BUF_END(x)
((x)->buffEnd)
#define LOG_BUF_SIZE(x)
((x)->buffSize)
#define LOG_BUF_MUTEX(x)
((x)->buffMutex)
#define LOG_BUF_START(x) ((x)->buffStart)
#define LOG_BUF_END(x) ((x)->buffEnd)
#define LOG_BUF_SIZE(x) ((x)->buffSize)
#define LOG_BUF_MUTEX(x) ((x)->buffMutex)
typedef
struct
{
char
*
buffer
;
char
*
buffer
;
int32_t
buffStart
;
int32_t
buffEnd
;
int32_t
buffSize
;
...
...
@@ -57,18 +57,18 @@ typedef struct {
}
SLogBuff
;
typedef
struct
{
int32_t
fileNum
;
int32_t
maxLines
;
int32_t
lines
;
int32_t
flag
;
int32_t
openInProgress
;
pid_t
pid
;
char
logName
[
LOG_FILE_NAME_LEN
];
SLogBuff
*
logHandle
;
int32_t
fileNum
;
int32_t
maxLines
;
int32_t
lines
;
int32_t
flag
;
int32_t
openInProgress
;
pid_t
pid
;
char
logName
[
LOG_FILE_NAME_LEN
];
SLogBuff
*
logHandle
;
pthread_mutex_t
logMutex
;
}
SLogObj
;
int8_t
tscEmbeddedInUtil
=
0
;
int8_t
tscEmbeddedInUtil
=
0
;
int32_t
tsLogKeepDays
=
0
;
int8_t
tsAsyncLog
=
1
;
...
...
@@ -93,19 +93,19 @@ int32_t debugFlag = 0;
int32_t
sDebugFlag
=
135
;
int32_t
wDebugFlag
=
135
;
int32_t
tsdbDebugFlag
=
131
;
int32_t
tqDebugFlag
=
131
;
int32_t
cqDebugFlag
=
131
;
int32_t
fsDebugFlag
=
135
;
int32_t
ctgDebugFlag
=
131
;
int64_t
dbgEmptyW
=
0
;
int64_t
dbgWN
=
0
;
int64_t
dbgSmallWN
=
0
;
int64_t
dbgBigWN
=
0
;
int64_t
dbgWSize
=
0
;
static
SLogObj
tsLogObj
=
{
.
fileNum
=
1
};
static
void
*
taosAsyncOutputLog
(
void
*
param
);
static
SLogObj
tsLogObj
=
{
.
fileNum
=
1
};
static
void
*
taosAsyncOutputLog
(
void
*
param
);
static
int32_t
taosPushLogBuffer
(
SLogBuff
*
tLogBuff
,
char
*
msg
,
int32_t
msgLen
);
static
SLogBuff
*
taosLogBuffNew
(
int32_t
bufSize
);
static
void
taosCloseLogByFd
(
int32_t
oldFd
);
...
...
@@ -139,8 +139,8 @@ static void taosStopLog() {
void
taosCloseLog
()
{
taosStopLog
();
//tsem_post(&(tsLogObj.logHandle->buffNotEmpty));
taosMsleep
(
MAX_LOG_INTERVAL
/
1000
);
//
tsem_post(&(tsLogObj.logHandle->buffNotEmpty));
taosMsleep
(
MAX_LOG_INTERVAL
/
1000
);
if
(
taosCheckPthreadValid
(
tsLogObj
.
logHandle
->
asyncThread
))
{
pthread_join
(
tsLogObj
.
logHandle
->
asyncThread
,
NULL
);
}
...
...
@@ -217,7 +217,7 @@ static void *taosThreadToOpenNewFile(void *param) {
tsLogObj
.
lines
=
0
;
tsLogObj
.
openInProgress
=
0
;
taosCloseLogByFd
(
oldFd
);
uInfo
(
" new log file:%d is opened"
,
tsLogObj
.
flag
);
uInfo
(
"=================================="
);
taosPrintCfg
();
...
...
@@ -308,9 +308,9 @@ static void taosGetLogFileName(char *fn) {
static
int32_t
taosOpenLogFile
(
char
*
fn
,
int32_t
maxLines
,
int32_t
maxFileNum
)
{
#ifdef WINDOWS
/*
* always set maxFileNum to 1
* means client log filename is unique in windows
*/
* always set maxFileNum to 1
* means client log filename is unique in windows
*/
maxFileNum
=
1
;
#endif
...
...
@@ -381,13 +381,14 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
void
taosPrintLog
(
const
char
*
flags
,
int32_t
dflag
,
const
char
*
format
,
...)
{
if
(
tsTotalLogDirGB
!=
0
&&
tsAvailLogDirGB
<
tsMinimalLogDirGB
)
{
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop print log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop print log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
fflush
(
stdout
);
return
;
}
va_list
argpointer
;
char
buffer
[
MAX_LOGLINE_BUFFER_SIZE
]
=
{
0
};
char
buffer
[
MAX_LOGLINE_BUFFER_SIZE
]
=
{
0
};
int32_t
len
;
struct
tm
Tm
,
*
ptm
;
struct
timeval
timeSecs
;
...
...
@@ -434,20 +435,20 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) {
}
}
if
(
dflag
&
DEBUG_SCREEN
)
taosWriteFile
(
1
,
buffer
,
(
uint32_t
)
len
);
if
(
dflag
&
DEBUG_SCREEN
)
taosWriteFile
(
1
,
buffer
,
(
uint32_t
)
len
);
if
(
dflag
==
255
)
nInfo
(
buffer
,
len
);
}
void
taosDumpData
(
unsigned
char
*
msg
,
int32_t
len
)
{
if
(
tsTotalLogDirGB
!=
0
&&
tsAvailLogDirGB
<
tsMinimalLogDirGB
)
{
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop dump log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop dump log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
fflush
(
stdout
);
return
;
}
char
temp
[
256
];
int32_t
i
,
pos
=
0
,
c
=
0
;
char
temp
[
256
];
int32_t
i
,
pos
=
0
,
c
=
0
;
for
(
i
=
0
;
i
<
len
;
++
i
)
{
sprintf
(
temp
+
pos
,
"%02x "
,
msg
[
i
]);
...
...
@@ -468,7 +469,8 @@ void taosDumpData(unsigned char *msg, int32_t len) {
void
taosPrintLongString
(
const
char
*
flags
,
int32_t
dflag
,
const
char
*
format
,
...)
{
if
(
tsTotalLogDirGB
!=
0
&&
tsAvailLogDirGB
<
tsMinimalLogDirGB
)
{
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop write log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
printf
(
"server disk:%s space remain %.3f GB, total %.1f GB, stop write log.
\n
"
,
tsLogDir
,
tsAvailLogDirGB
,
tsTotalLogDirGB
);
fflush
(
stdout
);
return
;
}
...
...
@@ -503,7 +505,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, .
}
else
{
taosWriteFile
(
tsLogObj
.
logHandle
->
fd
,
buffer
,
len
);
}
if
(
tsLogObj
.
maxLines
>
0
)
{
atomic_add_fetch_32
(
&
tsLogObj
.
lines
,
1
);
...
...
@@ -542,7 +544,7 @@ static SLogBuff *taosLogBuffNew(int32_t bufSize) {
tLogBuff
->
stop
=
0
;
if
(
pthread_mutex_init
(
&
LOG_BUF_MUTEX
(
tLogBuff
),
NULL
)
<
0
)
goto
_err
;
//tsem_init(&(tLogBuff->buffNotEmpty), 0, 0);
//
tsem_init(&(tLogBuff->buffNotEmpty), 0, 0);
return
tLogBuff
;
...
...
@@ -576,12 +578,12 @@ static void taosCopyLogBuffer(SLogBuff *tLogBuff, int32_t start, int32_t end, ch
}
static
int32_t
taosPushLogBuffer
(
SLogBuff
*
tLogBuff
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
start
=
0
;
int32_t
end
=
0
;
int32_t
remainSize
=
0
;
int32_t
start
=
0
;
int32_t
end
=
0
;
int32_t
remainSize
=
0
;
static
int64_t
lostLine
=
0
;
char
tmpBuf
[
40
]
=
{
0
};
int32_t
tmpBufLen
=
0
;
char
tmpBuf
[
40
]
=
{
0
};
int32_t
tmpBufLen
=
0
;
if
(
tLogBuff
==
NULL
||
tLogBuff
->
stop
)
return
-
1
;
...
...
@@ -592,7 +594,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen)
remainSize
=
(
start
>
end
)
?
(
start
-
end
-
1
)
:
(
start
+
LOG_BUF_SIZE
(
tLogBuff
)
-
end
-
1
);
if
(
lostLine
>
0
)
{
sprintf
(
tmpBuf
,
"...Lost %"
PRId64
" lines here...
\n
"
,
lostLine
);
sprintf
(
tmpBuf
,
"...Lost %"
PRId64
" lines here...
\n
"
,
lostLine
);
tmpBufLen
=
(
int32_t
)
strlen
(
tmpBuf
);
}
...
...
@@ -610,7 +612,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen)
taosCopyLogBuffer
(
tLogBuff
,
LOG_BUF_START
(
tLogBuff
),
LOG_BUF_END
(
tLogBuff
),
msg
,
msgLen
);
//int32_t w = atomic_sub_fetch_32(&waitLock, 1);
//
int32_t w = atomic_sub_fetch_32(&waitLock, 1);
/*
if (w <= 0 || ((remainSize - msgLen - tmpBufLen) < (LOG_BUF_SIZE(tLogBuff) * 4 /5))) {
tsem_post(&(tLogBuff->buffNotEmpty));
...
...
@@ -622,7 +624,6 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen)
pthread_mutex_unlock
(
&
LOG_BUF_MUTEX
(
tLogBuff
));
return
0
;
}
...
...
@@ -634,9 +635,9 @@ static int32_t taosGetLogRemainSize(SLogBuff *tLogBuff, int32_t start, int32_t e
static
void
taosWriteLog
(
SLogBuff
*
tLogBuff
)
{
static
int32_t
lastDuration
=
0
;
int32_t
remainChecked
=
0
;
int32_t
start
,
end
,
pollSize
;
int32_t
remainChecked
=
0
;
int32_t
start
,
end
,
pollSize
;
do
{
if
(
remainChecked
==
0
)
{
start
=
LOG_BUF_START
(
tLogBuff
);
...
...
@@ -662,24 +663,24 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
if
(
start
<
end
)
{
taosWriteFile
(
tLogBuff
->
fd
,
LOG_BUF_BUFFER
(
tLogBuff
)
+
start
,
pollSize
);
}
else
{
int32_t
tsize
=
LOG_BUF_SIZE
(
tLogBuff
)
-
start
;
taosWriteFile
(
tLogBuff
->
fd
,
LOG_BUF_BUFFER
(
tLogBuff
)
+
start
,
tsize
);
int32_t
tsize
=
LOG_BUF_SIZE
(
tLogBuff
)
-
start
;
taosWriteFile
(
tLogBuff
->
fd
,
LOG_BUF_BUFFER
(
tLogBuff
)
+
start
,
tsize
);
taosWriteFile
(
tLogBuff
->
fd
,
LOG_BUF_BUFFER
(
tLogBuff
),
end
);
taosWriteFile
(
tLogBuff
->
fd
,
LOG_BUF_BUFFER
(
tLogBuff
),
end
);
}
dbgWN
++
;
dbgWSize
+=
pollSize
;
dbgWSize
+=
pollSize
;
if
(
pollSize
<
tLogBuff
->
minBuffSize
)
{
dbgSmallWN
++
;
if
(
writeInterval
<
MAX_LOG_INTERVAL
)
{
writeInterval
+=
LOG_INTERVAL_STEP
;
}
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
3
)
{
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
3
)
{
dbgBigWN
++
;
writeInterval
=
MIN_LOG_INTERVAL
;
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
4
)
{
}
else
if
(
pollSize
>
LOG_BUF_SIZE
(
tLogBuff
)
/
4
)
{
if
(
writeInterval
>
MIN_LOG_INTERVAL
)
{
writeInterval
-=
LOG_INTERVAL_STEP
;
}
...
...
@@ -698,13 +699,13 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
writeInterval
=
MIN_LOG_INTERVAL
;
remainChecked
=
1
;
}
while
(
1
);
}
while
(
1
);
}
static
void
*
taosAsyncOutputLog
(
void
*
param
)
{
SLogBuff
*
tLogBuff
=
(
SLogBuff
*
)
param
;
setThreadName
(
"log"
);
while
(
1
)
{
taosMsleep
(
writeInterval
);
...
...
@@ -721,8 +722,8 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) {
int32_t
compressSize
=
163840
;
int32_t
ret
=
0
;
int32_t
len
=
0
;
char
*
data
=
malloc
(
compressSize
);
FILE
*
srcFp
=
NULL
;
char
*
data
=
malloc
(
compressSize
);
FILE
*
srcFp
=
NULL
;
gzFile
dstFp
=
NULL
;
srcFp
=
fopen
(
srcFileName
,
"r"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录