diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/middleware/database_selector/resolver.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/middleware/database_selector/resolver.rb b/activerecord/lib/active_record/middleware/database_selector/resolver.rb index 1c056e2156..930ddf900e 100644 --- a/activerecord/lib/active_record/middleware/database_selector/resolver.rb +++ b/activerecord/lib/active_record/middleware/database_selector/resolver.rb @@ -64,8 +64,12 @@ module ActiveRecord def write_to_primary(&blk) ActiveRecord::Base.connected_to(role: :writing) do instrumenter.instrument("database_selector.active_record.wrote_to_primary") do - resolver.update_last_write_timestamp - yield + begin + ret = yield + ensure + resolver.update_last_write_timestamp + end + ret end end end |