瀏覽代碼

:art: 重建索引前清空数据库队列

Liang Ding 2 年之前
父節點
當前提交
248eecb871
共有 2 個文件被更改,包括 7 次插入0 次删除
  1. 1 0
      kernel/sql/database.go
  2. 6 0
      kernel/sql/queue.go

+ 1 - 0
kernel/sql/database.go

@@ -64,6 +64,7 @@ func InitDatabase(forceRebuild bool) (err error) {
 	util.IncBootProgress(2, "Initializing database...")
 	util.IncBootProgress(2, "Initializing database...")
 
 
 	if forceRebuild {
 	if forceRebuild {
+		ClearQueue()
 		WaitForWritingDatabase()
 		WaitForWritingDatabase()
 	}
 	}
 
 

+ 6 - 0
kernel/sql/queue.go

@@ -85,6 +85,12 @@ func IsEmptyQueue() bool {
 	return 1 > len(operationQueue) && !util.IsMutexLocked(&txLock)
 	return 1 > len(operationQueue) && !util.IsMutexLocked(&txLock)
 }
 }
 
 
+func ClearQueue() {
+	upsertTreeQueueLock.Lock()
+	defer upsertTreeQueueLock.Unlock()
+	operationQueue = nil
+}
+
 func flushTreeQueue() {
 func flushTreeQueue() {
 	ops := mergeUpsertTrees()
 	ops := mergeUpsertTrees()
 	if 1 > len(ops) {
 	if 1 > len(ops) {