🎨 细化云端同步锁提升稳定性 Fix https://github.com/siyuan-note/siyuan/issues/5887
This commit is contained in:
parent
a942ae6a1b
commit
b53cb6c78b
4 changed files with 20 additions and 2 deletions
|
@ -918,9 +918,12 @@ func loadNodesByMode(node *ast.Node, inputIndex, mode, size int, isDoc, isHeadin
|
|||
}
|
||||
|
||||
func writeJSONQueue(tree *parse.Tree) (err error) {
|
||||
writingDataLock.Lock()
|
||||
if err = filesys.WriteTree(tree); nil != err {
|
||||
writingDataLock.Unlock()
|
||||
return
|
||||
}
|
||||
writingDataLock.Unlock()
|
||||
sql.UpsertTreeQueue(tree)
|
||||
return
|
||||
}
|
||||
|
@ -931,9 +934,12 @@ func indexWriteJSONQueue(tree *parse.Tree) (err error) {
|
|||
}
|
||||
|
||||
func renameWriteJSONQueue(tree *parse.Tree, oldHPath string) (err error) {
|
||||
writingDataLock.Unlock()
|
||||
if err = filesys.WriteTree(tree); nil != err {
|
||||
writingDataLock.Unlock()
|
||||
return
|
||||
}
|
||||
writingDataLock.Unlock()
|
||||
sql.RenameTreeQueue(tree, oldHPath)
|
||||
treenode.ReindexBlockTree(tree)
|
||||
return
|
||||
|
|
|
@ -63,6 +63,9 @@ func SyncData(boot, exit, byHand bool) {
|
|||
return
|
||||
}
|
||||
|
||||
writingDataLock.Lock()
|
||||
defer writingDataLock.Unlock()
|
||||
|
||||
if util.IsMutexLocked(&syncLock) {
|
||||
logging.LogWarnf("sync is in progress")
|
||||
planSyncAfter(30 * time.Second)
|
||||
|
|
|
@ -110,9 +110,12 @@ func AutoFlushTx() {
|
|||
}
|
||||
}
|
||||
|
||||
var txLock = sync.Mutex{}
|
||||
|
||||
func flushTx() {
|
||||
writingDataLock.Lock()
|
||||
defer writingDataLock.Unlock()
|
||||
txLock.Lock()
|
||||
defer txLock.Unlock()
|
||||
|
||||
defer logging.Recover()
|
||||
|
||||
currentTx = mergeTx()
|
||||
|
|
|
@ -34,6 +34,9 @@ import (
|
|||
)
|
||||
|
||||
func InsertLocalAssets(id string, assetPaths []string) (succMap map[string]interface{}, err error) {
|
||||
writingDataLock.Lock()
|
||||
defer writingDataLock.Unlock()
|
||||
|
||||
succMap = map[string]interface{}{}
|
||||
|
||||
bt := treenode.GetBlockTree(id)
|
||||
|
@ -101,6 +104,9 @@ func Upload(c *gin.Context) {
|
|||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(200, ret)
|
||||
|
||||
writingDataLock.Lock()
|
||||
defer writingDataLock.Unlock()
|
||||
|
||||
form, err := c.MultipartForm()
|
||||
if nil != err {
|
||||
logging.LogErrorf("insert asset failed: %s", err)
|
||||
|
|
Loading…
Add table
Reference in a new issue