Commit 03498c05 authored by Jim Fulton's avatar Jim Fulton

Numerous fixes in response to: https://github.com/zopefoundation/ZODB/pull/93

parent 7af91457
...@@ -54,8 +54,6 @@ logger = logging.getLogger(__name__) ...@@ -54,8 +54,6 @@ logger = logging.getLogger(__name__)
# max signed 64-bit value ~ infinity :) Signed cuz LBTree and TimeStamp # max signed 64-bit value ~ infinity :) Signed cuz LBTree and TimeStamp
m64 = b'\x7f\xff\xff\xff\xff\xff\xff\xff' m64 = b'\x7f\xff\xff\xff\xff\xff\xff\xff'
from ZODB.ConflictResolution import ResolvedSerial
def tid2time(tid): def tid2time(tid):
return str(TimeStamp(tid)) return str(TimeStamp(tid))
...@@ -748,7 +746,7 @@ class ClientStorage(ZODB.ConflictResolution.ConflictResolvingStorage): ...@@ -748,7 +746,7 @@ class ClientStorage(ZODB.ConflictResolution.ConflictResolvingStorage):
self._async('storea', oid, committed, data, id(txn)) self._async('storea', oid, committed, data, id(txn))
tbuf.resolve(oid, data) tbuf.resolve(oid, data)
else: else:
tbuf.serial(oid, ResolvedSerial) tbuf.server_resolve(oid)
vote_attempts += 1 vote_attempts += 1
......
...@@ -42,7 +42,6 @@ from ZEO._compat import Pickler, Unpickler, PY3, BytesIO ...@@ -42,7 +42,6 @@ from ZEO._compat import Pickler, Unpickler, PY3, BytesIO
from ZEO.Exceptions import AuthError from ZEO.Exceptions import AuthError
from ZEO.monitor import StorageStats from ZEO.monitor import StorageStats
from ZEO.asyncio.server import Delay, MTDelay, Result from ZEO.asyncio.server import Delay, MTDelay, Result
from ZODB.ConflictResolution import ResolvedSerial
from ZODB.loglevels import BLATHER from ZODB.loglevels import BLATHER
from ZODB.POSException import StorageError, StorageTransactionError from ZODB.POSException import StorageError, StorageTransactionError
from ZODB.POSException import TransactionError, ReadOnlyError, ConflictError from ZODB.POSException import TransactionError, ReadOnlyError, ConflictError
......
...@@ -25,8 +25,6 @@ import os ...@@ -25,8 +25,6 @@ import os
import tempfile import tempfile
import ZODB.blob import ZODB.blob
from ZODB.ConflictResolution import ResolvedSerial
from ZEO._compat import Pickler, Unpickler from ZEO._compat import Pickler, Unpickler
class TransactionBuffer: class TransactionBuffer:
...@@ -66,10 +64,7 @@ class TransactionBuffer: ...@@ -66,10 +64,7 @@ class TransactionBuffer:
self.store(oid, data) self.store(oid, data)
self.client_resolved[oid] = self.count - 1 self.client_resolved[oid] = self.count - 1
def serial(self, oid, serial): def server_resolve(self, oid):
if isinstance(serial, Exception):
self.exception = serial # This transaction will never be committed
elif serial == ResolvedSerial:
self.server_resolved.add(oid) self.server_resolved.add(oid)
def storeBlob(self, oid, blobfilename): def storeBlob(self, oid, blobfilename):
......
...@@ -6,7 +6,6 @@ else: ...@@ -6,7 +6,6 @@ else:
import trollius as asyncio import trollius as asyncio
from ZEO.Exceptions import ClientDisconnected from ZEO.Exceptions import ClientDisconnected
from ZODB.ConflictResolution import ResolvedSerial
import concurrent.futures import concurrent.futures
import functools import functools
import logging import logging
......
...@@ -44,8 +44,8 @@ class TransUndoStorageWithCache: ...@@ -44,8 +44,8 @@ class TransUndoStorageWithCache:
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
assert len(oids) == 1 [uoid] = oids
assert oids[0] == oid assert uoid == oid
data, revid = self._storage.load(oid, '') data, revid = self._storage.load(oid, '')
obj = zodb_unpickle(data) obj = zodb_unpickle(data)
assert obj == MinPO(24) assert obj == MinPO(24)
...@@ -28,8 +28,7 @@ from ZODB.DB import DB ...@@ -28,8 +28,7 @@ from ZODB.DB import DB
from ZODB.POSException import ReadOnlyError, ConflictError from ZODB.POSException import ReadOnlyError, ConflictError
from ZODB.tests.StorageTestBase import StorageTestBase from ZODB.tests.StorageTestBase import StorageTestBase
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase \ from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
import zodb_pickle, zodb_unpickle, handle_all_serials, handle_serials
import ZODB.tests.util import ZODB.tests.util
import transaction import transaction
...@@ -1065,14 +1064,12 @@ class MSTThread(threading.Thread): ...@@ -1065,14 +1064,12 @@ class MSTThread(threading.Thread):
data = MinPO("%s.%s.t%d.o%d" % (tname, c.__name, i, j)) data = MinPO("%s.%s.t%d.o%d" % (tname, c.__name, i, j))
#print(data.value) #print(data.value)
data = zodb_pickle(data) data = zodb_pickle(data)
s = c.store(oid, ZERO, data, '', t) c.store(oid, ZERO, data, '', t)
c.__serials.update(handle_all_serials(oid, s))
# Vote on all servers and handle serials # Vote on all servers and handle serials
for c in clients: for c in clients:
#print("%s.%s.%s vote" % (tname, c.__name, i)) #print("%s.%s.%s vote" % (tname, c.__name, i))
s = c.tpc_vote(t) c.tpc_vote(t)
c.__serials.update(handle_all_serials(None, s))
# Finish on all servers # Finish on all servers
for c in clients: for c in clients:
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
import random import random
import unittest import unittest
from ZODB.ConflictResolution import ResolvedSerial
from ZEO.TransactionBuffer import TransactionBuffer from ZEO.TransactionBuffer import TransactionBuffer
def random_string(size): def random_string(size):
...@@ -26,10 +25,11 @@ def new_store_data(): ...@@ -26,10 +25,11 @@ def new_store_data():
"""Return arbitrary data to use as argument to store() method.""" """Return arbitrary data to use as argument to store() method."""
return random_string(8), random_string(random.randrange(1000)) return random_string(8), random_string(random.randrange(1000))
def store(tbuf, serial=None): def store(tbuf, resolved=False):
data = new_store_data() data = new_store_data()
tbuf.store(*data) tbuf.store(*data)
tbuf.serial(data[0], serial) if resolved:
tbuf.server_resolve(data[0])
return data return data
class TransBufTests(unittest.TestCase): class TransBufTests(unittest.TestCase):
...@@ -46,7 +46,7 @@ class TransBufTests(unittest.TestCase): ...@@ -46,7 +46,7 @@ class TransBufTests(unittest.TestCase):
data = [] data = []
for i in range(10): for i in range(10):
data.append((store(tbuf), False)) data.append((store(tbuf), False))
data.append((store(tbuf, ResolvedSerial), True)) data.append((store(tbuf, True), True))
for i, (oid, d, resolved) in enumerate(tbuf): for i, (oid, d, resolved) in enumerate(tbuf):
self.assertEqual((oid, d), data[i][0]) self.assertEqual((oid, d), data[i][0])
......
...@@ -538,7 +538,6 @@ class CommonBlobTests: ...@@ -538,7 +538,6 @@ class CommonBlobTests:
def checkStoreBlob(self): def checkStoreBlob(self):
import transaction import transaction
from ZODB.blob import Blob from ZODB.blob import Blob
from ZODB.tests.StorageTestBase import handle_serials
from ZODB.tests.StorageTestBase import ZERO from ZODB.tests.StorageTestBase import ZERO
from ZODB.tests.StorageTestBase import zodb_pickle from ZODB.tests.StorageTestBase import zodb_pickle
...@@ -579,8 +578,7 @@ class CommonBlobTests: ...@@ -579,8 +578,7 @@ class CommonBlobTests:
def checkLoadBlob(self): def checkLoadBlob(self):
from ZODB.blob import Blob from ZODB.blob import Blob
from ZODB.tests.StorageTestBase import zodb_pickle, ZERO, \ from ZODB.tests.StorageTestBase import zodb_pickle, ZERO
handle_serials
import transaction import transaction
somedata = b'a' * 10 somedata = b'a' * 10
...@@ -629,7 +627,6 @@ class BlobAdaptedFileStorageTests(FullGenericTests, CommonBlobTests): ...@@ -629,7 +627,6 @@ class BlobAdaptedFileStorageTests(FullGenericTests, CommonBlobTests):
def checkStoreAndLoadBlob(self): def checkStoreAndLoadBlob(self):
import transaction import transaction
from ZODB.blob import Blob from ZODB.blob import Blob
from ZODB.tests.StorageTestBase import handle_serials
from ZODB.tests.StorageTestBase import ZERO from ZODB.tests.StorageTestBase import ZERO
from ZODB.tests.StorageTestBase import zodb_pickle from ZODB.tests.StorageTestBase import zodb_pickle
......
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