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