Skip to content

Commit

Permalink
Add additional logging to help troubleshoot indexing. (#5271)
Browse files Browse the repository at this point in the history
refs #5231
  • Loading branch information
justinlittman authored Feb 25, 2025
1 parent 26c0115 commit 34012d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ GEM
attr_extras (7.1.0)
base64 (0.2.0)
bcrypt_pbkdf (1.1.1)
bcrypt_pbkdf (1.1.1-arm64-darwin)
bcrypt_pbkdf (1.1.1-x86_64-darwin)
benchmark (0.4.0)
bigdecimal (3.1.9)
bootsnap (1.18.4)
Expand Down
8 changes: 6 additions & 2 deletions app/services/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ class Indexer
def self.reindex(cocina_object:, trace_id: nil)
return unless Settings.solr.enabled

trace_id ||= trace_id_for(druid: cocina_object.externalIdentifier)
solr_doc = Indexing::Builders::DocumentBuilder.for(
model: cocina_object,
trace_id: trace_id || trace_id_for(druid: cocina_object.externalIdentifier)
trace_id:
).to_solr
solr.add(solr_doc)
# This logging is to assist with https://github.com/sul-dlss/dor-services-app/issues/5231
# It is capturing that a Solr document is being committed and the order relative to other commits.
Rails.logger.info("[Indexing] Committing #{cocina_object.externalIdentifier} with trace_id=#{trace_id}")
solr.commit
end

Expand Down Expand Up @@ -39,7 +43,7 @@ def self.solr
def self.trace_id_for(druid:)
source = Kernel.caller_locations(2, 1).first.to_s.delete_prefix("#{Rails.root}/") # rubocop:disable Rails/FilePath
SecureRandom.uuid.tap do |trace_id|
Rails.logger.info("Reindexing #{druid} from #{source} with trace_id=#{trace_id}")
Rails.logger.info("[Indexing] Reindexing #{druid} from #{source} with trace_id=#{trace_id}")
end
end
end

0 comments on commit 34012d4

Please sign in to comment.