🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
This commit is contained in:
parent
6649220283
commit
4916baf31a
8 changed files with 38 additions and 32 deletions
|
@ -901,7 +901,7 @@
|
|||
"12": "Query asset failed [%s]",
|
||||
"13": "Cannot create a file starting with .",
|
||||
"14": "Export failed: %s",
|
||||
"15": "The content block with ID [%s] was not found, please try again later in the document tree panel menu [Rebuild Index]",
|
||||
"15": "Content block with id [%s] not found, please try again later",
|
||||
"16": "Please enter the doc name",
|
||||
"17": "The initial synchronization failed at startup. Unpredictable data overwriting may occur if you continue to operate. Please perform a synchronization first",
|
||||
"18": "Get community user account failed",
|
||||
|
@ -942,7 +942,7 @@
|
|||
"53": "Data synchronization has not been enabled",
|
||||
"54": "Indexing references...",
|
||||
"55": "Indexed references of [%d] documents",
|
||||
"56": "Reindexing, please wait until rebuilding is complete before trying to open the document",
|
||||
"56": "Reindexing, please wait until rebuilding is complete before trying to open",
|
||||
"57": "Failed to create temp key",
|
||||
"58": "After the index is rebuilt, the interface will be automatically refreshed later...",
|
||||
"59": "Failed to set sync ignore list",
|
||||
|
|
|
@ -901,7 +901,7 @@
|
|||
"12": "Fallo en la consulta de activos [%s]",
|
||||
"13": "No se puede crear un archivo que empiece por .",
|
||||
"14": "Exportación fallida: %s",
|
||||
"15": "El bloque de contenido con ID [%s] no se encontró, por favor inténtelo de nuevo más tarde en el menú del panel del árbol del documento [Reconstruir índice]",
|
||||
"15": "No se encontró el bloque de contenido con id [%s], inténtelo de nuevo más tarde",
|
||||
"16": "Por favor, introduzca el nombre del documento",
|
||||
"17": "La sincronización inicial falló en el arranque. Puede producirse una sobreescritura de datos imprevisible si continúa operando. Por favor, realice primero una sincronización",
|
||||
"18": "Falló la obtención de la cuenta de usuario de la comunidad",
|
||||
|
@ -942,7 +942,7 @@
|
|||
"53": "No se ha habilitado la sincronizacion de datos",
|
||||
"54": "Indexando referencias...",
|
||||
"55": "Referencias indexadas de [%d] documentos",
|
||||
"56": "Reindexando, espere hasta que se complete la reconstrucción antes de intentar abrir el documento",
|
||||
"56": "Reindexando, espere hasta que se complete la reconstrucción antes de intentar abrir",
|
||||
"57": "Fallo en la creación de la clave temporal",
|
||||
"58": "Después de reconstruir el índice, la interfaz se actualizará automáticamente más tarde...",
|
||||
"59": " Falló la configuración de sincronización de la lista de ignorados",
|
||||
|
|
|
@ -901,7 +901,7 @@
|
|||
"12": "Échec de la requête asset [%s]",
|
||||
"13": "Impossible de créer un fichier commençant par .",
|
||||
"14": "L'exportation a échoué : %s",
|
||||
"15": "Le bloc de contenu avec l'ID [%s] n'a pas été trouvé, veuillez réessayer plus tard dans le menu du panneau de l'arborescence du document [Reconstruire l'index]",
|
||||
"15": "Bloc de contenu avec l'identifiant [%s] introuvable, veuillez réessayer plus tard",
|
||||
"16": "Veuillez entrer le nom du fichier",
|
||||
"17": "La synchronisation initiale a échoué au démarrage. Un écrasement imprévisible des données peut se produire si vous continuez à fonctionner. Veuillez d'abord effectuer une synchronisation.",
|
||||
"18": "Échec de la récupération du compte utilisateur communautaire",
|
||||
|
@ -942,7 +942,7 @@
|
|||
"53": "La synchronisation des données n'a pas été activée",
|
||||
"54": "Indexation des références...",
|
||||
"55": "Références indexées de [%d] documents",
|
||||
"56": "Réindexation, veuillez attendre que la reconstruction soit terminée avant d'essayer d'ouvrir le document",
|
||||
"56": "Réindexation, veuillez attendre que la reconstruction soit terminée avant d'essayer d'ouvrir",
|
||||
"57": "Échec de la création d'une clé temporaire",
|
||||
"58": "Une fois l'index reconstruit, l'interface sera automatiquement rafraîchie ultérieurement...",
|
||||
"59": "Échec de la définition de la liste des ignores de synchronisation",
|
||||
|
|
|
@ -901,7 +901,7 @@
|
|||
"12": "查詢資料檔失敗 [%s]",
|
||||
"13": "無法創建 . 開頭的文件",
|
||||
"14": "匯出失敗:%s",
|
||||
"15": "未找到 ID 為 [%s] 的內容塊,請在文檔樹面板菜單【重建索引】以後再試",
|
||||
"15": "未找到 ID 為 [%s] 的內容塊,請稍後再試",
|
||||
"16": "請輸入文檔名",
|
||||
"17": "啟動時初次同步失敗,繼續操作可能會發生無法預測的數據覆蓋,請先執行一次同步",
|
||||
"18": "獲取社區用戶帳號失敗",
|
||||
|
@ -942,7 +942,7 @@
|
|||
"53": "數據同步尚未啟用",
|
||||
"54": "正在索引引用關係...",
|
||||
"55": "已完成索引 [%d] 篇文檔的引用關係",
|
||||
"56": "正在重建索引,請等重建索引完畢後再嘗試打開該文檔",
|
||||
"56": "正在重建索引,請等重建索引完畢後再嘗試打開",
|
||||
"57": "創建臨時金鑰失敗",
|
||||
"58": "重建索引完畢,稍後將自動重新整理介面...",
|
||||
"59": "設置同步忽略列表失敗",
|
||||
|
|
|
@ -901,7 +901,7 @@
|
|||
"12": "查询资源文件失败 [%s]",
|
||||
"13": "无法创建 . 开头的文件",
|
||||
"14": "导出失败:%s",
|
||||
"15": "未找到 ID 为 [%s] 的内容块,请在文档树面板菜单 [重建索引] 以后再试",
|
||||
"15": "未找到 ID 为 [%s] 的内容块,请稍后再试",
|
||||
"16": "请输入文档名",
|
||||
"17": "启动时初次同步失败,继续操作可能会发生无法预测的数据覆盖,请先执行一次同步",
|
||||
"18": "获取社区用户账号失败",
|
||||
|
@ -942,7 +942,7 @@
|
|||
"53": "数据同步尚未启用",
|
||||
"54": "正在索引引用关系...",
|
||||
"55": "已完成索引 [%d] 篇文档的引用关系",
|
||||
"56": "正在重建索引,请等重建索引完毕后再尝试打开该文档",
|
||||
"56": "正在重建索引,请等重建索引完毕后再尝试打开",
|
||||
"57": "创建临时密钥失败",
|
||||
"58": "重建索引完毕,稍后将自动刷新界面...",
|
||||
"59": "设置同步忽略列表失败",
|
||||
|
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/siyuan-note/siyuan/kernel/task"
|
||||
|
||||
"github.com/88250/lute"
|
||||
"github.com/88250/lute/ast"
|
||||
|
@ -393,7 +394,7 @@ func getBlock(id string) (ret *Block, err error) {
|
|||
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
if isIndexing() {
|
||||
if task.ContainIndexTask() {
|
||||
err = ErrIndexing
|
||||
}
|
||||
return
|
||||
|
|
|
@ -52,27 +52,12 @@ func (box *Box) Index() {
|
|||
task.AppendTask(task.DatabaseIndexRef, IndexRefs)
|
||||
}
|
||||
|
||||
var indexing = false
|
||||
|
||||
func isIndexing() (ret bool) {
|
||||
for i := 0; indexing || i > 7; i++ {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
ret = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func index(boxID string) {
|
||||
box := Conf.Box(boxID)
|
||||
if nil == box {
|
||||
return
|
||||
}
|
||||
|
||||
indexing = true
|
||||
defer func() {
|
||||
indexing = false
|
||||
}()
|
||||
|
||||
util.SetBootDetails("Listing files...")
|
||||
files := box.ListFiles("/")
|
||||
boxLen := len(Conf.GetOpenedBoxes())
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
@ -110,6 +111,15 @@ const (
|
|||
DatabaseIndexEmbedBlock = "task.database.index.embedBlock" // 数据库索引嵌入块
|
||||
)
|
||||
|
||||
func ContainIndexTask() bool {
|
||||
for _, task := range taskQueue {
|
||||
if DatabaseIndex == task.Action || DatabaseIndexFull == task.Action {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func StatusLoop() {
|
||||
for {
|
||||
time.Sleep(5 * time.Second)
|
||||
|
@ -138,15 +148,12 @@ func StatusLoop() {
|
|||
}
|
||||
data["tasks"] = items
|
||||
util.PushBackgroundTask(data)
|
||||
if 0 < len(tasks) {
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Loop() {
|
||||
for {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
if QueueStatusClosing == taskQueueStatus {
|
||||
clearQueue()
|
||||
break
|
||||
|
@ -161,7 +168,7 @@ func Loop() {
|
|||
break
|
||||
}
|
||||
|
||||
go execTask(task)
|
||||
execTask(task)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,5 +204,18 @@ func execTask(task *Task) {
|
|||
}
|
||||
}
|
||||
|
||||
task.Handler.Call(args)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*12)
|
||||
defer cancel()
|
||||
ch := make(chan bool, 1)
|
||||
go func() {
|
||||
task.Handler.Call(args)
|
||||
ch <- true
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
//logging.LogWarnf("task [%s] timeout", task.Action)
|
||||
case <-ch:
|
||||
//logging.LogInfof("task [%s] done", task.Action)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue