aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-01-30 18:21:16 -0500
committerGitHub <noreply@github.com>2019-01-30 18:21:16 -0500
commit0a9bb48f83e287e8a9ca5c74eec4e7f926de5a46 (patch)
treea967d0611a817c22146e579a4c1465e0ad69732b /activerecord/lib
parente01e64628d237ca3be2210b1b0caeee99f2fb09d (diff)
parentab952b19496c9569059f2dbb2b1dacaf44e618a8 (diff)
downloadrails-0a9bb48f83e287e8a9ca5c74eec4e7f926de5a46.tar.gz
rails-0a9bb48f83e287e8a9ca5c74eec4e7f926de5a46.tar.bz2
rails-0a9bb48f83e287e8a9ca5c74eec4e7f926de5a46.zip
Merge pull request #35108 from jhawthorn/db-selection-timestamp-after
Write update_last_write_timestamp after request
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/middleware/database_selector/resolver.rb8
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