From c74c56dc02a4e934ecf7245bfd376b94a47cd1c3 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 24 May 2013 11:34:23 +0100 Subject: [PATCH] guard against race with *_or_* DBIC methods --- Netdisco/lib/App/Netdisco/Util/Arpnip.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Util/Arpnip.pm b/Netdisco/lib/App/Netdisco/Util/Arpnip.pm index ab4522b0..c1145ecc 100644 --- a/Netdisco/lib/App/Netdisco/Util/Arpnip.pm +++ b/Netdisco/lib/App/Netdisco/Util/Arpnip.pm @@ -80,8 +80,12 @@ sub do_arpnip { # update subnets with new networks foreach my $cidr (@subnets) { - schema('netdisco')->resultset('Subnet') - ->update_or_create({net => $cidr, last_discover => \'now()'}); + try { + schema('netdisco')->txn_do(sub { + schema('netdisco')->resultset('Subnet') + ->update_or_create({net => $cidr, last_discover => \'now()'}); + }); + }; } debug sprintf ' [%s] arpnip - processed %s Subnet entries', $device->ip, scalar @subnets;