Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve kernel stability by eliminating some data races https://github.com/siyuan-note/siyuan/issues/9842

Daniel8715578bca62
diff --git a/kernel/model/box.go b/kernel/model/box.go
index 4ee696cd88..58076f9c42 100644
--- a/kernel/model/box.go
+++ b/kernel/model/box.go
@@ -26,7 +26,6 @@ import (
"runtime/debug"
"sort"
"strings"
- "sync"
"time"
"github.com/88250/gulu"
@@ -61,12 +60,9 @@ type Box struct {
historyGenerated int64 // 最近一次历史生成时间
}
-var statLock = sync.Mutex{}
-
func StatJob() {
- statLock.Lock()
- defer statLock.Unlock()
+ Conf.m.Lock()
Conf.Stat.TreeCount = treenode.CountTrees()
Conf.Stat.CTreeCount = treenode.CeilTreeCount(Conf.Stat.TreeCount)
Conf.Stat.BlockCount = treenode.CountBlocks()
@@ -74,6 +70,7 @@ func StatJob() {
Conf.Stat.DataSize, Conf.Stat.AssetsSize = util.DataSize()
Conf.Stat.CDataSize = util.CeilSize(Conf.Stat.DataSize)
Conf.Stat.CAssetsSize = util.CeilSize(Conf.Stat.AssetsSize)
+ Conf.m.Unlock()
Conf.Save()
logging.LogInfof("auto stat [trees=%d, blocks=%d, dataSize=%s, assetsSize=%s]", Conf.Stat.TreeCount, Conf.Stat.BlockCount, humanize.Bytes(uint64(Conf.Stat.DataSize)), humanize.Bytes(uint64(Conf.Stat.AssetsSize)))