This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-06
Channels
- # announcements (18)
- # asami (14)
- # aws (5)
- # babashka (58)
- # beginners (32)
- # calva (12)
- # cider (29)
- # clj-kondo (8)
- # cljfx (8)
- # cljs-dev (4)
- # clojure (101)
- # clojure-europe (54)
- # clojure-germany (5)
- # clojure-nl (8)
- # clojure-serbia (8)
- # clojure-spec (12)
- # clojure-uk (8)
- # clojurescript (24)
- # cursive (3)
- # datomic (17)
- # docs (2)
- # etaoin (12)
- # events (1)
- # fulcro (1)
- # google-cloud (2)
- # jobs (1)
- # jobs-discuss (6)
- # lsp (65)
- # luminus (2)
- # malli (10)
- # meander (4)
- # nrepl (1)
- # off-topic (112)
- # onyx (2)
- # pathom (6)
- # polylith (14)
- # re-frame (9)
- # reagent (36)
- # reitit (13)
- # releases (2)
- # remote-jobs (5)
- # rewrite-clj (12)
- # shadow-cljs (70)
- # specter (2)
- # startup-in-a-month (1)
- # xtdb (14)
what's the situation with using open-q
on an open-db
? I remember this is ill-advised but can't recall why
I'm not sure what the concern might be here as my understanding is that they are orthogonal, i.e. open-q
works the same whether inside a (with-open [db (c/open-db node)] ...)
or not (asides from the transparent performance benefits of pooling the underlying caches & KV index iterator resources)
That said, I might be missing something, and your fancy clojure.lang.ref.Cleaner
machinery could well break those assumptions very easily.
I'll double-check and confirm with you again here tomorrow 🙂
Circling back to this after some discussion - I can confirm there should be no issue. That said, I will write a test for running multiple concurrent open-q's inside an open-db, since we don't actually have a test for that right now.
Just caught a bug with open-q
where if I try to return a lazy sequence (e.g. a filter
instead of a filterv
) it actually crashed the whole JVM
are you using with-open
such that it's trying to realize the lazy seq after the open-q
snapshot has been closed? laziness and RAII-semantics don't really mix, I've found
Yeah exactly. It's just crazy that it doesn't simply fail, but actually crashes the whole JVM
I fixed my code to realize within the with-open but I thought that was a pretty nasty edge case to point out
> I fixed my code to realize within the with-open I'm relieved to hear that worked 🙂 I agree it's a sharp edge though. Sadly there's not much we can do functionally to change the situation (due to how the native interop works), but do you think a strong warning in the docstring would help?
Yeah. Currently the docstring says attempting to iterate when closed is undefined. Perhaps it varies by operating system?
I think crux could manage the lifetimes of resources opened through its api internally (e.g. expose a crux/close
that safely schedules a .close
, to be run only when all references to the db are gone) rather than push it on the user, though dubious whether it's worth the complexity/effort
or discourage the use of with-open in favor of a with-streaming-results
type macro that wraps the form and forces data realization
I dunno if that's too hand-holdy though