mirror of
https://github.com/logseq/logseq.git
synced 2026-05-21 03:12:38 +00:00
enhance(rtc): show more info in debug-ui
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
:rtc/ignore-entity-when-init-download true}}
|
||||
:logseq.kv/schema-version {:doc "Graph's current schema version"}
|
||||
:logseq.kv/remote-schema-version {:doc "Graph's remote schema version.
|
||||
RTC won't start when (not= local-schema-version remote-schema-version)"
|
||||
RTC won't start when major-schema-versions don't match"
|
||||
:rtc {:rtc/ignore-entity-when-init-upload true
|
||||
:rtc/ignore-entity-when-init-download true}}
|
||||
:logseq.kv/graph-created-at {:doc "Graph's created at time"}
|
||||
|
||||
25
deps/db/src/logseq/db/frontend/schema.cljs
vendored
25
deps/db/src/logseq/db/frontend/schema.cljs
vendored
@@ -9,18 +9,6 @@
|
||||
(str major "." minor)
|
||||
(str major))))
|
||||
|
||||
;;; nbb not support extend-protocol ICompareable for defrecord
|
||||
(defn compare-schema-version
|
||||
[x y]
|
||||
(assert (instance? SchemaVersion x) x)
|
||||
(cond
|
||||
(number? y) (compare (.-major x) y)
|
||||
(sequential? y) (compare [(.-major x) (.-minor x)] [(first y) (second y)])
|
||||
(instance? SchemaVersion y)
|
||||
(compare [(.-major x) (.-minor x)] [(.-major y) (.-minor y)])
|
||||
:else
|
||||
(throw (js/Error. (str "Cannot compare " x " to " y)))))
|
||||
|
||||
(defn parse-schema-version
|
||||
"schema-version-old: 10, a number
|
||||
schema-version-new: \"12.34\", string, <major-num>.<minor-num>"
|
||||
@@ -35,6 +23,19 @@
|
||||
:else
|
||||
(throw (ex-info (str "Bad schema version: " string-or-compatible-number) {:data string-or-compatible-number}))))
|
||||
|
||||
;;; nbb not support extend-protocol ICompareable for defrecord
|
||||
(defn compare-schema-version
|
||||
[x y]
|
||||
(if (instance? SchemaVersion x)
|
||||
(cond
|
||||
(number? y) (compare (.-major x) y)
|
||||
(sequential? y) (compare [(.-major x) (.-minor x)] [(first y) (second y)])
|
||||
(instance? SchemaVersion y)
|
||||
(compare [(.-major x) (.-minor x)] [(.-major y) (.-minor y)])
|
||||
:else
|
||||
(throw (js/Error. (str "Cannot compare " x " to " y))))
|
||||
(compare-schema-version (parse-schema-version x) y)))
|
||||
|
||||
(def version (parse-schema-version "63"))
|
||||
|
||||
(defn major-version
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
[frontend.ui :as ui]
|
||||
[frontend.util :as util]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.frontend.schema :as db-schema]
|
||||
[logseq.shui.ui :as shui]
|
||||
[missionary.core :as m]
|
||||
[promesa.core :as p]
|
||||
@@ -107,7 +108,10 @@
|
||||
:remote-profile? (:remote-profile? debug-state*)
|
||||
:current-page (state/get-current-page)
|
||||
:blocks-count (when-let [page (state/get-current-page)]
|
||||
(count (:block/_page (db/get-page page))))}
|
||||
(count (:block/_page (db/get-page page))))
|
||||
:schema-version {:app (str db-schema/version)
|
||||
:local-graph (:local-graph-schema-version debug-state*)
|
||||
:remote-graph (:remote-graph-schema-version debug-state*)}}
|
||||
(fipp/pprint {:width 20})
|
||||
with-out-str)]]
|
||||
|
||||
|
||||
@@ -254,6 +254,8 @@
|
||||
(def ^:private empty-rtc-loop-metadata
|
||||
{:repo nil
|
||||
:graph-uuid nil
|
||||
:local-graph-schema-version nil
|
||||
:remote-graph-schema-version nil
|
||||
:user-uuid nil
|
||||
:rtc-state-flow nil
|
||||
:*rtc-auto-push? nil
|
||||
@@ -314,7 +316,7 @@
|
||||
(m/sp
|
||||
;; ensure device metadata existing first
|
||||
(m/? (worker-device/new-task--ensure-device-metadata! token))
|
||||
(let [{:keys [conn user-uuid graph-uuid schema-version _remote-schema-version date-formatter] :as r}
|
||||
(let [{:keys [conn user-uuid graph-uuid schema-version remote-schema-version date-formatter] :as r}
|
||||
(validate-rtc-start-conditions repo token)]
|
||||
(if (instance? ExceptionInfo r)
|
||||
(do (prn r) (r.ex/->map r))
|
||||
@@ -330,6 +332,8 @@
|
||||
(do (prn start-ex) (r.ex/->map start-ex))
|
||||
(do (reset! *rtc-loop-metadata {:repo repo
|
||||
:graph-uuid graph-uuid
|
||||
:local-graph-schema-version schema-version
|
||||
:remote-graph-schema-version remote-schema-version
|
||||
:user-uuid user-uuid
|
||||
:rtc-state-flow rtc-state-flow
|
||||
:*rtc-auto-push? *rtc-auto-push?
|
||||
@@ -413,7 +417,8 @@
|
||||
(let [rtc-loop-metadata-flow (m/watch *rtc-loop-metadata)]
|
||||
(m/ap
|
||||
(let [{rtc-lock :*rtc-lock
|
||||
:keys [repo graph-uuid user-uuid rtc-state-flow *rtc-auto-push? *rtc-remote-profile?
|
||||
:keys [repo graph-uuid local-graph-schema-version remote-graph-schema-version
|
||||
user-uuid rtc-state-flow *rtc-auto-push? *rtc-remote-profile?
|
||||
*online-users *last-stop-exception]}
|
||||
(m/?< rtc-loop-metadata-flow)]
|
||||
(try
|
||||
@@ -423,6 +428,8 @@
|
||||
(fn [rtc-state rtc-auto-push? rtc-remote-profile?
|
||||
rtc-lock online-users pending-local-ops-count local-tx remote-tx]
|
||||
{:graph-uuid graph-uuid
|
||||
:local-graph-schema-version (str local-graph-schema-version)
|
||||
:remote-graph-schema-version (str remote-graph-schema-version)
|
||||
:user-uuid user-uuid
|
||||
:unpushed-block-update-count pending-local-ops-count
|
||||
:local-tx local-tx
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
[frontend.worker.rtc.ws-util :as ws-util]
|
||||
[frontend.worker.util :as worker-util]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.frontend.schema :as db-schema]
|
||||
[missionary.core :as m]))
|
||||
|
||||
(defn- get-builtin-db-idents
|
||||
@@ -34,7 +35,7 @@
|
||||
(let [{:keys [server-schema-version server-builtin-db-idents]} r
|
||||
client-builtin-db-idents (set (get-builtin-db-idents db))
|
||||
client-schema-version (ldb/get-graph-schema-version db)]
|
||||
(when (not= client-schema-version server-schema-version)
|
||||
(when-not (zero? (db-schema/compare-schema-version client-schema-version server-schema-version))
|
||||
(worker-util/post-message :notification
|
||||
[[:div
|
||||
[:p (str :client-schema-version client-schema-version)]
|
||||
|
||||
Reference in New Issue
Block a user