views:

53

answers:

2

So, I'm pulling my hair out here, and maybe someone has an insight.

I have a cronjob that loops over all my Link objects, does some stuff, might change properties on the object and does a save(). That's it.

Every so often (around once an hour), one of my rows just disappears. Poof. Nothing in the logs.

So, I'm trying to add debugging statements everywhere, but are there any glaring reasons for an entry to disapear? Is the only way to remove an entry by calling delete()?

Just any general directions to go would be wonderful, thank you.

Some ideas I've had:

  • git push while the cronjob is running
  • some cascading delete is wiping them out
  • some django method is calling delete on an exception
+1  A: 

You could use django-logging with LOGGING_LOG_SQL = True to log all the SQL, so you can see if any DELETE's are occurring.

John Paulett
Yay! It was a cascading delete. Thank you!
Paul Tarjan
+2  A: 

You could override the delete method on your Link class and dump a stack trace or log a message to see if it's indeed happening from within your Django application.

import sys, traceback

def delete(self):
   super(Link, self).delete()

   try:
      assert False
   except AssertionError, e
      traceback.print_tb(file=sys.stdout)

There may be a better way to get and log a stack trace, but that's the first thing that came to mind.

Joe Holloway