Skip to content

Commit

Permalink
tidy and document recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
terrywbrady committed Jan 19, 2024
1 parent 01213bd commit 46a964e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/file_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def check_download

def check_version
version = @file.inv_version
obj = version.inv_object
version.inv_object
end

def not_found_obj
Expand Down
5 changes: 5 additions & 0 deletions app/lib/merritt_retry_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ class RetryException < RuntimeError; end

RETRY_LIMIT = 3

# Merritt UI was encountering 500 errors on database connections that were no longer active.
# The first solution that I tried was to wrap frequent query blocks with the following retry logic.
# This significantly decreased the number of 500 errors.
# In Jan 2024, I also began setting "idle_timeout=0". Hopefully, this will address the underlying issue.
# For each retry block that is invoked, there is an RSpec test that forces the code into the retry logic.
def merritt_retry_block
retries = 0
begin
Expand Down
3 changes: 3 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ default: &default
host: "{!SSM: inv/db-host}"
database: "{!SSM: inv/db-name}"
pool: 25
# Merritt UI encountered 500 errors when mysql connections were no longer active.
# Jan 2024 - adding this setting to see if it prevents inactive connections.
# See https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html
idle_timeout: 0
port: 3306
username: "{!SSM: inv/readwrite/db-user}"
Expand Down

0 comments on commit 46a964e

Please sign in to comment.