From 248eecb87151d8f047411ad457bbcc9108f54a7d Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 9 Jan 2023 00:04:49 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=87=8D=E5=BB=BA=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E5=89=8D=E6=B8=85=E7=A9=BA=E6=95=B0=E6=8D=AE=E5=BA=93=E9=98=9F?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/sql/database.go | 1 + kernel/sql/queue.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/kernel/sql/database.go b/kernel/sql/database.go index 1f46dd6d5..35c83d946 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -64,6 +64,7 @@ func InitDatabase(forceRebuild bool) (err error) { util.IncBootProgress(2, "Initializing database...") if forceRebuild { + ClearQueue() WaitForWritingDatabase() } diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go index 02e796089..c9c71cfa2 100644 --- a/kernel/sql/queue.go +++ b/kernel/sql/queue.go @@ -85,6 +85,12 @@ func IsEmptyQueue() bool { return 1 > len(operationQueue) && !util.IsMutexLocked(&txLock) } +func ClearQueue() { + upsertTreeQueueLock.Lock() + defer upsertTreeQueueLock.Unlock() + operationQueue = nil +} + func flushTreeQueue() { ops := mergeUpsertTrees() if 1 > len(ops) {