🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-24 21:05:32 +08:00
parent 6d100464dd
commit e8fe3a77b3
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 23 additions and 12 deletions

View file

@ -38,7 +38,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"golang.org/x/text/language"
@ -422,7 +421,6 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
}
}
task.CloseWait()
Conf.Close()
sql.CloseDatabase()
treenode.SaveBlockTree(false)

View file

@ -1303,6 +1303,13 @@ func autoFixIndex() {
}
reindexTreeByPath(box.ID, p, i, size)
if util.IsExiting {
break
}
}
if util.IsExiting {
break
}
}
@ -1347,6 +1354,10 @@ func autoFixIndex() {
logging.LogWarnf("exist more than one tree [%s], reindex it", rootID)
sql.RemoveTreeQueue(root.Box, rootID)
reindexTree(rootID, i, size)
if util.IsExiting {
break
}
}
util.PushStatusBar(Conf.Language(185))
@ -1358,6 +1369,10 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string, bl
for rootID, updated := range rootUpdatedMap {
i++
if util.IsExiting {
break
}
rootUpdated := dbRootUpdatedMap[rootID]
if "" == rootUpdated {
logging.LogWarnf("not found tree [%s] in database, reindex it", rootID)
@ -1378,6 +1393,10 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string, bl
reindexTree(rootID, i, size)
continue
}
if util.IsExiting {
break
}
}
for rootID, _ := range dbRootUpdatedMap {
@ -1385,6 +1404,10 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string, bl
logging.LogWarnf("tree [%s] is not in block tree, remove it from [%s]", rootID, blocksTable)
sql.DeleteTree(blocksTable, rootID)
}
if util.IsExiting {
break
}
}
}

View file

@ -161,16 +161,6 @@ func Loop() {
}
}
func CloseWait() {
taskQueueStatus = QueueStatusClosing
for {
time.Sleep(10 * time.Millisecond)
if 1 > len(taskQueue) {
break
}
}
}
func clearQueue() {
queueLock.Lock()
defer queueLock.Unlock()