提交 8fc5a0d6 编写于 作者: A Alex Duan

test: add first ignore log

上级 31828ae3
...@@ -78,13 +78,16 @@ class WalFile: ...@@ -78,13 +78,16 @@ class WalFile:
# VNode object # VNode object
class VNode : class VNode :
# init # init
def __init__(self, dnodeId, path, walPeriod, walSize): def __init__(self, dnodeId, path, walPeriod, walSize, walStayRange):
self.path = path self.path = path
self.dnodeId = dnodeId self.dnodeId = dnodeId
self.vgId = 0 self.vgId = 0
self.snapVer = 0 self.snapVer = 0
self.firstVer = 0
self.lastVer = -1
self.walPeriod = walPeriod self.walPeriod = walPeriod
self.walSize = walSize self.walSize = walSize
self.walStayRange = walStayRange
self.walFiles = [] self.walFiles = []
self.load(path) self.load(path)
...@@ -108,7 +111,9 @@ class VNode : ...@@ -108,7 +111,9 @@ class VNode :
if metaFile != "": if metaFile != "":
jsonVer = jsonFromFile(metaFile) jsonVer = jsonFromFile(metaFile)
metaNode = jsonVer["meta"] metaNode = jsonVer["meta"]
self.snapVer = int(metaNode["snapshotVer"]) self.snapVer = int(metaNode["snapshotVer"])
self.firstVer = int(metaNode["firstVer"])
self.lastVer = int(metaNode["lastVer"])
# sort with startVer # sort with startVer
self.walFiles = sorted(self.walFiles, key=lambda x : x.startVer, reverse=True) self.walFiles = sorted(self.walFiles, key=lambda x : x.startVer, reverse=True)
...@@ -122,7 +127,7 @@ class VNode : ...@@ -122,7 +127,7 @@ class VNode :
startVer = walFile.startVer startVer = walFile.startVer
# print total # print total
tdLog.info(f" ---- dnode{self.dnodeId} snapVer={self.snapVer} {self.path} --------") tdLog.info(f" ---- dnode{self.dnodeId} snapVer={self.snapVer} firstVer={self.firstVer} lastVer={self.lastVer} {self.path} --------")
for walFile in self.walFiles: for walFile in self.walFiles:
mt = datetime.fromtimestamp(walFile.mtime) mt = datetime.fromtimestamp(walFile.mtime)
tdLog.info(f" {walFile.pathFile} {mt} startVer={walFile.startVer} endVer={walFile.endVer}") tdLog.info(f" {walFile.pathFile} {mt} startVer={walFile.startVer} endVer={walFile.endVer}")
...@@ -132,10 +137,26 @@ class VNode : ...@@ -132,10 +137,26 @@ class VNode :
if walFile.endVer == -1: if walFile.endVer == -1:
# end file # end file
return False return False
# check snapVer
ret = False
if self.snapVer > walFile.endVer: if self.snapVer > walFile.endVer:
return True ret = True
return False
# check stayRange
if self.lastVer != -1 and ret:
# first wal file ignore
if walFile.startVer == self.firstVer:
tdLog.info(f" {walFile.pathFile} can del, but is first. snapVer={self.snapVer} firstVer={self.firstVer}")
return False
# ver in stay range
smallVer = self.snapVer - self.walStayRange -1
if walFile.startVer >= smallVer:
tdLog.info(f" {walFile.pathFile} can del, but range not arrived. snapVer={self.snapVer} smallVer={smallVer}")
return False
return ret
# get log size # get log size
def getWalsSize(self): def getWalsSize(self):
...@@ -341,7 +362,7 @@ class TDTestCase: ...@@ -341,7 +362,7 @@ class TDTestCase:
tdSql.execute(sql) tdSql.execute(sql)
#tdLog.info(sql) #tdLog.info(sql)
def check_retention(self): def check_retention(self, walStayRange):
# flash database # flash database
tdSql.execute(f"flush database {self.dbname}") tdSql.execute(f"flush database {self.dbname}")
time.sleep(0.5) time.sleep(0.5)
...@@ -359,7 +380,7 @@ class TDTestCase: ...@@ -359,7 +380,7 @@ class TDTestCase:
if os.path.isdir(entryPath): if os.path.isdir(entryPath):
if path.exists(path.join(entryPath, "vnode.json")): if path.exists(path.join(entryPath, "vnode.json")):
vnode = VNode(int(dnode[5:]), entryPath, self.wal_period, self.wal_size) vnode = VNode(int(dnode[5:]), entryPath, self.wal_period, self.wal_size, walStayRange)
vnodes.append(vnode) vnodes.append(vnode)
# do check # do check
...@@ -423,7 +444,7 @@ class TDTestCase: ...@@ -423,7 +444,7 @@ class TDTestCase:
# check retention # check retention
tdLog.info(f" -------------- do check retention ---------------") tdLog.info(f" -------------- do check retention ---------------")
self.check_retention() self.check_retention(walStayRange = 256)
# stop insert and wait exit # stop insert and wait exit
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册