fix: flush database put to write end

This commit is contained in:
Alex Duan 2024-10-19 17:14:19 +08:00
parent dbd8d6891d
commit 528465ae21
1 changed files with 37 additions and 27 deletions

View File

@ -195,22 +195,28 @@ def findContextValue(context, label):
def writeTemplateInfo(resultFile): def writeTemplateInfo(resultFile):
# create info # create info
context = readFileContext(templateFile) context = readFileContext(templateFile)
dbname = findContextValue(context, "name")
vgroups = findContextValue(context, "vgroups") vgroups = findContextValue(context, "vgroups")
childCount = findContextValue(context, "childtable_count") childCount = findContextValue(context, "childtable_count")
insertRows = findContextValue(context, "insert_rows") insertRows = findContextValue(context, "insert_rows")
line = f"vgroups = {vgroups}\nchildtable_count = {childCount}\ninsert_rows = {insertRows}\n\n" line = f"vgroups = {vgroups}\nchildtable_count = {childCount}\ninsert_rows = {insertRows}\n\n"
print(line) print(line)
appendFileContext(resultFile, line) appendFileContext(resultFile, line)
return dbname
def totalCompressRate(algo, resultFile, writeSpeed, querySpeed): def totalCompressRate(algo, resultFile, writeSpeed, querySpeed):
global Number global Number
# flush loop = 30
while loop > 0:
loop -= 1
# flush database
command = 'taos -s "flush database dbrate;"' command = 'taos -s "flush database dbrate;"'
rets = exec(command) exec(command)
command = 'taos -s "compact database dbrate;"' time.sleep(1)
rets = exec(command)
waitCompactFinish(60)
# read compress rate # read compress rate
command = 'taos -s "show table distributed dbrate.meters\G;"' command = 'taos -s "show table distributed dbrate.meters\G;"'
@ -230,13 +236,14 @@ def totalCompressRate(algo, resultFile, writeSpeed, querySpeed):
pos = str2.find("=[") pos = str2.find("=[")
rate = str2[pos+2:] rate = str2[pos+2:]
print("rate =" + rate) print("rate =" + rate)
if rate != "0.00":
break
# total data file size # total data file size
#dataSize = getFolderSize(f"{dataDir}/vnode/") #dataSize = getFolderSize(f"{dataDir}/vnode/")
#dataSizeMB = int(dataSize/1024/1024) #dataSizeMB = int(dataSize/1024/1024)
# appand to file # appand to file
Number += 1 Number += 1
context = "%10s %10s %10s %10s %30s %15s\n"%( Number, algo, str(totalSize)+" MB", rate+"%", writeSpeed + " Records/second", querySpeed) context = "%10s %10s %10s %10s %30s %15s\n"%( Number, algo, str(totalSize)+" MB", rate+"%", writeSpeed + " Records/second", querySpeed)
showLog(context) showLog(context)
@ -268,6 +275,10 @@ def testWrite(jsonFile):
speed = context[pos: end] speed = context[pos: end]
#print(f"write pos ={pos} end={end} speed={speed}\n output={context} \n") #print(f"write pos ={pos} end={end} speed={speed}\n output={context} \n")
# flush database
command = 'taos -s "flush database dbrate;"'
exec(command)
return speed return speed
def testQuery(): def testQuery():
@ -295,7 +306,6 @@ def testQuery():
def doTest(algo, resultFile): def doTest(algo, resultFile):
print(f"doTest algo: {algo} \n") print(f"doTest algo: {algo} \n")
#cleanAndStartTaosd()
# json # json
jsonFile = generateJsonFile(algo) jsonFile = generateJsonFile(algo)