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.
rtlog.txt (11.3 KB)