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

This commit is contained in:
Liang Ding 2023-01-25 20:46:17 +08:00
parent a4d779258c
commit fdc2f19eaa
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
9 changed files with 16 additions and 15 deletions

View file

@ -151,7 +151,7 @@ func prepareWriteTree(tree *parse.Tree) (data []byte, filePath string, err error
newP := parse.NewParagraph()
tree.Root.AppendChild(newP)
tree.Root.SetIALAttr("updated", util.TimeFromID(newP.ID))
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
}
filePath = filepath.Join(util.DataDir, tree.Box, tree.Path)

View file

@ -535,7 +535,7 @@ func RenameAsset(oldPath, newName string) (err error) {
return
}
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
sql.UpsertTreeQueue(tree)
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), tree.Root.IALAttr("title")))

View file

@ -197,12 +197,12 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
}
refPivot.Unlink()
treenode.ReindexBlockTree(refTree)
treenode.IndexBlockTree(refTree)
if err = writeJSONQueue(refTree); nil != err {
return
}
if !sameTree {
treenode.ReindexBlockTree(defTree)
treenode.IndexBlockTree(defTree)
if err = writeJSONQueue(defTree); nil != err {
return
}

View file

@ -874,12 +874,12 @@ func writeJSONQueueWithoutChangeTime(tree *parse.Tree) (err error) {
}
func indexWriteJSONQueue(tree *parse.Tree) (err error) {
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
return writeJSONQueue(tree)
}
func indexWriteJSONQueueWithoutChangeTime(tree *parse.Tree) (err error) {
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
return writeJSONQueueWithoutChangeTime(tree)
}
@ -888,7 +888,7 @@ func renameWriteJSONQueue(tree *parse.Tree, oldHPath string) (err error) {
return
}
sql.RenameTreeQueue(tree, oldHPath)
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
return
}

View file

@ -393,7 +393,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
continue
}
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
sql.UpsertTreeQueue(tree)
}

View file

@ -112,7 +112,7 @@ func index(boxID string) {
}
cache.PutDocIAL(file.path, docIAL)
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
sql.IndexTreeQueue(box.ID, file.path)
util.IncBootProgress(bootProgressPart, fmt.Sprintf(Conf.Language(92), util.ShortPathForBootingDisplay(tree.Path)))

View file

@ -253,7 +253,7 @@ func incReindex(upserts, removes []string) {
if nil != err0 {
continue
}
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
sql.UpsertTreeQueue(tree)
}

View file

@ -1093,7 +1093,7 @@ func (tx *Transaction) loadTree(id string) (ret *parse.Tree, err error) {
func (tx *Transaction) writeTree(tree *parse.Tree) (err error) {
tx.trees[tree.ID] = tree
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
return
}
@ -1446,7 +1446,7 @@ func reindexTree0(tree *parse.Tree, i, size int) {
tree.Root.SetIALAttr("updated", updated)
indexWriteJSONQueue(tree)
} else {
treenode.ReindexBlockTree(tree)
treenode.IndexBlockTree(tree)
sql.IndexTreeQueue(tree.Box, tree.Path)
}

View file

@ -45,6 +45,7 @@ type BlockTree struct {
Path string // 文档数据路径
HPath string // 文档可读路径
Updated string // 更新时间
Type string // 类型
}
func GetRootUpdated() (ret map[string]string) {
@ -206,7 +207,7 @@ func SetBlockTreePath(tree *parse.Tree) {
for _, b := range blockTrees {
if b.RootID == tree.ID {
b.BoxID, b.Path, b.HPath, b.Updated = tree.Box, tree.Path, tree.HPath, tree.Root.IALAttr("updated")
b.BoxID, b.Path, b.HPath, b.Updated, b.Type = tree.Box, tree.Path, tree.HPath, tree.Root.IALAttr("updated"), TypeAbbr(ast.NodeDocument.String())
}
}
blockTreesChanged = time.Now()
@ -288,7 +289,7 @@ func RemoveBlockTree(id string) {
blockTreesChanged = time.Now()
}
func ReindexBlockTree(tree *parse.Tree) {
func IndexBlockTree(tree *parse.Tree) {
blockTreesLock.Lock()
defer blockTreesLock.Unlock()
@ -303,7 +304,7 @@ func ReindexBlockTree(tree *parse.Tree) {
if "" == n.ID {
return ast.WalkContinue
}
blockTrees[n.ID] = &BlockTree{ID: n.ID, ParentID: parentID, RootID: tree.ID, BoxID: tree.Box, Path: tree.Path, HPath: tree.HPath, Updated: tree.Root.IALAttr("updated")}
blockTrees[n.ID] = &BlockTree{ID: n.ID, ParentID: parentID, RootID: tree.ID, BoxID: tree.Box, Path: tree.Path, HPath: tree.HPath, Updated: tree.Root.IALAttr("updated"), Type: TypeAbbr(n.Type.String())}
return ast.WalkContinue
})
blockTreesChanged = time.Now()