I have a Rails 5.2.3 (MRI 2.5.5) app hosted on Heroku. I've added some cleanup code inside an ensure block, so that it runs when the app receives the SIGTERM for its daily restart. The cleanup code involves a simple update on an ActiveRecord object. The ensure block runs as expected, but the database transaction itself always rolls back.
The transaction inside ensure works fine during normal operations, but I cannot get it to complete after it has received a SIGTERM. I'm going by what's shown in Heroku's docs.
begin
## Do some work...
ensure
## Runs (not exclusively) after SIGTERM...
## ...except for ActiveRecord update/create etc!
I couldn't find any error message to go by.