未验证 提交 d5c4d388 编写于 作者: W wade zhang 提交者: GitHub

Merge pull request #22535 from taosdata/fix/TS-3831-MAIN

fix: query failed return time from websocket is last successful time
...@@ -147,13 +147,13 @@ class VNode : ...@@ -147,13 +147,13 @@ class VNode :
if self.lastVer != -1 and ret: if self.lastVer != -1 and ret:
# first wal file ignore # first wal file ignore
if walFile.startVer == self.firstVer: if walFile.startVer == self.firstVer:
tdLog.info(f" {walFile.pathFile} can del, but is first. snapVer={self.snapVer} firstVer={self.firstVer}") tdLog.info(f" can del {walFile.pathFile}, but is first. snapVer={self.snapVer} firstVer={self.firstVer}")
return False return False
# ver in stay range # ver in stay range
smallVer = self.snapVer - self.walStayRange -1 smallVer = self.snapVer - self.walStayRange -1
if walFile.startVer >= smallVer: if walFile.startVer >= smallVer:
tdLog.info(f" {walFile.pathFile} can del, but range not arrived. snapVer={self.snapVer} smallVer={smallVer}") tdLog.info(f" can del {walFile.pathFile}, but range not arrived. snapVer={self.snapVer} smallVer={smallVer}")
return False return False
return ret return ret
...@@ -161,9 +161,20 @@ class VNode : ...@@ -161,9 +161,20 @@ class VNode :
# get log size # get log size
def getWalsSize(self): def getWalsSize(self):
size = 0 size = 0
lastSize = 0
max = -1
for walFile in self.walFiles: for walFile in self.walFiles:
size += walFile.fsize if self.canDelete(walFile) == False:
tdLog.info(f" calc vnode size {walFile.pathFile} size={walFile.fsize} startVer={walFile.startVer}")
size += walFile.fsize
if max < walFile.startVer:
max = walFile.startVer
lastSize = walFile.fsize
if lastSize > 0:
tdLog.info(f" last file size need reduct . lastSize={lastSize}")
size -= lastSize
return size return size
# vnode # vnode
...@@ -183,7 +194,7 @@ class VNode : ...@@ -183,7 +194,7 @@ class VNode :
delTs = delTsLine.timestamp() delTs = delTsLine.timestamp()
for walFile in self.walFiles: for walFile in self.walFiles:
mt = datetime.fromtimestamp(walFile.mtime) mt = datetime.fromtimestamp(walFile.mtime)
info = f" {walFile.pathFile} mt={mt} line={delTsLine} start={walFile.startVer} snap={self.snapVer} end= {walFile.endVer}" info = f" {walFile.pathFile} size={walFile.fsize} mt={mt} line={delTsLine} start={walFile.startVer} snap={self.snapVer} end= {walFile.endVer}"
tdLog.info(info) tdLog.info(info)
if walFile.mtime < delTs and self.canDelete(walFile): if walFile.mtime < delTs and self.canDelete(walFile):
# wait a moment then check file exist # wait a moment then check file exist
...@@ -199,25 +210,16 @@ class VNode : ...@@ -199,25 +210,16 @@ class VNode :
if self.walSize == 0: if self.walSize == 0:
return True return True
time.sleep(2)
vnodeSize = self.getWalsSize() vnodeSize = self.getWalsSize()
if vnodeSize < self.walSize: # need over 20%
tdLog.info(f" wal size valid. {self.path} real = {vnodeSize} set = {self.walSize} ") if vnodeSize < self.walSize * 1.2:
tdLog.info(f" wal size valid. {self.path} real = {vnodeSize} set = {self.walSize}. allow over 20%.")
return True return True
# check valid # check over
tdLog.info(f" wal size over set. {self.path} real = {vnodeSize} set = {self.walSize} ") tdLog.exit(f" wal size over set. {self.path} real = {vnodeSize} set = {self.walSize} ")
for walFile in self.walFiles: return False
if self.canDelete(walFile):
# wait a moment then check file exist
time.sleep(1)
if os.path.exists(walFile.pathFile):
tdLog.exit(f" wal file size over .\
\n wal file = {walFile.pathFile}\
\n snapVer = {self.snapVer}\
\n real = {vnodeSize} bytes\
\n set = {self.walSize} bytes")
return False
return True
# insert by async # insert by async
......
...@@ -278,7 +278,7 @@ void shellRunSingleCommandWebsocketImp(char *command) { ...@@ -278,7 +278,7 @@ void shellRunSingleCommandWebsocketImp(char *command) {
} }
if (code == TSDB_CODE_WS_SEND_TIMEOUT if (code == TSDB_CODE_WS_SEND_TIMEOUT
|| code == TSDB_CODE_WS_RECV_TIMEOUT) { || code == TSDB_CODE_WS_RECV_TIMEOUT) {
fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); fprintf(stderr, "Hint: use -T to increase the timeout in seconds\n");
} else if (code == TSDB_CODE_WS_INTERNAL_ERRO } else if (code == TSDB_CODE_WS_INTERNAL_ERRO
|| code == TSDB_CODE_WS_CLOSED) { || code == TSDB_CODE_WS_CLOSED) {
shell.ws_conn = NULL; shell.ws_conn = NULL;
...@@ -373,8 +373,6 @@ void shellRunSingleCommandWebsocketImp(char *command) { ...@@ -373,8 +373,6 @@ void shellRunSingleCommandWebsocketImp(char *command) {
} else { } else {
printf("Query interrupted, %d row(s) in set (%.6fs)\n", numOfRows, printf("Query interrupted, %d row(s) in set (%.6fs)\n", numOfRows,
(et - st)/1E6); (et - st)/1E6);
printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n",
execute_time, net_time, total_time);
} }
} }
printf("\n"); printf("\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册