diff --git a/Gemfile.lock b/Gemfile.lock index 09b872a2c..8eae36d79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -197,7 +197,9 @@ GEM font-awesome-rails (4.7.0.8) railties (>= 3.2, < 8.0) formatador (1.1.0) - geocoder (1.8.2) + geocoder (1.8.3) + base64 (>= 0.1.0) + csv (>= 3.0.0) globalid (1.2.1) activesupport (>= 6.1) govdelivery-tms (2.8.4) diff --git a/app/models/institution_builder.rb b/app/models/institution_builder.rb index 8eb447349..cdde063cf 100644 --- a/app/models/institution_builder.rb +++ b/app/models/institution_builder.rb @@ -80,11 +80,10 @@ def self.run_insertions(version) def self.run(user) prev_gen_start = Time.now.utc version = Version.create!(production: false, user: user) - build_messages = {} begin Institution.transaction do # to fix 'cancelling statement due to statement timeout' issue - ActiveRecord::Base.connection.execute("SET LOCAL statement_timeout = '120s';") + ActiveRecord::Base.connection.execute("SET LOCAL statement_timeout = '240s';") if staging? # Skipping validation here because of the scale of this query (it will timeout updating all 70k records) # rubocop:disable Rails/SkipsModelValidations @@ -97,24 +96,16 @@ def self.run(user) ) # rubocop:enable Rails/SkipsModelValidations end - build_messages = run_insertions(version) + run_insertions(version) version.update(production: true, completed_at: Time.now.utc.to_fs(:db)) GibctSiteMapper.new(ping: true) if production? Archiver.archive_previous_versions if Settings.archiver.archive log_info_status PUBLISH_COMPLETE_TEXT end rescue ActiveRecord::StatementInvalid => e - notice = 'There was an error occurring at the database level' - log_info_status notice - error_msg = e.message - Rails.logger.error "#{notice}: #{error_msg}" - version.delete + log_error_and_delete_version(version, "There was an error occurring at the database level: #{e.message}") rescue StandardError => e - notice = 'There was an error of unexpected origin' - log_info_status notice - error_msg = e.message - Rails.logger.error "#{notice}: #{error_msg}" - version.delete + log_error_and_delete_version(version, "There was an error of unexpected origin: #{e.message}") end prev_gen_end = Time.now.utc @@ -1188,6 +1179,12 @@ def self.add_section1015(version_id) Institution.connection.execute(sql) end + def self.log_error_and_delete_version(version, notice) + log_info_status notice + Rails.logger.error notice + version.delete + end + def self.log_info_status(message) Rails.logger.info "*** #{Time.now.utc} #{message}" diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index fdb2c84dd..8078059ca 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -1,4 +1,8 @@ +# The default backend geocoding service is nominatim. At some point in late May 2024, +# the user agent became mandatory and nominatim started returning parse errors to +# the Geocoder gem unless this was provided. Geocoder.configure( + http_headers: { "User-Agent" => "Brian.Grubb@va.gov" }, timeout: 15, always_raise: :all )