diff --git a/kernel/model/bookmark.go b/kernel/model/bookmark.go index 5dd1ac861..64db0b445 100644 --- a/kernel/model/bookmark.go +++ b/kernel/model/bookmark.go @@ -160,7 +160,9 @@ func BookmarkLabels() (ret []string) { func BuildBookmark() (ret *Bookmarks) { WaitForWritingFiles() - sql.WaitForWritingDatabase() + if !sql.IsEmptyQueue() { + sql.WaitForWritingDatabase() + } ret = &Bookmarks{} sqlBlocks := sql.QueryBookmarkBlocks() diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go index afc88d467..02e796089 100644 --- a/kernel/sql/queue.go +++ b/kernel/sql/queue.go @@ -81,6 +81,10 @@ func isWritingDatabase() bool { return false } +func IsEmptyQueue() bool { + return 1 > len(operationQueue) && !util.IsMutexLocked(&txLock) +} + func flushTreeQueue() { ops := mergeUpsertTrees() if 1 > len(ops) {