Infinity start backend by a cron job

161 views
Skip to first unread message

José Luis Montesinos González

unread,
Jan 9, 2013, 11:46:52 AM1/9/13
to google-a...@googlegroups.com
Hello, I developed an app with GAE/J and I created a cron job like this:

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
  <cron>
    <url>/cron/v1/cleanDB</url>
    <description>Clean Data Base</description>
    <schedule>every day 04:00</schedule>
    <target>clean-db</target>
  </cron>
</cronentries>

Also, I defined this backend:
<backends>
  <backend name="clean-db">
    <class>B1</class>
    <options>
        <dynamic>true</dynamic>
    </options>
  </backend>
</backends>


My cron job and backend are always working fine, but one day when the crob job was woken and the backend must have started, It consumed 46858162ms (13h) and I received this error:

2013-01-05 18:01:00.669 /_ah/start 500 46858162ms 0kb instance=0
    1. I 2013-01-05 18:01:00.669 This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This requ
    2. E 2013-01-05 18:01:00.669 Process terminated because the backend took too long to shutdown.

Then, I received multiples errors every 200ms:

    1. 2013-01-05 18:01:20.370 /cron/v1/cleanDB 503 4ms 0kb AppEngine-Google; (+http://code.google.com/appengine)
      0.1.0.1 - - [05/Jan/2013:09:01:20 -0800] "GET /cron/v1/cleanDB HTTP/1.1" 503 970 - "AppEngine-Google; (+http://code.google.com/appengine)" "clean-bd.categoriasidintel.appspot.com" ms=4 cpu_ms=0 cpm_usd=0.000108 queue_name=__cron task_name=a96f2b757c5cbc0b3811e7a105fe7f0b 

This error consumes my free 9h of backends (I do not allow even billing)

Well, what was the problem? Maybe it was a causal problem, but I am very disappointed with GAE, though I have enabled billing, how much would it cost?
Is there any way to prevent this kind of thing?

Thanks

Takashi Matsuo

unread,
Jan 9, 2013, 1:55:40 PM1/9/13
to google-a...@googlegroups.com

Hi José,

Your cron entry has a target 'clean-db', but the log indicates the backend name is clean-bd. Which is correct?
How long does the cron job take BTW?
I think the reason why your free quota was consumed is that the cron job took 13h, wasn't it?

However, those errors seem weird to me too. I'll look into them and keep you updated.


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/y_b71bjBtZ0J.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.



--
Takashi Matsuo | Developers Advocate | tma...@google.com

Takashi Matsuo

unread,
Jan 9, 2013, 2:04:56 PM1/9/13
to google-a...@googlegroups.com

Okay, I noticed that the cron job in question was stopped because you had consumed the daily free quota for the backend usage on Jan 5.

I think the following errors were made by the retry logic of our task queue service. Is that the case? Are you invoking any tasks within the cron job itself? If so, those tasks were failed because there was no quota for the backend.

José Luis Montesinos González

unread,
Jan 10, 2013, 3:44:09 AM1/10/13
to google-a...@googlegroups.com
First of all, thanks for your answer Takashi Matsuo
1) The cron job name, and the URL, etc. are clean-bd, beacuse in spaish BD is Base de Datos, so I rewrote the post of the forum to be understood in English ( DB = Data Base). But the name and the logic are correct.
2) I don't know why the backend takes 13h if I only have 9h free, but I know that it was stopped because the backend had consumed the daily free quouta.
3) This cron job is only executed one time at 4:00 every day and It takes 1-5 seconds. Also, neither other tasks nor anything use a backend. Only, this cron job uses the backend 1-5 secondos per day.
4) The cron job only reads some data from Data Base and removes some values. (But in this case, the cron job was never exectued)

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
                        //LOAD AND SAVE DATA FROM DB
       }


pdknsk

unread,
Jan 10, 2013, 4:52:55 AM1/10/13
to Google App Engine
I've had the same problem. It eventually resolved itself after
randomly occurring for weeks. I've made some code changes (which
seemed unrelated) so I cannot say for sure if Google made some changes
or I did by chance. Do you use transactions in your code? I seem to
remember that I had a massive transaction near the end of the handler
which I subsequently split into smaller writes and tasks.

It's fairly easy to debug. Just add logging to the last line of the
handler (or whatever the equivalent is in Java). In my case the
logging occured, but the backend didn't stop, even though there was
obviously no code left. My theory was that the backend didn't get the /
_ah/stop/ signal for whatever reason.

José Luis Montesinos González

unread,
Jan 10, 2013, 10:31:49 AM1/10/13
to google-a...@googlegroups.com
I put loggin to the first line and to the last line of the handler and in this case, no log message was shown. That day the backend was never started, it was a GAE error, things that happen... I only want to know if there is any way to prevent this kind of thing.
Reply all
Reply to author
Forward
0 new messages