Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of "Software caused connection abort" messages appearing in apache log #119

Open
drtjmb opened this issue Aug 12, 2013 · 13 comments
Open

Lots of "Software caused connection abort" messages appearing in apache log #119

drtjmb opened this issue Aug 12, 2013 · 13 comments

Comments

@drtjmb
Copy link
Member

@drtjmb drtjmb commented Aug 12, 2013

We are correctly trapping the client abort in an eval {} but I think the error message from apache has changed in recent versions / is different is some versions?

eg - Apache 2.2.22-1ubuntu1.4 message is:

:Apache2 IO write: (103) Software caused connection abort at [...]

which won't match the regexp in Apache::Storage::handler():

                # eval threw an error
                # If the software (web client) stopped listening
                # before we stopped sending then that's not a fail.
                # even if $rv was not set
                if( $@ !~ m/^Software caused connection abort/ )
                {
                        EPrints::abort( "Error in file retrieval: $@" );
                }
@MrkGrgsn
Copy link
Contributor

@MrkGrgsn MrkGrgsn commented Aug 13, 2013

Our error log (3.2.7) is also full of these errors. Apache is 2.2.7 on RHEL5 64bit.

@drtjmb
Copy link
Member Author

@drtjmb drtjmb commented Aug 13, 2013

Can you try changing the regexp (remove the '^').

I think EPrints should suppress these messages from the log but the
regexp is failing to match.

On 13/08/13 01:01, Mark Gregson wrote:

Our error log (3.2.7) is also full of these errors. Apache is 2.2.7 on
RHEL5 64bit.


Reply to this email directly or view it on GitHub
#119 (comment) Bug
from
https://github.com/notifications/beacon/L17L0tPPBiaot5bV7knnxvPLGwaGUFk9KyzrwFTrEm2CJAmYU7e-C5SihRj5RGcP.gif

Timothy Miles-Board
EPrints Services
School of Electronics and Computer Science
University of Southampton, UK
+44 (0)23 8059 3980 tmb@ecs.soton.ac.uk
http://www.eprints.org/services/
Consultancy - Training - Hosting

@jesusbagpuss
Copy link
Contributor

@jesusbagpuss jesusbagpuss commented Aug 13, 2013

Is masking these the right option under all circumstances?

I’ve noticed them in our logs too, but never got to the bottom of whether I should be concerned about them…

From: Tim Miles-Board [mailto:notifications@github.com]
Sent: 13 August 2013 09:53
To: eprints/eprints
Subject: Re: [eprints] Lots of "Software caused connection abort" messages appearing in apache log (#119)

Can you try changing the regexp (remove the '^').

I think EPrints should suppress these messages from the log but the
regexp is failing to match.

On 13/08/13 01:01, Mark Gregson wrote:

Our error log (3.2.7) is also full of these errors. Apache is 2.2.7 on
RHEL5 64bit.


Reply to this email directly or view it on GitHub
#119 (comment) Bug
from
https://github.com/notifications/beacon/L17L0tPPBiaot5bV7knnxvPLGwaGUFk9KyzrwFTrEm2CJAmYU7e-C5SihRj5RGcP.gif

Timothy Miles-Board
EPrints Services
School of Electronics and Computer Science
University of Southampton, UK
+44 (0)23 8059 3980 tmb@ecs.soton.ac.ukmailto:tmb@ecs.soton.ac.uk
http://www.eprints.org/services/
Consultancy - Training - Hosting


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-22551208.

@drtjmb
Copy link
Member Author

@drtjmb drtjmb commented Aug 13, 2013

Same problem appears in perl_lib/EPrints/Page/Text.pm in 3.2:

 60         eval { print $self->{page_text}; };
 61         if( $@ && $@ !~ m/^Software caused connection abort/ )
 62         {
 63                 EPrints::abort( "Error in send_page: $@" );
 64         }

@sebastfr
Copy link

@sebastfr sebastfr commented Aug 13, 2013

Page.pm also throws that error on 3.3

               if( $@ !~ m/^Software caused connection abort/ )
                {
                        EPrints::abort( "Error in send_page: $@" );
                }
                else
                {
                        die $@;
                }

But anyway, which behaviour would you like to see here? This error is caused by the client closing the socket so it doesn't seem to be a major problem.

@jesusbagpuss
Copy link
Contributor

@jesusbagpuss jesusbagpuss commented Aug 13, 2013

As I said, I never understood whether I should be worried about these or not. If it’s always caused by a client closing the socket, yes, throw it away.
If there are other things that could cause it (someone like me doing some bad perl ;o), it might be useful?

If it’s always a useless error, why is it generated?

Cheers,
John

From: Sebastien Francois [mailto:notifications@github.com]
Sent: 13 August 2013 11:45
To: eprints/eprints
Cc: John Salter
Subject: Re: [eprints] Lots of "Software caused connection abort" messages appearing in apache log (#119)

Page.pm also throws that error on 3.3

           if( $@ !~ m/^Software caused connection abort/ )

            {

                    EPrints::abort( "Error in send_page: $@" );

            }

            else

            {

                    die $@;

            }

But anyway, which behaviour would you like to see here? This error is caused by the client closing the socket so it doesn't seem to be a major problem.


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-22556477.

@drtjmb
Copy link
Member Author

@drtjmb drtjmb commented Aug 13, 2013

It's generated when apache tries to write to a connection that's already
been closed by a client.

EPrints does the right thing - if when writing to a connection the
client closes the connection it just catches that exception and ends
silently.

The bug is that it is not in fact silent because the regexp does not
match - either we never got it right in the first place or it used to
work but now the message has changed in apache (instead of starting with
"Software caused connection abort" that error is prefixed with some
additional info - see the entries from the log that I pasted).

So fix as far as I can see is just to remove the '^' from the regexp in
both Storage.pm and Page.pm.

On 13/08/13 11:50, jesusbagpuss wrote:

As I said, I never understood whether I should be worried about these or
not. If it’s always caused by a client closing the socket, yes, throw
it away.
If there are other things that could cause it (someone like me doing
some bad perl ;o), it might be useful?

If it’s always a useless error, why is it generated?

Cheers,
John

From: Sebastien Francois [mailto:notifications@github.com]
Sent: 13 August 2013 11:45
To: eprints/eprints
Cc: John Salter
Subject: Re: [eprints] Lots of "Software caused connection abort"
messages appearing in apache log (#119)

Page.pm also throws that error on 3.3

if( $@ !~ m/^Software caused connection abort/ )

{

EPrints::abort( "Error in send_page: $@" );

}

else

{

die $@;

}

But anyway, which behaviour would you like to see here? This error is
caused by the client closing the socket so it doesn't seem to be a major
problem.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/119#issuecomment-22556477.


Reply to this email directly or view it on GitHub
#119 (comment) Bug
from
https://github.com/notifications/beacon/L17L0tPPBiaot5bV7knnxvPLGwaGUFk9KyzrwFTrEm2CJAmYU7e-C5SihRj5RGcP.gif

Timothy Miles-Board
EPrints Services
School of Electronics and Computer Science
University of Southampton, UK
+44 (0)23 8059 3980 tmb@ecs.soton.ac.uk
http://www.eprints.org/services/
Consultancy - Training - Hosting

@sebastfr
Copy link

@sebastfr sebastfr commented Aug 13, 2013

Note that in 3.3, Page.pm will throw that error, always: either via EPrints::abort() or via die(). My understanding is that code execution must stop if the page isn't successfully sent to the client for whatever reason.

@UmbrellaDish
Copy link

@UmbrellaDish UmbrellaDish commented Nov 19, 2013

Hi, I suspect that correcting or rather suppressing this error at logging level is not quite sufficient on a larger scale. The callback routine in said Storage.pm module is just sub { print $[0] }, but what can $[0] be? Can it be a whole PDF stream of, say, some hundreds of megabytes? If that is the case, syswrite() instead of print() approach seems preferable to me since it would write $buffersize bytes at once only, thus it would be less data the system tries to write to a socket suddenly closed, enabling apache to destroy the invalidated response sooner and to be, in the end, more responsive when exposed to parallelized downloading, badly designed crawlers and alike.

@sebastfr
Copy link

@sebastfr sebastfr commented Nov 19, 2013

By default it would be Plugin::Storage::Local::retrieve running the following:

        my $buffer;
        my $bsize = $n > 65536 ? 65536 : $n;
        while(sysread($fh,$buffer,$bsize))
        {
                $rc &&= &$f($buffer);
                last unless $rc;

$f = sub { print $[0] } so $[0] is $buffer above, enclosed in a sysread with default read size of 64kb. So the behaviour seems correct i.e. it won't try to write to a closed socket.

@UmbrellaDish
Copy link

@UmbrellaDish UmbrellaDish commented Nov 19, 2013

Hi, thank you for replaying so soon, but then is STDOUT binmode and/or autoflushing ($|=1)? As far as i know, print is buffering internally as well to flush not until newline, so simply subsequent print() would be of no avail. But in modperl environment, autoflush might well be on by default, dunno.

@sebastfr
Copy link

@sebastfr sebastfr commented Nov 19, 2013

Wouldn't print's buffer flush when the sub {} it's enclosed in returns?

Cos the code isn't:

while() {
print $CHUNK;
}

but

while() {
&sub{ print $CHUNK; }
}

@UmbrellaDish
Copy link

@UmbrellaDish UmbrellaDish commented Nov 20, 2013

No, that doesn't matter.

% perl -e '@a = qw(please imagine a very long bytestream here with no newline); $func = sub { print $_[0] }; while ( my $snippet = shift @a ) { warn "dummy output to stderr"; $func->($snippet); }'
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
dummy output to stderr at -e line 1.
pleaseimagineaverylongbytestreamherewithnonewline

phluid61 added a commit to QUTlib/eprints that referenced this issue Jul 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants