[Rt-commit] rt branch, 4.4/mariadb_disconnect_segv_bugfix, created. rt-4.4.4-79-gd3f2d33987

Aaron Trevena ast at bestpractical.com
Thu Dec 5 14:19:59 EST 2019


The branch, 4.4/mariadb_disconnect_segv_bugfix has been created
        at  d3f2d339875108c83f6282acdfd10001152cf616 (commit)

- Log -----------------------------------------------------------------
commit d3f2d339875108c83f6282acdfd10001152cf616
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Thu Dec 5 19:16:42 2019 +0000

    Workaround for segfault on disconnect/reconnect/ping on MariaDB 10.3/10.4
    
    Simple workaround for I#222238 bug causing segfault when reconnect or ping after disconnect on mariadb 10.3.x and 10.4.x

diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 29e929e7b7..93b7a4c6db 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -103,6 +103,17 @@ sub FinalizeDatabaseType {
     }
 }
 
+sub Disconnect {
+    my $self = shift;
+    if (exists $self->{db_subtype} && ( $self->{db_subtype} eq 'mariadb')) {
+        my ($version) = $self->{database_version} =~ /^(\d+\.\d+)/;
+        if ( $version >= 10.3 ) {
+            $self->{_reconnection_required}++;
+        }
+    }
+    $self->SUPER::Disconnect(@_);
+}
+
 =head2 Connect
 
 Connects to RT's database using credentials and options from the RT config.
@@ -126,9 +137,14 @@ sub Connect {
         DisconnectHandleOnDestroy => 1,
         %args,
     );
-
+    if (exists $self->{_reconnection_required}) {
+        $self->{_reconnection_required} = 0;
+    }
     if ( $db_type eq 'mysql' ) {
         my $version = $self->DatabaseVersion;
+        if ($self->{database_version} =~ m/maria/i) {
+            $self->{db_subtype} = 'mariadb';
+        }
         ($version) = $version =~ /^(\d+\.\d+)/;
         $self->dbh->do("SET NAMES 'utf8'") if $version >= 4.1;
     }
@@ -141,6 +157,17 @@ sub Connect {
     $self->dbh->{'LongReadLen'} = RT->Config->Get('MaxAttachmentSize');
 }
 
+sub dbh {
+    my $self = shift;
+    if (@_) {
+        return $self->SUPER::dbh(@_);
+    }
+    elsif ($self->{_reconnection_required}) {
+        return undef;
+    }
+    return $self->SUPER::dbh();
+}
+
 =head2 BuildDSN
 
 Build the DSN for the RT database. Doesn't take any parameters, draws all that

-----------------------------------------------------------------------


More information about the rt-commit mailing list