Log the failing SQL statement in vectorization task
Unique violations on packages_name_key happen on a statement that cannot logically touch name - log the exact query and a longer backtrace to identify what really fails.
This commit is contained in:
parent
bada261841
commit
61b64fae25
1 changed files with 9 additions and 1 deletions
|
|
@ -30,6 +30,13 @@ namespace :debshots do
|
|||
done = 0
|
||||
failed = 0
|
||||
|
||||
# Remember the most recent SQL statement so failures can be traced
|
||||
# to the exact query that triggered them.
|
||||
last_sql = nil
|
||||
ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
||||
last_sql = args.last[:sql]
|
||||
end
|
||||
|
||||
scope.find_each do |package|
|
||||
begin
|
||||
raise ArgumentError, 'no description text' if package.embedding_text.blank?
|
||||
|
|
@ -41,7 +48,8 @@ namespace :debshots do
|
|||
# enough detail to diagnose it and move on.
|
||||
failed += 1
|
||||
logger.error "Failed for package #{package.name}: #{e.class}: #{e.message}"
|
||||
logger.error e.backtrace.first(3).join("\n") if e.backtrace
|
||||
logger.error "Last SQL: #{last_sql}"
|
||||
logger.error e.backtrace.first(15).join("\n") if e.backtrace
|
||||
end
|
||||
|
||||
processed = done + failed
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue