Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve kernel stability https://github.com/siyuan-note/siyuan/issues/9912

Danielb3d51ed94f29
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 35153b8355..aaa101fd1e 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"path/filepath"
+ "runtime/debug"
"strings"
"sync"
"sync/atomic"
@@ -168,6 +169,19 @@ func performTx(tx *Transaction) (ret *TxErr) {
return
}
+ defer func() {
+ if e := recover(); nil != e {
+ stack := debug.Stack()
+ msg := fmt.Sprintf("PANIC RECOVERED: %v\n\t%s\n", e, stack)
+ logging.LogErrorf(msg)
+
+ if 0 == tx.state.Load() {
+ tx.rollback()
+ return
+ }
+ }
+ }()
+
for _, op := range tx.DoOperations {
switch op.Action {
case "create":