[Rt-devel] rt-mailgate issue: Empty Tickets created if Attachment insert fails

Andrés Schiavo andresschiavo at gmail.com
Fri Jul 9 05:55:33 EDT 2010


Hi, I'm currently working with a RT 3 instance and I've found that some
Tickets could be created with missing content under specific situations.
This is my scenario:
* RT 3.8.7 runnig on RHEL5 with perl 5.8.8
* Oracle 10g database
* External mail server and fetchmail to recover emails

This RT instance is quite special, we recive a lot of spam (we are working
to fix it) and the database grows quickly. During working days our
monitoring agents alert us about reaching  database space limit, but if this
happen on weekend, nobody extends de DB until Monday.
Because of Spam we have configured fetchmail with "no keep" option, so if
Ticket creation fails and fetchmail does not recieve an error return code
the information of the email is lost.
I know that this are a lot of "special situations" but I think that
rt-mailgate should return non zero result when RT couldn't create the Ticket
correctly.
I haven't try to reproduce with other databases than Oracle, but I've
reproduce this behavior on two different Oracle instances
This are the steps to reproduce the issue:

When rt database tablesapce is full, fetchmail try to recover an email (with
an attachment or an html email).
Ticket is created but we end up with no attach or no text if email was html.
Fetchmail recive a 0 ret code and erase email from server.

I've attach the rt log when attachment insert fails.

I don't know if this is a bug or that's the way it's supposed to work, but
we can't loose the email information.
If this is a bug, I think that could be generated by the scope of the
variable $id in this code (Attachment_Overlay line 140)

    # If a message has no bodyhandle, that means that it has subparts (or
appears to)
    # and we should act accordingly.
    unless ( defined $Attachment->bodyhandle ) {
        my ($id) = $self->SUPER::Create(
            TransactionId => $args{'TransactionId'},
            Parent        => $args{'Parent'},
            ContentType   => $Attachment->mime_type,
            Headers       => $head,
            MessageId     => $MessageId,
            Subject       => $Subject,
        );

        unless ($id) {
            $RT::Logger->crit("Attachment insert failed - ".
$RT::Handle->dbh->errstr);
        }

        foreach my $part ( $Attachment->parts ) {
            my $SubAttachment = new RT::Attachment( $self->CurrentUser );
            my ($id) = $SubAttachment->Create(
                TransactionId => $args{'TransactionId'},
                Parent        => $id,
                Attachment    => $part,
            );
            unless ($id) {
                $RT::Logger->crit("Attachment insert failed: ".
$RT::Handle->dbh->errstr);
            }
        }
        return ($id);
    }

    #If it's not multipart
    else {

        my ($ContentEncoding, $Body) = $self->_EncodeLOB(
            $Attachment->bodyhandle->as_string,


If the first SUPER::Create is successfull, the $id value isn't undef, but
within the foreach loop, if an error ocurred adding Subattachments the crit
message is printed because the inner $id is undef, but the returned value is
the outer $id that is not undef, so the Ticket is created despite the error
adding a subattachment. Adding a return($id) inside the foreach loop solves
the problem an RT knows that Ticket can not be completly created.

This post is too long and don't want to add more info (specially with this
terrible bad english), but despite the error returned to rt-mailgate when
Ticket creation fails, it tells fetchmail that everything is ok and email is
deleted. I've made an ugly hack to make it work, but I think that
check_for_failure() in rt-mailgate could get te correct return code, I'm not
a perl expert and couldn't make it work, any help?

Anyway, do you think that this is a bug or a feature?
Best regards.
Andres.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-devel/attachments/20100709/b9d848d0/attachment-0001.html>
-------------- next part --------------
[Thu Jul  8 14:04:59 2010] [debug]: About to think about scrips for transaction #2510 (/opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm:163)
[Thu Jul  8 14:04:59 2010] [debug]: About to think about scrips for transaction #2511 (/opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm:163)
[Thu Jul  8 14:05:00 2010] [debug]: Max size is 100000000 (/opt/rt3/bin/../lib/RT/Record.pm:743)
[Thu Jul  8 14:05:01 2010] [warning]: DBD::Oracle::st execute failed: ORA-12952: The request exceeds the maximum allowed database size of 4 GB (DBD ERROR: OCILobWrite in post_execute_lobs) [for Statement "INSERT INTO Attachments (Subject, Filename, ContentType, Headers, Creator, MessageId, Parent, Created, id, Content, ContentEncoding, TransactionId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" with ParamValues: :p1='', :p10='UEsDBAoDAAAAAARybDwAAAAAAAAAAAAAAAAZAAAATWF0ZXJpYWxlcyBDdXJzbyBQbGV0dGFjL1BL
AwQKAwAAAACLmWg8AAAAAAAAAAAAAAAAIQAAAE1hdGVyaWFsZXMgQ3Vyc28gUGxldHRhYy9BcHVu
dGVzL1BLAwQUAwAACABlYGg85LZASpMtAwAcPAMALwAAAE1hdGVyaWFsZXMgQ3Vyc28gUGxldHRh
Yy9BcHVudGVzLzAwIFBvcnRhZGEucGRmlFljeCVNFr5xcmPbtjWx7RsbN7YxMSa2bZsT2/jiiSc2
J5PsZKLNevfZ/bOn+0dXVdc5p6qP3i5qVUlpZnYWLiD1cOlwz3D7cAGQg4yNzMnMFigoyKoIdrRy
tybj/OhRZ5W2sXcHu7JK25u6gyXB5k4WYGFhoJu7K9jUAeidGw6ajiZkR+t5ZnRHqdV+VVWACjXh
bSfvxEfiZ+J3IEFbC9tWCBBZSb7KcrmEHma7tvHQ1tZkrKd/MeqNiDQmWNSTUENxMh6u8No7sSU1
gmKvY2brKyOrgm7fe3nFTuoh2bBJ+MOtwFjrT6RGXPYB4f6M7r1SCeO3j/4P3jrYuhkmCzVEfWHP
xDArzr8euapBJG7VXlyW9V4clk157wc6NlwP2goaJtbBDtPfGAJkpXP5jh7VaY49kl6fbl2kkOH1
CBruEWDK11xk2Md0UEXKW5O/CaoIhDy0y26SaD3HnGEsgLx58s37AkJGVKhmE23kIhe4Lp95prFk
tVLi8gpeguaJv9qFtie6ODCl85t/+jW4FvkVMgzCEFJOUGyc1DF3HvnUWWz6DyFjvzfMLiEMGWzi
ZSK8Hd3oSKRkSYC8+hGXfHqOCR1hJi2HqB6Oil7Mk85l7YxUWfDA3l1sTZoyFJNk2aDJvO5GZ6su
dkeig8O4wFeEW91cz0R9vikoM6Knpo1IG6ykIj2S8A0N9oInd08ky5nKK7k8jK9oR+0VwsB...', :p11='base64', :p12='2512', :p2='file.zip', :p3='application/zip', :p4='Content-Type: application/zip
content-disposition: attachment; filename="file.zip"
Content-Transfer-Encoding: base64
', :p5='70', :p6='', :p7='1445', :p8='2010-07-08 14:05:00', :p9='1447'] at /usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle.pm line 509. (/usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle.pm:509)
[Thu Jul  8 14:05:02 2010] [warning]: RT::Handle=HASH(0x7ffb528a8330) couldn't execute the query 'INSERT INTO Attachments (Subject, Filename, ContentType, Headers, Creator, MessageId, Parent, Created, id, Content, ContentEncoding, TransactionId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' at /usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle.pm line 522
        DBIx::SearchBuilder::Handle::SimpleQuery('RT::Handle=HASH(0x7ffb528a8330)', 'INSERT INTO Attachments (Subject, Filename, ContentType, Head...', '', 'file.zip', 'application/zip', 'HASH(0x7ffb5041d0a0)', 70, '', 1445, ...) called at /usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle.pm line 357
        DBIx::SearchBuilder::Handle::Insert('RT::Handle=HASH(0x7ffb528a8330)', 'Attachments', 'Subject', '', 'Filename', 'file.zip', 'ContentType', 'application/zip', 'Headers', ...) called at /usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Handle/Oracle.pm line 107
        DBIx::SearchBuilder::Handle::Oracle::Insert('RT::Handle=HASH(0x7ffb528a8330)', 'Attachments', 'Subject', '', 'ContentType', 'application/zip', 'Filename', 'file.zip', 'Headers', ...) called at /usr/lib/perl5/site_perl/5.8.8/DBIx/SearchBuilder/Record.pm line 1293
        DBIx::SearchBuilder::Record::Create('RT::Attachment=HASH(0x7ffb5611b230)', 'Subject', '', 'Filename', 'file.zip', 'ContentType', 'application/zip', 'Headers', 'Content-Type: application/zip\x{a}content-disposition: attachment...', ...) called at /opt/rt3/bin/../lib/RT/Record.pm line 289
        RT::Record::Create('RT::Attachment=HASH(0x7ffb5611b230)', 'TransactionId', 2512, 'ContentType', 'application/zip', 'ContentEncoding', 'base64', 'Parent', 1445, ...) called at /opt/rt3/bin/../lib/RT/Attachment_Overlay.pm line 178
        RT::Attachment::Create('RT::Attachment=HASH(0x7ffb5611b230)', 'TransactionId', 2512, 'Parent', 1445, 'Attachment', 'MIME::Entity=HASH(0x7ffb5544c9c0)') called at /opt/rt3/bin/../lib/RT/Attachment_Overlay.pm line 158
        RT::Attachment::Create('RT::Attachment=HASH(0x7ffb5613f2c0)', 'TransactionId', 2512, 'Attachment', 'MIME::Entity=HASH(0x7ffb5543dd80)') called at /opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm line 514
        RT::Transaction::_Attach('RT::Transaction=HASH(0x7ffb560d8e90)', 'MIME::Entity=HASH(0x7ffb5543dd80)') called at /opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm line 154
        RT::Transaction::Create('RT::Transaction=HASH(0x7ffb560d8e90)', 'ObjectId', 522, 'ObjectType', 'RT::Ticket', 'TimeTaken', 0, 'Type', 'Create', ...) called at /opt/rt3/bin/../lib/RT/Record.pm line 1457
        RT::Record::_NewTransaction('RT::Ticket=HASH(0x7ffb56099900)', 'Type', 'Create', 'TimeTaken', 0, 'MIMEObj', 'MIME::Entity=HASH(0x7ffb5543dd80)', 'CommitScrips', 1, ...) called at /opt/rt3/bin/../lib/RT/Ticket_Overlay.pm line 656
        RT::Ticket::Create('RT::Ticket=HASH(0x7ffb56099900)', 'Queue', 3, 'Subject', 'Incidencia con adjunto 81', 'Requestor', 'ARRAY(0x7ffb51813920)', 'Cc', 'ARRAY(0x7ffb51813900)', ...) called at /opt/rt3/bin/../lib/RT/Interface/Email.pm line 1494
        RT::Interface::Email::Gateway('HASH(0x7ffb4fc68ae0)') called at /opt/rt3/share/html/REST/1.0/NoAuth/mail-gateway line 61
        HTML::Mason::Commands::__ANON__('SessionType', 'REST', 'action', 'correspond', 'queue', 'General', 'message', 'Return-Path: <root at localhost>\x{a}Received: from murde...') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm line 135
        HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x7ffb56403540)', 'SessionType', 'REST', 'action', 'correspond', 'queue', 'General', 'message', 'Return-Path: <root at localhost>\x{a}Received: from murde...', ...) called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 1297
        eval {...} called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 1292
        HTML::Mason::Request::comp('undef', 'undef', 'undef', 'SessionType', 'REST', 'action', 'correspond', 'queue', 'General', ...) called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 481
        eval {...} called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 481
        eval {...} called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/Request.pm line 433
        HTML::Mason::Request::exec('RT::Interface::Web::Request=HASH(0x7ffb5341bfe0)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm line 168
        HTML::Mason::Request::ApacheHandler::exec('RT::Interface::Web::Request=HASH(0x7ffb5341bfe0)') called at /usr/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm line 825
        HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0x7ffb4fc27470)', 'Apache2::RequestRec=SCALAR(0x7ffb528a8540)') called at /opt/rt3/bin/webmux.pl line 166
        eval {...} called at /opt/rt3/bin/webmux.pl line 166
        RT::Mason::handler('Apache2::RequestRec=SCALAR(0x7ffb528a8540)') called at -e line 0
        eval {...} called at -e line 0 (/usr/lib/perl5/5.8.8/Carp.pm:272)
[Thu Jul  8 14:05:02 2010] [crit]: Attachment insert failed: ORA-12952: The request exceeds the maximum allowed database size of 4 GB (DBD ERROR: OCILobWrite in post_execute_lobs) (/opt/rt3/bin/../lib/RT/Attachment_Overlay.pm:191)
[Thu Jul  8 14:05:02 2010] [crit]: Attachment insert failed: ORA-12952: The request exceeds the maximum allowed database size of 4 GB (DBD ERROR: OCILobWrite in post_execute_lobs) (/opt/rt3/bin/../lib/RT/Attachment_Overlay.pm:164)
[Thu Jul  8 14:05:02 2010] [debug]: About to think about scrips for transaction #2512 (/opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm:163)
[Thu Jul  8 14:05:02 2010] [debug]: About to prepare scrips for transaction #2512 (/opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm:167)
[Thu Jul  8 14:05:02 2010] [debug]: Found 3 scrips for TransactionCreate stage with applicable type(s) Create (/opt/rt3/bin/../lib/RT/Scrips_Overlay.pm:370)
[Thu Jul  8 14:05:04 2010] [debug]: About to commit scrips for transaction #2512 (/opt/rt3/bin/../local/lib/RT/Transaction_Overlay.pm:187)
[Thu Jul  8 14:05:04 2010] [debug]: Committing scrip #4 on txn #2512 of ticket #522 (/opt/rt3/bin/../lib/RT/Scrips_Overlay.pm:190)
[Thu Jul  8 14:05:04 2010] [debug]: Calling SetRecipientDigests for transaction RT::Transaction=HASH(0x7ffb5041d0e0), id 2512 (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:630)
[Thu Jul  8 14:05:04 2010] [debug]: Working on mailfield Cc; recipients are  (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:646)
[Thu Jul  8 14:05:04 2010] [debug]: Subject: [General #522] Incidencia con adjunto 81
From: General at localhost
Reply-To: General at localhost
In-Reply-To: <20100707162617.GA12488 at localhost.localhost>
References: <RT-Ticket-522 at MIR> <20100707162617.GA12488 at localhost.localhost>
Message-ID: <rt-3.8.7-5764-1278597903-256.522-4-0 at MIR>
Precedence: bulk
X-RT-Loop-Prevention: General
RT-Ticket: General #522
Managed-by: RT 3.8.7 (http://www.bestpractical.com/rt/)
RT-Originator: root at localhost
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8 (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:653)
[Thu Jul  8 14:05:04 2010] [debug]: Removing deferred recipients from Cc: line (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:676)
[Thu Jul  8 14:05:04 2010] [debug]: Setting deferred recipients for attribute creation (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:685)
[Thu Jul  8 14:05:04 2010] [debug]: Working on mailfield Bcc; recipients are  (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:646)
[Thu Jul  8 14:05:04 2010] [debug]: Subject: [General #522] Incidencia con adjunto 81
From: General at localhost
Reply-To: General at localhost
In-Reply-To: <20100707162617.GA12488 at localhost.localhost>
References: <RT-Ticket-522 at MIR> <20100707162617.GA12488 at localhost.localhost>
Message-ID: <rt-3.8.7-5764-1278597903-256.522-4-0 at MIR>
Precedence: bulk
X-RT-Loop-Prevention: General
RT-Ticket: General #522
Managed-by: RT 3.8.7 (http://www.bestpractical.com/rt/)
RT-Originator: root at localhost
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8 (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:653)
[Thu Jul  8 14:05:04 2010] [debug]: Removing deferred recipients from Bcc: line (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:676)
[Thu Jul  8 14:05:04 2010] [debug]: Setting deferred recipients for attribute creation (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:685)
[Thu Jul  8 14:05:04 2010] [debug]: No recipients found for deferred delivery on transaction #2512 (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:698)
[Thu Jul  8 14:05:04 2010] [info]: <rt-3.8.7-5764-1278597903-256.522-4-0 at MIR> #522/2512 - Scrip 4 On Create Notify AdminCcs (/opt/rt3/bin/../lib/RT/Action/SendEmail.pm:300)
[Thu Jul  8 14:05:04 2010] [info]: <rt-3.8.7-5764-1278597903-256.522-4-0 at MIR> No recipients found. Not sending. (/opt/rt3/bin/../lib/RT/Interface/Email.pm:342)
[Thu Jul  8 14:05:04 2010] [debug]: Committing scrip #11 on txn #2512 of ticket #522 (/opt/rt3/bin/../lib/RT/Scrips_Overlay.pm:190)
[Thu Jul  8 14:05:04 2010] [info]: Ticket 522 created in queue 'General' by root at localhost (/opt/rt3/bin/../lib/RT/Ticket_Overlay.pm:667)
[Thu Jul  8 14:05:04 2010] [debug]: Found 1 scrips for TransactionBatch stage with applicable type(s)  (/opt/rt3/bin/../lib/RT/Scrips_Overlay.pm:370)


More information about the rt-devel mailing list