[Zodb-checkins] SVN: ZODB/trunk/src/ZODB/ Fixed a bug that could cause InvalidObjectReference errors

Jim Fulton jim at zope.com
Fri Sep 5 13:56:52 EDT 2008


Log message for revision 90879:
  Fixed a bug that could cause InvalidObjectReference errors
  for objects that were explicitly added to a database if the object
  was modified after a savepoint that added the object.
  
  M      src/ZEO/tests/InvalidationTests.py
  Fixed spurious scary intermittent test failure.
  

Changed:
  U   ZODB/trunk/src/ZODB/Connection.py
  U   ZODB/trunk/src/ZODB/tests/testcrossdatabasereferences.py

-=-
Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py	2008-09-05 17:56:50 UTC (rev 90878)
+++ ZODB/trunk/src/ZODB/Connection.py	2008-09-05 17:56:52 UTC (rev 90879)
@@ -587,7 +587,14 @@
             oid = obj._p_oid
             serial = getattr(obj, "_p_serial", z64)
 
-            if serial == z64:
+            if ((serial == z64)
+                and
+                ((self._savepoint_storage is None)
+                 or (oid not in self._savepoint_storage.creating)
+                 or self._savepoint_storage.creating[oid]
+                 )
+                ):
+                
                 # obj is a new object
 
                 # Because obj was added, it is now in _creating, so it

Modified: ZODB/trunk/src/ZODB/tests/testcrossdatabasereferences.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testcrossdatabasereferences.py	2008-09-05 17:56:50 UTC (rev 90878)
+++ ZODB/trunk/src/ZODB/tests/testcrossdatabasereferences.py	2008-09-05 17:56:52 UTC (rev 90879)
@@ -146,6 +146,32 @@
 
 """
 
+def test_explicit_adding_with_savepoint2():
+    """
+
+    >>> import ZODB.tests.util, transaction, persistent
+    >>> databases = {}
+    >>> db1 = ZODB.tests.util.DB(databases=databases, database_name='1')
+    >>> db2 = ZODB.tests.util.DB(databases=databases, database_name='2')
+    >>> tm = transaction.TransactionManager()
+    >>> conn1 = db1.open(transaction_manager=tm)
+    >>> conn2 = conn1.get_connection('2')
+    >>> z = MyClass()
+
+    >>> conn1.root()['z'] = z
+    >>> conn1.add(z)
+    >>> s = tm.savepoint()
+    >>> conn2.root()['z'] = z
+    >>> z.x = 1
+    >>> tm.commit()
+    >>> z._p_jar.db().database_name
+    '1'
+    
+    >>> db1.close()
+    >>> db2.close()
+
+"""
+
 def tearDownDbs(test):
     test.globs['db1'].close()
     test.globs['db2'].close()



More information about the Zodb-checkins mailing list