core-async

jrychter 2025-04-06T01:43:42.779419Z

I'm looking at the release notes for core.async and noticed ASYNC-260 and ASYNC-256. This is worrying for me, because I've been using clojure.core.async.pool-size (set to 128) since 2019 or so, and my app does not work without it. Without the setting, my app would hang completely after several days of operation on production servers. I never tracked down the real issue and I'm not sure if I'm able to: it's hard to reproduce, and I've only seen it occur in production, with actual loads. I suspect it is a combination of clj-rethinkdb, aleph, and my own use of core.async. No particular reason for writing this: I'm just venting my worries and perhaps someone will chip in with a comment. Or tell me that I should not worry, because ASYNC-256 (which I'm unable to fully review and understand) would make such problems go away by themselves.

2025-04-06T02:04:36.354809Z

When the app locks up, take a thread dump, find the core.async thread pool threads in the dump, see what they are blocked on and move the execution of that somewhere else

2025-04-06T02:08:03.700719Z

I would be shocked if it isn't the result of using blocking channel ops instead of parking in a go block somewhere (that just seems like the most likely way to deadlock, the alternatives seem like they would cause starvation/poor performance but not a complete lock up)

2025-04-06T02:13:54.933919Z

Looks like you already did a lot of this work six years ago https://github.com/apa512/clj-rethinkdb/issues/198

jrychter 2025-04-06T02:31:16.981379Z

…and I've completely forgotten about all of it 🙂

jrychter 2025-04-06T02:33:20.185479Z

Unfortunately, this is not an easy thing to find and fix, and I'm looking for a way to keep the status quo. I will be replacing RethinkDB with FoundationDB in the future anyway, so all of this complex manifold code will go away. For now, I'm just worried that upgrading core.async will make the hangs reappear.

Alex Miller (Clojure team) 2025-04-06T02:40:09.971399Z

You can use the new executor-factory property setting to install a fixed size dispatch thread pool sized 128 if you need to, should then be identical

Alex Miller (Clojure team) 2025-04-06T02:45:50.337079Z

If the problem is blocking code in your go blocks then eventually (when we have vthread support), I would recommend using that with Java 21+ and switching your go blocks to io-thread

jrychter 2025-04-06T03:00:01.597959Z

For now, I just want to keep the existing thing going. It's a solo-founder SaaS and I have to be extremely careful with my time. As I intend to switch to FoundationDB in the future anyway, there is no point in investing time to debug clj-rethinkdb and manifold. Thanks for the hint about clojure.core.async.executor-factory , I'll look into that.