This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-25
Channels
- # babashka (65)
- # beginners (34)
- # biff (18)
- # calva (8)
- # clara (22)
- # clj-kondo (32)
- # clojure (24)
- # clojure-bay-area (4)
- # clojure-europe (135)
- # clojure-nl (3)
- # clojure-norway (9)
- # clojure-uk (1)
- # clojurescript (11)
- # clojutre (1)
- # core-async (8)
- # cursive (3)
- # datomic (31)
- # emacs (5)
- # fulcro (6)
- # graalvm (5)
- # graphql (3)
- # honeysql (1)
- # introduce-yourself (9)
- # kaocha (1)
- # lsp (65)
- # meander (5)
- # nbb (7)
- # nrepl (2)
- # off-topic (44)
- # rum (3)
- # shadow-cljs (23)
- # specter (1)
- # tools-deps (6)
- # vim (3)
- # xtdb (30)
Is that possible to do much nicer: eg. how to check is that closed?
(def closed? (atom "false"))
(defn kv-store [dir]
{:kv-store {:xtdb/module 'xtdb.rocksdb/->kv-store
:db-dir (io/file dir)
:block-cache :xtdb.rocksdb/block-cache
:sync? true}})
(defn start-xtdb! [conf]
^IXtdb (IXtdb/startNode
(let [xtdb-path (-> conf :xtdb :dev :dir)
xtdb-port (-> conf :xtdb :dev :port)
^Map m {:xtdb/tx-log (kv-store (str xtdb-path "/tx-log"))
:xtdb/document-store (kv-store (str xtdb-path "/doc-store"))
:xtdb/index-store (kv-store (str xtdb-path "/index-store"))
;; Configuring the Block Cache
:xtdb.rocksdb/block-cache {:xtdb/module 'xtdb.rocksdb/->lru-block-cache
:cache-size (* 512 1024 1024)}
;; optional:
:xtdb.lucene/lucene-store {:db-dir (str xtdb-path "/lucene-dir")}
:xtdb.http-server/server {:port xtdb-port}}]
m)))
(mount/defstate ^:dynamic ^{:on-lazy-start :throw}
*xtdb*
:start (do (println (str "XTDB database start"))
(reset! closed? "false")
(start-xtdb! conf))
:stop (when (not (keyword? *xtdb*))
(try
(do
(.close *xtdb*)
(.status *xtdb*))
(catch IllegalStateException e
(when (= "XTDB node is closed" (.getMessage e))
(reset! closed? "true"))))))
Hi @U2T2ZEVPC I'm not clear on the problem you're trying to solve here (/ the problem you have solved). Please can you describe it a little more? This previous thread on "how do I know if a node is closed" may be of use: https://clojurians.slack.com/archives/CG3AM2F7V/p1661950972927149
Ok, I try to find out. My code is working, but very dirty. So no different solution. What I would like to solve: get feedback Rocksdb really closed or not, because mount sometimes give back false info.
Hmm, so are you finding that .close
is not blocking correctly / behaving synchronously?
Yes, I use in this way the mount.. as I shared.. if not.. 1 blocked from 5-6 restart. Mount said stopped but really not fully.. like locked something
Maybe that is coming rocksdb installation on osx.. I will find out later. Ps. I read about that was a problem at Python too.. etc in the past
Im not a senior Clojure dev.. so therefore I can mainly just drop questions. I dont want to say anything as fact. If you understand me.
I haven't used Mount before so I don't have a good understanding of how it could/should all work together. However, if you are keen to get to the bottom of this I should be able to help you if you could create a small, isolated project (i.e. a new repo on Github) that consistently reproduces the issue, alongside the solution. I'm wondering whether perhaps Mount isn't even required to demonstrate the real underlying issue :thinking_face:
> I’m wondering whether perhaps Mount isn’t even required to demonstrate the real underlying issue
I think it is a true statement
> mount said stopped but really not fully.. like locked something
mount does not really say anything
what you see is a result of a stop function (a block of code after the :stop
👆)
. I saw: A write as in docs B write as above, like test. So, at A sometimes I get error, at B case never
to @U899JBRPF’s point I would recommend to try to reproduce it without mount
the error comes from the code block in your :stop
function, mount just calls it on (mount/stop)
it is best to isolate the problem vs. wrap it in tools
@U899JBRPF I tested out the full code and the solution:
(defn start-xtdb! [conf]
^IXtdb (xt/start-node (rocks-node-opts conf)))
Ok, the mistake was I used (declare ^:dynamic ^IXtdb *xtdb*)
instead of def.. beginning of the namespace… I never checked 😕 😞🤯
Oh no! Although I'm really glad to hear you got to the bottom of it eventually 👏
What was the intended use-case for using (declare ^:dynamic ^IXtdb *xtdb*)
? Testing?
I used at user.clj > backend/db setup where was the lifecycle management, so effected to everything. Eg. at tests:
(defn test-rocksdb-fixture
"(clojure.test/use-fixtures :once test-rocksdb-fixture)"
[f]
(start-with-args {:mode :test} [#'conf #'*xtdb*])
(f)
(stop [#'*xtdb* #'conf]))
that is call *xtdb*
> (mount/defstate *xtdb* ..
which is depend on config and special args.
I know, that isn’t perfect.. but you can see fully (maybe easier in this way understand my problem) https://github.com/damesek/deps-fullstack I work on this ( long time ago.. was a plan .. renew my stack from lein).