Help! Methods randomly ending

Hi,

Relatively inexperienced RoR guy here (but decided to use it for the
challenge!).

I have a website which takes online credit card payments. I have a very
bad problem though with it though. My “place_order” method which
actually performs the payment transaction and saves the order to the
database is not working correctly every time.

Here is some very brief psuedo-code of the method:

def place_order
create Order object
add line items to Order object
if Order.valid?
send XML-RPC call to credit card processing company
if result of XML-RPC call is ok
save Order to database
empty cart
redirect to payment_complete page
end
end
rescue XMLRPC::FaultException
log XML-RPC error
rescue Exception
log error
end

To help me diagnose my problem i have also put a large number of
logger.info() printouts throughout the method.

Now the problem i have is that from studying my logs it seems like every
now and then, the method just decides to randomly stop at a certain
point. Do rails methods have some kind of timeout where they will just
suddenly die after a certain time?

For me this problem is so bad because what is happening is that the
XML-RPC call is being sent to the credit card company, the method is
then dying; this results in the person being charged for the order but
it not being saved to the database - very bad indeed!

The point in the method where it seems to be halting does not seem to
stay the same - sometimes it is right after the XML-RPC call is made,
and other times it is after the result has been recieved back (but
before the order is saved to the database).

The XML-RPC call to the credit card processing company seems to take
between 2-30 seconds, could this play a factor?

As i said, this is only happening sometimes and the place_order method
works perfectly fine 9/10 times.

When the method was ending i was getting absolutely no error output in
my logs (set at :info level). I have just set my logs to :debug so maybe
that will shed some light on it.

I would be hugely grateful if anyone could help out or give me any
advice what i should do to make a more fault proof method; possibly
going to have to take the site offline if i cant solve this quite fast.

Thanks very much indeed.

Martin Brown.

A bit of extra information i found after digging around in more log
files.

This is a line from my apache error.log:

[Mon Sep 04 08:18:01 2006] [error] [client ...] FastCGI: incomplete
headers (0 bytes) received from server
“/home//.com/*****/public/dispatch.fcgi”, referer:
https://www.****.com/store/checkout

This is the associated line in my production log which caused this error
i assume:

Processing StoreController#place_order (for ... at 2006-09-04
08:17:58) [POST]

So could it be that the apache server throwing this “incomplete header”
error 3 seconds after the post request is causing the place_order method
to die? Any ideas why is the error being thrown in the first place?

Thanks very much!

Martin Brown.

have you considered using the breakpointer and stopping the code then
manually running each line?

Martin Brown wrote:

Here is some very brief psuedo-code of the method:
end
Now the problem i have is that from studying my logs it seems like every
stay the same - sometimes it is right after the XML-RPC call is made,
my logs (set at :info level). I have just set my logs to :debug so maybe

Jeremy W.
Serval Systems Ltd.

www.servalsystems.co.uk http://www.servalsystems.co.uk
Tel: 01342 331940
Fax: 01342 331950

I have not tried using the breakpointer but i have tried testing it
(sending dummy transactions through) myself a large number of times and
i cannot recreate the problem for myself.

It is the random nature of this problem which worries me so much!

Can anyone confirm whether there are any in built timeouts in rails
whereby methods will only run for a maximum amount of time and will
forcibly exit after this time?

Thanks.

Martin.