From 3ec1a5df87e94d46865139d784ccf6ee08d8bf73 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 18 Apr 2013 16:43:25 +0200 Subject: [PATCH] [FIX] don't rollback() transation, use savepoint. This fixes concurrency issues with long running cron threads as rollback also releases the lock --- fetchmail_attach_from_folder/model/fetchmail_server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fetchmail_attach_from_folder/model/fetchmail_server.py b/fetchmail_attach_from_folder/model/fetchmail_server.py index c8d620f51..5efdf4754 100644 --- a/fetchmail_attach_from_folder/model/fetchmail_server.py +++ b/fetchmail_attach_from_folder/model/fetchmail_server.py @@ -148,14 +148,15 @@ class fetchmail_server(Model): if found_ids and (len(found_ids) == 1 or folder.match_first): try: + cr.execute('savepoint apply_matching') match_algorithm.handle_match( cr, uid, connection, found_ids[0], folder, mail_message, msgdata[0][1], msgid, context) - cr.commit() + cr.execute('release savepoint apply_matching') matched_object_ids += found_ids[:1] except Exception, e: - cr.rollback() + cr.execute('rollback to savepoint apply_matching') logger.exception( "Failed to fetch mail %s from %s", msgid, this.name)