views:

19

answers:

0

I have a cronjob which processes emails and stores them in the system. It'd been working well for over a year but now all of a sudden it has started giving these weird transaction errors randomly every now and then.

2010-09-02-01:45:11 ERROR Exception occured during mail processing
Traceback (most recent call last):
 File "/var/www/example.com/project/scripts/cronjobs.py", line 453, in process_msg
   source, email, 'i' if rejection_reason else 'v', rejection_reason)
 File "/usr/lib/python2.5/site-packages/django/db/transaction.py", line 267, in _commit_manually
   leave_transaction_management()
 File "/usr/lib/python2.5/site-packages/django/db/transaction.py", line 77, in leave_transaction_management
   raise TransactionManagementError("Transaction managed block ended with pending COMMIT/ROLLBACK")
TransactionManagementError: Transaction managed block ended with pending COMMIT/ROLLBACK

It happens without any reason and there isn't any other context information available to me. Here is the structure of my process_msg function:

@commit_manually
def save_email( u,l, d, t, s, e, status, reason):
    try:
        # ... bla bla bla ... 
        commit()
    exception, e:
        rollback()
        raise e

def process_msg(m):
    try:
        #....
        save_email(u, l, d, t
            source, email, 'i' if rejection_reason else 'v', rejection_reason)
        #....
     except Exception, e:
        logger.error('Error while processing email', exc_info=True )
        return None
    else:
        return True

How how I probe this issue?