From aeb09cb0f64da101e78bec9ac40cdd13208381b6 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 10 Mar 2024 18:10:45 +0800 Subject: [PATCH] :art: Automatic check of database indexes is only performed once after startup https://github.com/siyuan-note/siyuan/issues/10563 --- kernel/job/cron.go | 1 - kernel/main.go | 1 + kernel/mobile/kernel.go | 1 + kernel/model/index_fix.go | 4 ++-- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/job/cron.go b/kernel/job/cron.go index a6206877e68..d4c86ef2933 100644 --- a/kernel/job/cron.go +++ b/kernel/job/cron.go @@ -38,7 +38,6 @@ func StartCron() { go every(util.SQLFlushInterval, sql.FlushTxJob) go every(util.SQLFlushInterval, sql.FlushHistoryTxJob) go every(util.SQLFlushInterval, sql.FlushAssetContentTxJob) - go every(10*time.Minute, model.FixIndexJob) go every(10*time.Minute, model.IndexEmbedBlockJob) go every(10*time.Minute, model.CacheVirtualBlockRefJob) go every(30*time.Second, model.OCRAssetsJob) diff --git a/kernel/main.go b/kernel/main.go index a1021717a52..0d294866514 100644 --- a/kernel/main.go +++ b/kernel/main.go @@ -48,6 +48,7 @@ func main() { util.PushClearAllMsg() job.StartCron() + go model.CheckIndex() go model.AutoGenerateDocHistory() go cache.LoadAssets() go util.CheckFileSysStatus() diff --git a/kernel/mobile/kernel.go b/kernel/mobile/kernel.go index 624fbb55e43..adc6a0bf131 100644 --- a/kernel/mobile/kernel.go +++ b/kernel/mobile/kernel.go @@ -63,6 +63,7 @@ func StartKernel(container, appDir, workspaceBaseDir, timezoneID, localIPs, lang util.PushClearAllMsg() job.StartCron() + go model.CheckIndex() go model.AutoGenerateDocHistory() go cache.LoadAssets() }() diff --git a/kernel/model/index_fix.go b/kernel/model/index_fix.go index db58ccbe171..c3ff3c31795 100644 --- a/kernel/model/index_fix.go +++ b/kernel/model/index_fix.go @@ -40,8 +40,8 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) -// FixIndexJob 自动校验数据库索引 https://github.com/siyuan-note/siyuan/issues/7016 -func FixIndexJob() { +// CheckIndex 自动校验数据库索引 https://github.com/siyuan-note/siyuan/issues/7016 https://github.com/siyuan-note/siyuan/issues/10563 +func CheckIndex() { task.AppendTask(task.DatabaseIndexFix, removeDuplicateDatabaseIndex) sql.WaitForWritingDatabase()