{"record":{"id":"ba831f86f07c87a8","repo":"siyuan-note/siyuan","slug":"conf-language-239","errorCode":null,"errorMessage":"Conf.Language(239)","messagePattern":"Conf\\.Language\\(239\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/history.go","lineNumber":653,"sourceCode":"\tencrypted, err := isEncryptedHistoryBoxDir(filepath.Join(util.HistoryDir, parts[0], boxID))\n\tif err != nil {\n\t\tlogging.LogErrorf(\"inspect encrypted history path [%s] failed: %s\", absPath, err)\n\t\treturn true\n\t}\n\treturn encrypted\n}\n\nfunc RollbackNotebookHistory(historyPath string) (err error) {\n\thistoryPath, err = validateHistoryPath(historyPath)\n\tif err != nil {\n\t\treturn\n\t}\n\tboxID, err := validateNotebookHistoryPath(historyPath)\n\tif err != nil {\n\t\treturn\n\t}\n\tif _, loaded := boxLock.LoadOrStore(boxID, true); loaded {\n\t\treturn errors.New(Conf.Language(239))\n\t}\n\tdefer boxLock.Delete(boxID)\n\n\tfrom := historyPath\n\tto := filepath.Join(util.DataDir, boxID)\n\tif filelock.IsExist(to) {\n\t\treturn errors.New(Conf.Language(371))\n\t}\n\n\tif err = filelock.CopyNewtimes(from, to); err != nil {\n\t\tlogging.LogErrorf(\"copy file [%s] to [%s] failed: %s\", from, to, err)\n\t\treturn\n\t}\n\n\tIncSync()\n\tReloadFiletree()\n\tutil.PushMsg(Conf.Language(372), 3000)\n\treturn nil","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/history.go#L635-L671","documentation":"RollbackNotebookHistory uses a per-box mutex (boxLock with LoadOrStore) to prevent concurrent rollbacks of the same notebook. If a rollback for that boxID is already in flight, the second call immediately fails with the localized message Conf.Language(239), which tells the user the notebook history is currently being rolled back.","triggerScenarios":"Invoking RollbackNotebookHistory twice concurrently for the same notebook — e.g. double-clicking the rollback button, parallel API calls, or a script racing the UI.","commonSituations":"Automated scripts issuing overlapping rollback requests; slow rollback (large notebook) causing users to retry; multiple clients connected to the same workspace.","solutions":["Wait for the in-flight rollback to finish and retry once","Serialize notebook rollback calls in the caller (single-flight / queue per boxID)","Disable the rollback button/entry while a rollback request is pending in the UI"],"exampleFix":"// before\nPromise.all([rollbackNotebookHistory(p), rollbackNotebookHistory(p)])\n// after\nawait rollbackNotebookHistory(p); // await before issuing again","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await rollbackNotebookHistory(p); } catch (e) { if (isBusyNotebookMessage(e)) { await sleep(1000); await rollbackNotebookHistory(p); } else { throw e; } }","preventionTips":["Disable the rollback action while a rollback request is in flight","Use a single-flight queue per notebook ID on the client side","Inform users that large rollbacks take time instead of allowing retries"],"tags":["history","concurrency","notebook","lock"],"backgroundTag":"invalid-state-transition","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}