ash-project / reactor

Reactor is a dynamic, concurrent, dependency resolving saga orchestrator.
https://ash-hq.org/
MIT License
44 stars 6 forks source link

Weird behaviour using a transaction inside a step #73

Closed noozo closed 11 months ago

noozo commented 12 months ago

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?

jimsynz commented 12 months ago

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.

noozo commented 12 months ago

will try tomorrow at work. thanks :)

noozo commented 11 months ago

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