mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 14:32:34 +08:00
🐛 Index fixing should not be performed before data synchronization https://github.com/siyuan-note/siyuan/issues/10761
This commit is contained in:
parent
2c1e8966e7
commit
0322e022f1
@ -48,7 +48,6 @@ func main() {
|
|||||||
util.PushClearAllMsg()
|
util.PushClearAllMsg()
|
||||||
|
|
||||||
job.StartCron()
|
job.StartCron()
|
||||||
go model.CheckIndex()
|
|
||||||
go model.AutoGenerateDocHistory()
|
go model.AutoGenerateDocHistory()
|
||||||
go cache.LoadAssets()
|
go cache.LoadAssets()
|
||||||
go util.CheckFileSysStatus()
|
go util.CheckFileSysStatus()
|
||||||
|
@ -64,7 +64,6 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang
|
|||||||
util.PushClearAllMsg()
|
util.PushClearAllMsg()
|
||||||
|
|
||||||
job.StartCron()
|
job.StartCron()
|
||||||
go model.CheckIndex()
|
|
||||||
go model.AutoGenerateDocHistory()
|
go model.AutoGenerateDocHistory()
|
||||||
go cache.LoadAssets()
|
go cache.LoadAssets()
|
||||||
}()
|
}()
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
@ -40,8 +41,18 @@ import (
|
|||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CheckIndex 自动校验数据库索引 https://github.com/siyuan-note/siyuan/issues/7016 https://github.com/siyuan-note/siyuan/issues/10563
|
var (
|
||||||
func CheckIndex() {
|
checkIndexPerformed = atomic.Bool{}
|
||||||
|
)
|
||||||
|
|
||||||
|
// checkIndex 自动校验数据库索引,仅在数据同步执行完成后执行一次。
|
||||||
|
func checkIndex() {
|
||||||
|
if checkIndexPerformed.Load() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.LogInfof("start checking index...")
|
||||||
|
|
||||||
task.AppendTask(task.DatabaseIndexFix, removeDuplicateDatabaseIndex)
|
task.AppendTask(task.DatabaseIndexFix, removeDuplicateDatabaseIndex)
|
||||||
sql.WaitForWritingDatabase()
|
sql.WaitForWritingDatabase()
|
||||||
|
|
||||||
@ -61,6 +72,9 @@ func CheckIndex() {
|
|||||||
util.PushStatusBar(Conf.Language(185))
|
util.PushStatusBar(Conf.Language(185))
|
||||||
})
|
})
|
||||||
debug.FreeOSMemory()
|
debug.FreeOSMemory()
|
||||||
|
logging.LogInfof("finish checking index")
|
||||||
|
|
||||||
|
checkIndexPerformed.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
var autoFixLock = sync.Mutex{}
|
var autoFixLock = sync.Mutex{}
|
||||||
|
@ -1330,6 +1330,9 @@ func syncRepo(exit, byHand bool) (dataChanged bool, err error) {
|
|||||||
autoSyncErrCount = 0
|
autoSyncErrCount = 0
|
||||||
|
|
||||||
processSyncMergeResult(exit, byHand, mergeResult, trafficStat, "a", elapsed)
|
processSyncMergeResult(exit, byHand, mergeResult, trafficStat, "a", elapsed)
|
||||||
|
|
||||||
|
// 首次数据同步执行完成后再执行索引订正 Index fixing should not be performed before data synchronization https://github.com/siyuan-note/siyuan/issues/10761
|
||||||
|
checkIndex()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user