diff options
author | mkanat%bugzilla.org <> | 2009-03-02 02:21:54 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2009-03-02 02:21:54 +0100 |
commit | a28edf3c2423e748f0919ea7a803324c5b269e40 (patch) | |
tree | 43c64de446c6d0c4f555d5805ae65ac5375ace00 /Bugzilla | |
parent | 60900705412d6512db3eb8bae39da50fc5400a7d (diff) | |
download | bugzilla-a28edf3c2423e748f0919ea7a803324c5b269e40.tar.gz bugzilla-a28edf3c2423e748f0919ea7a803324c5b269e40.tar.xz |
Bug 480001: MySQL 5.1.31 throws an error when you try to SET SESSION max_allowed_packet (and previous versions of MySQL were just ignoring the SET SESSION), so just warn people if their max_allowed_packet is too small
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Config/Attachment.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Config/Common.pm | 19 | ||||
-rw-r--r-- | Bugzilla/DB/Mysql.pm | 36 | ||||
-rw-r--r-- | Bugzilla/Install/DB.pm | 5 |
4 files changed, 42 insertions, 20 deletions
diff --git a/Bugzilla/Config/Attachment.pm b/Bugzilla/Config/Attachment.pm index 2b014deda..f22c01d95 100644 --- a/Bugzilla/Config/Attachment.pm +++ b/Bugzilla/Config/Attachment.pm @@ -68,7 +68,7 @@ sub get_param_list { name => 'maxattachmentsize', type => 't', default => '1000', - checker => \&check_numeric + checker => \&check_maxattachmentsize }, # The maximum size (in bytes) for patches and non-patch attachments. diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm index b6aa1a108..b285b3bc9 100644 --- a/Bugzilla/Config/Common.pm +++ b/Bugzilla/Config/Common.pm @@ -50,6 +50,7 @@ use base qw(Exporter); check_netmask check_user_verify_class check_image_converter check_mail_delivery_method check_notification check_utf8 check_bug_status check_smtp_auth check_theschwartz_available + check_maxattachmentsize ); # Checking functions for the various values @@ -313,6 +314,24 @@ sub check_mail_delivery_method { return ""; } +sub check_maxattachmentsize { + my $check = check_numeric(@_); + return $check if $check; + my $size = shift; + my $dbh = Bugzilla->dbh; + if ($dbh->isa('Bugzilla::DB::Mysql')) { + my (undef, $max_packet) = $dbh->selectrow_array( + q{SHOW VARIABLES LIKE 'max\_allowed\_packet'}); + my $byte_size = $size * 1024; + if ($max_packet < $byte_size) { + return "You asked for a maxattachmentsize of $byte_size bytes," + . " but the max_allowed_packet setting in MySQL currently" + . " only allows packets up to $max_packet bytes"; + } + } + return ""; +} + sub check_notification { my $option = shift; my @current_version = diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index f85bd31f1..f06900f1b 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -44,6 +44,7 @@ package Bugzilla::DB::Mysql; use strict; use Bugzilla::Constants; +use Bugzilla::Install::Util qw(install_string); use Bugzilla::Util; use Bugzilla::Error; use Bugzilla::DB::Schema::Mysql; @@ -101,20 +102,9 @@ sub new { } } - # The "comments" field of the bugs_fulltext table could easily exceed - # MySQL's default max_allowed_packet. Also, MySQL should never have - # a max_allowed_packet smaller than our max_attachment_size. However, - # if we've already set a max_allowed_packet in MySQL bigger than all - # of those, we should keep it. - my (undef, $current_max_allowed) = $self->selectrow_array( - q{SHOW VARIABLES LIKE 'max\_allowed\_packet'}); - my $min_max_allowed_packet = MAX_COMMENTS * MAX_COMMENT_LENGTH; - my $max_allowed_packet = max($min_max_allowed_packet, - $current_max_allowed, - # This parameter is not yet defined when the DB - # is being built for the very first time. - Bugzilla->params->{'maxattachmentsize'} || 0); - $self->do("SET SESSION max_allowed_packet = $max_allowed_packet"); + # Allow large GROUP_CONCATs (largely for inserting comments + # into bugs_fulltext). + $self->do('SET SESSION group_concat_max_len = 128000000'); return $self; } @@ -291,6 +281,24 @@ sub _bz_get_initial_schema { sub bz_setup_database { my ($self) = @_; + # The "comments" field of the bugs_fulltext table could easily exceed + # MySQL's default max_allowed_packet. Also, MySQL should never have + # a max_allowed_packet smaller than our max_attachment_size. So, we + # warn the user here if max_allowed_packet is too small. + my $min_max_allowed = MAX_COMMENTS * MAX_COMMENT_LENGTH; + my (undef, $current_max_allowed) = $self->selectrow_array( + q{SHOW VARIABLES LIKE 'max\_allowed\_packet'}); + # This parameter is not yet defined when the DB is being built for + # the very first time. The code below still works properly, however, + # because the default maxattachmentsize is smaller than $min_max_allowed. + my $max_attachment = (Bugzilla->params->{'maxattachmentsize'} || 0) * 1024; + my $needed_max_allowed = max($min_max_allowed, $max_attachment); + if ($current_max_allowed < $needed_max_allowed) { + warn install_string('max_allowed_packet', + { current => $current_max_allowed, + needed => $needed_max_allowed }) . "\n"; + } + # Make sure the installation has InnoDB turned on, or we're going to be # doing silly things like making foreign keys on MyISAM tables, which is # hard to fix later. We do this up here because none of the code below diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 44ad4c814..ff949f58e 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -3074,11 +3074,6 @@ sub _populate_bugs_fulltext { if (UNIVERSAL::can($dbh, 'sql_group_concat')) { print "Populating bugs_fulltext..."; print " (this can take a long time.)\n"; - # XXX This hack should probably be moved elsewhere. - if ($dbh->isa('Bugzilla::DB::Mysql')) { - $dbh->do('SET SESSION group_concat_max_len = 128000000'); - $dbh->do('SET SESSION max_allowed_packet = 128000000'); - } $dbh->do( q{INSERT INTO bugs_fulltext (bug_id, short_desc, comments, comments_noprivate) |