Commit 11ac83e5 authored by Jim Fulton's avatar Jim Fulton

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.
parent 8d469d4c
......@@ -587,7 +587,14 @@ class Connection(ExportImport, object):
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
......
......@@ -146,6 +146,32 @@ def test_explicit_adding_with_savepoint():
"""
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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment