We ran into a problem recently in which ActiveRecord wound up with an
inconsistent transaction count. Analysis revealed that those processes
had hit a deadlock in the database and were chosen to be the deadlock
victim, resulting in an exception being raised by the database
adapter. Unhappily, the sql was being triggered incidentally by a
method exposed to a liquid template, and liquid was swallowing the
exception, preventing the outermost transaction block from cleaning up
from the mess and, in turn, erroring out the request.
The solution was trivial: switch from template.render to
template.render!, which causes liquid to re-raise exceptions.
Anyone else exposing methods to liquid templates that might trigger
ActiveRecord to run database code, or anything else which may raise an
exception which needs to be handled above probably should do the same.
I might even venture to suggest this should be the default behavior,
or at least that render! should be preferred in the documentation over