From 7031a421b48d61fab30f63775f957230ccf65fb9 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Wed, 10 Feb 2010 17:04:09 +0000
Subject: [PATCH] Add an assertion on tid who took the oid lock when releasing
 it.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1688 71dcc9de-d417-0410-9af5-da40c76e7ee4
---
 neo/storage/transactions.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/neo/storage/transactions.py b/neo/storage/transactions.py
index 4f1da99f..1c87bff1 100644
--- a/neo/storage/transactions.py
+++ b/neo/storage/transactions.py
@@ -206,8 +206,10 @@ class TransactionManager(object):
         # unlock any object
         for oid in transaction.getOIDList():
             if has_load_lock:
-                # XXX: we release locks without checking if tid owns them
-                del self._load_lock_dict[oid]
+                lock_tid = self._load_lock_dict.pop(oid)
+                assert lock_tid == tid, 'Transaction %s tried to release ' \
+                    'the lock on oid %s, but it was held by %s' % (dump(tid),
+                    dump(oid), dump(lock_tid))
             del self._store_lock_dict[oid]
         # _uuid_dict entry will be deleted at node disconnection
         self._uuid_dict[transaction.getUUID()].discard(transaction)
-- 
2.30.9