This will be a quick one, since I didn’t really upgrade to Phoenix v1.2.0, unfortunately… Why, why not?!
The main reason I was eager to upgrade was the new Presence feature. It will really streamline my code, and allow me to easily implement the monitoring stuff I mentioned in the previous post. Also, my tests are getting slow, so having the ecto async goodness would be great as well.
The reason I didn’t upgrade is because I’ve tried to, and it didn’t work out.
First off, after the upgrade, I ran my tests, and got a whole lot of long error stacktraces on my console. I’ve included a few at the bottom. The first one I tackled was the FunctionClauseError related to the handle_info stuff. After spending about an hour at the Elixir slack channel, turns out it was a bug in the db_connection library.
That’s not too bad, but seeing that this is just one error, and I now see at least three more different ones, I just can’t spend the time to dig into each and every one!
It probably makes sense at this point not to upgrade a sufficiently complex application, and wait for the release to stabilize. I have a new project in Elixir, tho, and it’s using v1.2.0 without issues. This is because I can easily avoid troublesome patterns in the new app, but it would take forever to migrate the old app.
Just a quick example of a “troublesome” pattern, that is spinning off GenServers and processes that interact with the DB. Apparently, the new Ecto sandbox stuff is nice and all, but quite restrictive. To properly use it, you either have to do it right from the get-go, or refactor your whole implementation.
This one is a completely random DBConnection error that doesn’t make any sense to me. I’m not sure about it, so I can’t really open an issue on Github…
Update: One of the Ecto developers told me it’s a bug already fixed on master.
Finally, many people have been running into this, but it seems the only way to avoid it is to properly manage your access to the DB and make sure all transactions are complete within the test time frame?