From 89cd0ae97ac521827060f147528d3c99de24b38a Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 29 Apr 2011 01:13:20 +0000 Subject: [PATCH] avoid deadlocks, RT#10574 --- FS/bin/freeside-torrus-srvderive | 6 ++++-- torrus/perllib/Torrus/Collector/ExtDBI.pm | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/FS/bin/freeside-torrus-srvderive b/FS/bin/freeside-torrus-srvderive index e8626e10d..a02d23ea0 100644 --- a/FS/bin/freeside-torrus-srvderive +++ b/FS/bin/freeside-torrus-srvderive @@ -102,8 +102,10 @@ while (1) { exit unless @serviceids; #don't try to search for empty virtual ports #nonlocking select statements; rows in this table never change - dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED') - if driver_name eq 'mysql'; + if ( driver_name eq 'mysql' ) { + dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + dbh->commit or die dbh->errstr; + } my @in = (); for my $dir ('_IN', '_OUT') { diff --git a/torrus/perllib/Torrus/Collector/ExtDBI.pm b/torrus/perllib/Torrus/Collector/ExtDBI.pm index 7d1394191..a4fe4fc75 100644 --- a/torrus/perllib/Torrus/Collector/ExtDBI.pm +++ b/torrus/perllib/Torrus/Collector/ExtDBI.pm @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -# $Id: ExtDBI.pm,v 1.1 2010-12-27 00:03:58 ivan Exp $ +# $Id: ExtDBI.pm,v 1.2 2011-04-29 01:13:20 ivan Exp $ # Stanislav Sinyagin ## Pluggable backend module for ExternalStorage @@ -63,6 +63,12 @@ sub backendOpenSession if( defined( $dbh ) ) { + + if ( $dbh->{Driver}->{Name} =~ /^mysql/i ) { + $dbh->do('SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'); + $dbh->commit(); + } + $sth = $dbh->prepare( Torrus::SQL::SrvExport->sqlInsertStatement() ); if( not defined( $sth ) ) { -- 2.11.0