Ver código fonte

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

Liang Ding 2 anos atrás
pai
commit
248eecb871
2 arquivos alterados com 7 adições e 0 exclusões
  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...")
 
 	if forceRebuild {
+		ClearQueue()
 		WaitForWritingDatabase()
 	}
 

+ 6 - 0
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) {