Commit 203ba57f authored by Jim Fulton's avatar Jim Fulton

Fixed a bug in handling an odd edge case of a client connecting to a

server whose last transaction is older than the last one the client
saw.
parent cb518ed6
...@@ -1233,9 +1233,9 @@ class ClientStorage(object): ...@@ -1233,9 +1233,9 @@ class ClientStorage(object):
self.finish_verification() self.finish_verification()
return "no verification" return "no verification"
elif ltid < last_inval_tid: elif ltid < last_inval_tid:
logger.critical( message = ("%s Client has seen newer transactions than server!"
"%s Client has seen newer transactions than server!", % self.__name__)
self.__name__) logger.critical(message)
raise ClientStorageError(message) raise ClientStorageError(message)
# log some hints about last transaction # log some hints about last transaction
......
...@@ -1071,6 +1071,62 @@ def tpc_finish_error(): ...@@ -1071,6 +1071,62 @@ def tpc_finish_error():
connection closed connection closed
""" """
def client_has_newer_data_than_server():
"""It is bad if a client has newer data than the server.
>>> db = ZODB.DB('Data.fs')
>>> db.close()
>>> shutil.copyfile('Data.fs', 'Data.save')
>>> addr, admin = start_server(keep=1)
>>> db = ZEO.DB(addr, name='client', max_disconnect_poll=.01)
>>> wait_connected(db.storage)
>>> conn = db.open()
>>> conn.root().x = 1
>>> transaction.commit()
OK, we've added some data to the storage and the client cache has
the new data. Now, we'll stop the server, put back the old data, and
see what happens. :)
>>> stop_server(admin)
>>> shutil.copyfile('Data.save', 'Data.fs')
>>> import zope.testing.loggingsupport
>>> handler = zope.testing.loggingsupport.InstalledHandler(
... 'ZEO', level=logging.ERROR)
>>> formatter = logging.Formatter('%(name)s %(levelname)s %(message)s')
>>> _, admin = start_server(addr=addr)
>>> for i in range(1000):
... while len(handler.records) < 5:
... time.sleep(.01)
>>> db.close()
>>> for record in handler.records[:5]:
... print formatter.format(record)
... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
ZEO.ClientStorage CRITICAL client
Client has seen newer transactions than server!
ZEO.zrpc ERROR (...) CW: error in notifyConnected (('localhost', ...))
Traceback (most recent call last):
...
ClientStorageError: client Client has seen newer transactions than server!
ZEO.ClientStorage CRITICAL client
Client has seen newer transactions than server!
ZEO.zrpc ERROR (...) CW: error in notifyConnected (('localhost', ...))
Traceback (most recent call last):
...
ClientStorageError: client Client has seen newer transactions than server!
...
Note that the errors repeat because the client keeps on trying to connect.
>>> handler.uninstall()
>>> stop_server(admin)
"""
slow_test_classes = [ slow_test_classes = [
BlobAdaptedFileStorageTests, BlobWritableCacheTests, BlobAdaptedFileStorageTests, BlobWritableCacheTests,
DemoStorageTests, FileStorageTests, MappingStorageTests, DemoStorageTests, FileStorageTests, MappingStorageTests,
......
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