Attachment insert failed: MySQL server has gone away

Hello,

My company is fairly new to using RT, about a half a year now, and we
suddenly seem to be having an attachment issue. We are currently using RT
4.0.6 and have been unable to attach images larger than around 1 MB. We
have previously been able to because I had increased the maximum attachment
size in the RT_SiteConfig, http config, and mysql config files. We haven’t
recently made any updates to the system that I am aware of.

I have tried restarting the http and mysql services a couple times, but to
no avail. I can still attach smaller image files, but 1MB seems to be about
the limit. The error message seems to be “Attachment insert failed: MySQL
server has gone away”. After the attachment insert query, it seems to also
fail on a Scrip query but if the sql server HAS gone away, it comes right
back after those two failures. The MySQL log doesn’t appear to have
anything useful from around that time.

The FAQ suggests that if it is not the MaxAttachmentSize then it may be
mod_security, but I don’t believe we use that in our http config and I
don’t see anything about mod_security in the log.

So it appears to be a MySql issue, but MySql doesn’t think anything is
going wrong. Below is the full log message from the error.

[Wed Oct 17 18:20:08 2012] [warning]: DBD::mysql::st execute failed: MySQL
server has gone away at /usr/local/share/perl5/DBIx/SearchBuilder/Handle.pm
line 587. (/usr/local/share/perl5/DBIx/SearchBuilder/Handle.pm:587)

[Wed Oct 17 18:20:08 2012] [warning]: RT::Handle=HASH(0x7797a60) couldn’t
execute the query ‘INSERT INTO Attachments (Subject, ContentType, Filename,
Headers, MessageId, Creator, Parent, Created, ContentEncoding, Content,
TransactionId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ at
/usr/local/share/perl5/DBIx/SearchBuilder/Handle.pm line 600.

DBIx::SearchBuilder::Handle::SimpleQuery(‘RT::Handle=HASH(0x7797a60)’,
‘INSERT INTO Attachments (Subject, ContentType, Filename, Head…’,
‘DH_Test_IMG_0092’, ‘application/octet-stream’, ‘DH_Test_IMG_0092’,
‘MIME-Version: 1.0\x{a}Subject: DH_Test_IMG_0092\x{a}X-Mailer: MIME-to…’,
’’, 38, 5845, …) called at
/usr/local/share/perl5/DBIx/SearchBuilder/Handle.pm line 350

DBIx::SearchBuilder::Handle::Insert(‘RT::Handle=HASH(0x7797a60)’,
‘Attachments’, ‘Subject’, ‘DH_Test_IMG_0092’, ‘ContentType’,
‘application/octet-stream’, ‘Filename’, ‘DH_Test_IMG_0092’, ‘Headers’, …)
called at /usr/local/share/perl5/DBIx/SearchBuilder/Handle/mysql.pm line 36

DBIx::SearchBuilder::Handle::mysql::Insert(‘RT::Handle=HASH(0x7797a60)’,
‘Attachments’, ‘Subject’, ‘DH_Test_IMG_0092’, ‘ContentType’,
‘application/octet-stream’, ‘Filename’, ‘DH_Test_IMG_0092’, ‘Headers’, …)
called at /usr/local/share/perl5/DBIx/SearchBuilder/Record.pm line 1292

DBIx::SearchBuilder::Record::Create(‘RT::Attachment=HASH(0x7d38bc0)’,
‘Subject’, ‘DH_Test_IMG_0092’, ‘Filename’, ‘DH_Test_IMG_0092’,
‘ContentType’, ‘application/octet-stream’, ‘Headers’, ‘MIME-Version:
1.0\x{a}Subject: DH_Test_IMG_0092\x{a}X-Mailer: MIME-to…’, …) called at
/usr/local/rt/sbin/…/lib/RT/Record.pm line 316

RT::Record::Create(‘RT::Attachment=HASH(0x7d38bc0)’, ‘TransactionId’,
12268, ‘ContentType’, ‘application/octet-stream’, ‘ContentEncoding’,
‘none’, ‘Parent’, 5845, …) called at
/usr/local/rt/sbin/…/lib/RT/Attachment.pm line 193

RT::Attachment::Create(‘RT::Attachment=HASH(0x7d38bc0)’, ‘TransactionId’,
12268, ‘Parent’, 5845, ‘Attachment’, ‘MIME::Entity=HASH(0x7e27b98)’) called
at /usr/local/rt/sbin/…/lib/RT/Attachment.pm line 172

RT::Attachment::Create(‘RT::Attachment=HASH(0x7875a48)’, ‘TransactionId’,
12268, ‘Attachment’, ‘MIME::Entity=HASH(0x7e28690)’) called at
/usr/local/rt/sbin/…/lib/RT/Transaction.pm line 543

RT::Transaction::_Attach(‘RT::Transaction=HASH(0x7d41d80)’,
‘MIME::Entity=HASH(0x7e28690)’) called at
/usr/local/rt/sbin/…/lib/RT/Transaction.pm line 160

RT::Transaction::Create(‘RT::Transaction=HASH(0x7d41d80)’, ‘ObjectId’, 155,
‘ObjectType’, ‘RT::Ticket’, ‘TimeTaken’, ‘’, ‘Type’, ‘Comment’, …) called
at /usr/local/rt/sbin/…/lib/RT/Record.pm line 1459

RT::Record::_NewTransaction(‘RT::Ticket=HASH(0x7e27df0)’, ‘Type’,
‘Comment’, ‘Data’, ‘No Subject’, ‘TimeTaken’, ‘’, ‘MIMEObj’,
‘MIME::Entity=HASH(0x7e28690)’, …) called at
/usr/local/rt/sbin/…/lib/RT/Ticket.pm line 2243

RT::ticket::_RecordNote(‘RT::Ticket=HASH(0x7e27df0)’, ‘DryRun’, 0,
‘BccMessageTo’, ‘’, ‘CcMessageTo’, ‘’, ‘NoteType’, ‘Comment’, …) called
at /usr/local/rt/sbin/…/lib/RT/Ticket.pm line 2103

RT::ticket::Comment(‘RT::Ticket=HASH(0x7e27df0)’, ‘BccMessageTo’, ‘’,
‘CcMessageTo’, ‘’, ‘MIMEObj’, ‘MIME::Entity=HASH(0x7e28690)’, ‘TimeTaken’,
’’, …) called at /usr/local/rt/sbin/…/lib/RT/Interface/Web.pm line 1859

HTML::Mason::Commands::ProcessUpdateMessage(‘ARGSRef’, ‘HASH(0x7e074d8)’,
‘Actions’, ‘ARRAY(0x7def938)’, ‘TicketObj’, ‘RT::Ticket=HASH(0x7e27df0)’)
called at /usr/local/rt/share/html/Ticket/Display.html line 164

HTML::Mason::Commands::ANON(‘TicketObj’, ‘RT::Ticket=HASH(0x7e27df0)’,
‘Articles-Include-Article-Named’, ‘’, ‘UpdateCc’, ‘’,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘SubmitTicket’, …)
called at /usr/local/share/perl5/HTML/Mason/Component.pm line 138

HTML::Mason::Component::run(‘HTML::Mason::Component::FileBased=HASH(0x7dffa78)’,
‘TicketObj’, ‘RT::Ticket=HASH(0x7e27df0)’,
‘Articles-Include-Article-Named’, ‘’, ‘UpdateCc’, ‘’,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, …) called at
/usr/local/share/perl5/HTML/Mason/Request.pm line 1305

eval {…} called at /usr/local/share/perl5/HTML/Mason/Request.pm line 1295

HTML::Mason::Request::comp(undef, undef, ‘TicketObj’,
‘RT::Ticket=HASH(0x7e27df0)’, ‘Articles-Include-Article-Named’, ‘’,
‘UpdateCc’, ‘’, ‘Object-RT::Ticket-155-CustomField-5-Value’, …) called at
/usr/local/rt/share/html/Ticket/Update.html line 328

HTML::Mason::Commands::ANON(‘Object-RT::Ticket-155-CustomField-5-Value’,
‘Any’, ‘UpdateCc’, ‘’, ‘Articles-Include-Article-Named’, ‘’,
‘Articles_Content’, ‘’, ‘SubmitTicket’, …) called at
/usr/local/share/perl5/HTML/Mason/Component.pm line 138

HTML::Mason::Component::run(‘HTML::Mason::Component::FileBased=HASH(0x7cf7620)’,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, ‘Articles_Content’, ‘’, …) called
at /usr/local/share/perl5/HTML/Mason/Request.pm line 1305

eval {…} called at /usr/local/share/perl5/HTML/Mason/Request.pm line 1295

HTML::Mason::Request::comp(undef, undef, undef,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, …) called at
/usr/local/share/perl5/HTML/Mason/Request.pm line 958

HTML::Mason::Request::call_next(‘RT::Interface::Web::Request=HASH(0x7d9adb0)’)
called at /usr/local/rt/share/html/Ticket/autohandler line 19

HTML::Mason::Commands::ANON(‘Object-RT::Ticket-155-CustomField-5-Value’,
‘Any’, ‘UpdateCc’, ‘’, ‘Articles-Include-Article-Named’, ‘’,
‘Articles_Content’, ‘’, ‘SubmitTicket’, …) called at
/usr/local/share/perl5/HTML/Mason/Component.pm line 138

HTML::Mason::Component::run(‘HTML::Mason::Component::FileBased=HASH(0x7dbf490)’,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, ‘Articles_Content’, ‘’, …) called
at /usr/local/share/perl5/HTML/Mason/Request.pm line 1305

eval {…} called at /usr/local/share/perl5/HTML/Mason/Request.pm line 1295

HTML::Mason::Request::comp(undef, undef, undef,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, …) called at
/usr/local/rt/sbin/…/lib/RT/Interface/Web.pm line 568

RT::Interface::Web::ShowRequestedPage(‘HASH(0x7da6178)’) called at
/usr/local/rt/sbin/…/lib/RT/Interface/Web.pm line 318

RT::Interface::Web::HandleRequest(‘HASH(0x7da6178)’) called at
/usr/local/rt/share/html/autohandler line 53

HTML::Mason::Commands::ANON(‘Object-RT::Ticket-155-CustomField-5-Value’,
‘Any’, ‘UpdateCc’, ‘’, ‘Articles-Include-Article-Named’, ‘’,
‘Articles_Content’, ‘’, ‘SubmitTicket’, …) called at
/usr/local/share/perl5/HTML/Mason/Component.pm line 138

HTML::Mason::Component::run(‘HTML::Mason::Component::FileBased=HASH(0x77e1848)’,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, ‘Articles_Content’, ‘’, …) called
at /usr/local/share/perl5/HTML/Mason/Request.pm line 1300

eval {…} called at /usr/local/share/perl5/HTML/Mason/Request.pm line 1295

HTML::Mason::Request::comp(undef, undef, undef,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, …) called at
/usr/local/share/perl5/HTML/Mason/Request.pm line 484

eval {…} called at /usr/local/share/perl5/HTML/Mason/Request.pm line 484

eval {…} called at /usr/local/share/perl5/HTML/Mason/Request.pm line 436

HTML::Mason::Request::exec(‘RT::Interface::Web::Request=HASH(0x7d9adb0)’)
called at /usr/local/share/perl5/HTML/Mason/PSGIHandler.pm line 85

eval {…} called at /usr/local/share/perl5/HTML/Mason/PSGIHandler.pm line
85

HTML::Mason::Request::PSGI::exec(‘RT::Interface::Web::Request=HASH(0x7d9adb0)’)
called at /usr/local/share/perl5/HTML/Mason/Interp.pm line 345

HTML::Mason::Interp::exec(undef, undef,
‘Object-RT::Ticket-155-CustomField-5-Value’, ‘Any’, ‘UpdateCc’, ‘’,
‘Articles-Include-Article-Named’, ‘’, ‘Articles_Content’, …) called at
/usr/local/share/perl5/HTML/Mason/PSGIHandler.pm line 48

eval {…} called at /usr/local/share/perl5/HTML/Mason/PSGIHandler.pm line
48

HTML::Mason::PSGIHandler::invoke_mason(‘HTML::Mason::PSGIHandler::Streamy=HASH(0x76b2798)’,
‘HTML::Mason::FakeApache=HASH(0x7d8f938)’, ‘HASH(0x7db06a8)’) called at
/usr/local/share/perl5/HTML/Mason/PSGIHandler/Streamy.pm line 52

HTML::Mason::PSGIHandler::Streamy::ANON(‘CODE(0x7d9ce70)’) called at
/usr/local/rt/sbin/…/lib/RT/Interface/Web/Handler.pm line 263

RT::Interface::Web::Handler::ANON(‘CODE(0x7d9ce70)’) called at
/usr/local/share/perl5/Plack/Util.pm line 301

Plack::Util::ANON(‘CODE(0x7d9f158)’) called at
/usr/local/share/perl5/Plack/Handler/FCGI.pm line 130

Plack::Handler::FCGI::run(‘Plack::Handler::FCGI=HASH(0x7737568)’,
‘CODE(0x76ac918)’) called at /usr/local/share/perl5/Plack/Loader.pm line 84

Plack::Loader::run(‘Plack::Loader=HASH(0x77373a0)’,
‘Plack::Handler::FCGI=HASH(0x7737568)’) called at
/usr/local/share/perl5/Plack/Runner.pm line 263

Plack::runner::run(‘Plack::Runner=HASH(0x73229f0)’, ‘CODE(0x76ac918)’)
called at /usr/local/rt/sbin/rt-server.fcgi line 232

eval {…} called at /usr/local/rt/sbin/rt-server.fcgi line 232
(/usr/local/share/perl5/Carp.pm:103)

[Wed Oct 17 18:20:08 2012] [critical]: Attachment insert failed: MySQL
server has gone away (/usr/local/rt/sbin/…/lib/RT/Attachment.pm:206)

[Wed Oct 17 18:20:08 2012] [critical]: Attachment insert failed: MySQL
server has gone away (/usr/local/rt/sbin/…/lib/RT/Attachment.pm:178)

I am unsure of what to look into next to try and fix the issue. Could
somebody point me in the right direction?

Thanks,

David

My company is fairly new to using RT, about a half a year now, and we
suddenly seem to be having an attachment issue. We are currently using
RT 4.0.6 and have been unable to attach images larger than around 1
MB. We have previously been able to because I had increased the
maximum attachment size in the RT_SiteConfig, http config, and mysql
config files. We haven’t recently made any updates to the system that
I am aware of.

1M is the default max_allowed_packet size for MySQL – I strongly
suspect that you’re hitting that limit, and the failure mode matches
your errors. Show the contents of your my.cnf file?

  • Alex

[snip]

Please keep replies on-list so others can see and benefit from them, as
well as contribute.

The my.cnf file:

[mysqld]

Settings user and group are ignored when systemd is used.

If you need to run mysqld under different user or group,

customize your systemd unit file for mysqld according to the

instructions in http://fedoraproject.org/wiki/Systemd

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Disabling symbolic-links is recommended to prevent assorted security

risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
max_allowed_packet=100M

I agree that that looks not-wrong. Double-check with show variables like 'max_allowed_packet', to be sure.

  • Alex

[snip]

Please keep replies on-list so others can see and benefit from them, as
well as contribute.

The my.cnf file:

[mysqld]

Settings user and group are ignored when systemd is used.

If you need to run mysqld under different user or group,

customize your systemd unit file for mysqld according to the

instructions in http://fedoraproject.org/wiki/Systemd

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Disabling symbolic-links is recommended to prevent assorted security

risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
max_allowed_packet=100M

I agree that that looks not-wrong. Double-check with show variables like 'max_allowed_packet', to be sure.

  • Alex

Final RT training for 2012 in Atlanta, GA - October 23 & 24
http://bestpractical.com/training

We’re hiring! Careers — Best Practical Solutions

Thanks for the suggestion. That was able to lead me in the right
direction. Its a silly mistake, but that variable needs to be in the
[mysqld] section instead of the [mysqld_safe] section of the
configuration. So the my.cnf below works for me:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
max_allowed_packet=100M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Thanks,
David