mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
This commit is contained in:
parent
9e948196ed
commit
9b4a6eb577
2 changed files with 27 additions and 2 deletions
|
|
@ -582,8 +582,9 @@ func ReindexHistory() (err error) {
|
||||||
|
|
||||||
name := historyDir.Name()
|
name := historyDir.Name()
|
||||||
indexHistoryDir(name, lutEngine)
|
indexHistoryDir(name, lutEngine)
|
||||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(40), name))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sql.WaitForWritingHistoryDatabase()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ func FlushHistoryQueue() {
|
||||||
defer txLock.Unlock()
|
defer txLock.Unlock()
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBarAndProgress}
|
||||||
total := len(ops)
|
total := len(ops)
|
||||||
for i, op := range ops {
|
for i, op := range ops {
|
||||||
if util.IsExiting {
|
if util.IsExiting {
|
||||||
|
|
@ -137,3 +137,27 @@ func getHistoryOperations() (ops []*historyDBQueueOperation) {
|
||||||
historyOperationQueue = nil
|
historyOperationQueue = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WaitForWritingHistoryDatabase() {
|
||||||
|
var printLog bool
|
||||||
|
var lastPrintLog bool
|
||||||
|
for i := 0; isWritingHistoryDatabase(); i++ {
|
||||||
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
if 200 < i && !printLog { // 10s 后打日志
|
||||||
|
logging.LogWarnf("history database is writing: \n%s", logging.ShortStack())
|
||||||
|
printLog = true
|
||||||
|
}
|
||||||
|
if 1200 < i && !lastPrintLog { // 60s 后打日志
|
||||||
|
logging.LogWarnf("history database is still writing")
|
||||||
|
lastPrintLog = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isWritingHistoryDatabase() bool {
|
||||||
|
time.Sleep(util.SQLFlushInterval + 50*time.Millisecond)
|
||||||
|
if 0 < len(historyOperationQueue) || util.IsMutexLocked(&historyTxLock) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue