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