ash-project/reactor

Weird behaviour using a transaction inside a step

Closed this issue · 3 comments

I have a curious use case where in one of my tests i call enqueue on an Oban job (set to test mode, so it executes immediately). This Oban job then uses a transaction to do a Repo.stream to perform some batch operations, and for each of the lines it calls a reactor on an object.

Apparently this causes the first step of the reactor to timeout waiting for a database connection. If i remove the transaction and iterate a Repo.all instead it works (though that's far from memory optimal).

Any idea what might be happening?

Hi @noozo 👋

Does this happen in live code as well as in the tests? If it's just in the tests I'd guess it's something to do with the sandbox and Reactor's use of concurrency. Try passing the async?: false option to your Reactor.run call in test and see if that fixes it. If that's the case then we need to figure out how make it work correctly by default.

will try tomorrow at work. thanks :)

apparently the problem just went away once i put the transaction back, which is weird :(