dybr
Mar. 1st, 2023 10:51 pmWhat was going on: Postgres, handled via Slick, was hanging on certain operations. Giving it 15 seconds or something did not help. More, psql was hanging on connection. Meaning that connections were interfering. Really not my area of expertise, yet. Safa was supposed to be helpful, but well.
Anyway, now I know what happened.
Slick, when you call it, returns you a future. If you don't want to wait (why should you), you "chain it" with the next future. But the fucking truth is that it's a Scala Future. It launches right away. Which is not what I want to have, I want it start after the first one is finished, there's a dependency.
So, one solution would be to concatenate all those sqls in one big chunk, and execute; another would be to remember what I knew about Scala Futures and chain them properly. The third solution would be to use ZIO.
But wait, I can't seriously expect something different from Slick, it just returns you a launched future. I'll have to chain them via "onComplete".
Vaguely I remember dealing with this shit eons ago, no I have to fix it. Why would a promise help, I don't see. Oh, whatever. Tomorrow.
An alternative would be just use a regular CPS, since that's how it works. Not creating a future before the previous one started. That would be the sanest solution.

























