From a683cedcce4bb6f96c77e9f87734e17c3a481155 Mon Sep 17 00:00:00 2001 From: Matthew Kienow Date: Fri, 14 Dec 2018 12:28:16 -0500 Subject: [PATCH] Enhance race condition workaround in report_host --- lib/msf/core/db_manager/host.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/msf/core/db_manager/host.rb b/lib/msf/core/db_manager/host.rb index 10b62d3ac9..a4c2fbebb0 100644 --- a/lib/msf/core/db_manager/host.rb +++ b/lib/msf/core/db_manager/host.rb @@ -258,9 +258,9 @@ module Msf::DBManager::Host msf_import_timestamps(opts, host) host.save! end - rescue ActiveRecord::RecordNotUnique - # two concurrent report requests for a new host could result in a RecordNotUnique exception - # simply retry the report once more as an optimistic approach + rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid + # two concurrent report requests for a new host could result in a RecordNotUnique or + # RecordInvalid exception, simply retry the report once more as an optimistic approach retry if (retry_attempts+=1) <= 1 raise end