Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
53b465a2
Commit
53b465a2
authored
Jul 08, 2016
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify server commit-lock management
parent
d2095794
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
214 additions
and
232 deletions
+214
-232
src/ZEO/StorageServer.py
src/ZEO/StorageServer.py
+182
-202
src/ZEO/asyncio/mtacceptor.py
src/ZEO/asyncio/mtacceptor.py
+3
-9
src/ZEO/tests/testConversionSupport.py
src/ZEO/tests/testConversionSupport.py
+1
-0
src/ZEO/tests/testZEO2.py
src/ZEO/tests/testZEO2.py
+28
-21
No files found.
src/ZEO/StorageServer.py
View file @
53b465a2
This diff is collapsed.
Click to expand it.
src/ZEO/asyncio/mtacceptor.py
View file @
53b465a2
...
@@ -31,15 +31,9 @@ http://bugs.python.org/issue27392, but it's hard to justify the fix to
...
@@ -31,15 +31,9 @@ http://bugs.python.org/issue27392, but it's hard to justify the fix to
get it accepted, so we won't bother for now. This currently uses a
get it accepted, so we won't bother for now. This currently uses a
horrible monley patch to work with SSL.
horrible monley patch to work with SSL.
To use this module, replace::
Note that the latest server commit-lock manager assumes a single
thread. To use this Acceptor, the lock manager would need to be
from .asyncio.server import Acceptor
updated.
with:
from .asyncio.mtacceptor import Acceptor
in ZEO.StorageServer.
"""
"""
from
.._compat
import
PY3
from
.._compat
import
PY3
...
...
src/ZEO/tests/testConversionSupport.py
View file @
53b465a2
...
@@ -48,6 +48,7 @@ class FakeServer:
...
@@ -48,6 +48,7 @@ class FakeServer:
'1'
:
FakeStorage
(),
'1'
:
FakeStorage
(),
'2'
:
FakeStorageBase
(),
'2'
:
FakeStorageBase
(),
}
}
lock_managers
=
storages
def
register_connection
(
*
args
):
def
register_connection
(
*
args
):
return
None
,
None
return
None
,
None
...
...
src/ZEO/tests/testZEO2.py
View file @
53b465a2
...
@@ -169,27 +169,28 @@ So, we arrange to get an error in vote:
...
@@ -169,27 +169,28 @@ So, we arrange to get an error in vote:
>>> zs = ZEO.tests.servertesting.client(server, 1)
>>> zs = ZEO.tests.servertesting.client(server, 1)
>>> zs.tpc_begin('0', '', '', {})
>>> zs.tpc_begin('0', '', '', {})
>>> zs.storea(ZODB.utils.p64(99), ZODB.utils.z64, 'x', '0')
>>> zs.storea(ZODB.utils.p64(99), ZODB.utils.z64, 'x', '0')
>>> zs.vote('0')
>>> zs.vote('0')
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError
ValueError
When we do, the storage server's transaction lock shouldn't be held:
#
When we do, the storage server's transaction lock shouldn't be held:
>>> '1' in server._commit_locks
#
>>> '1' in server._commit_locks
False
#
False
Of course, if vote suceeds, the lock will be held:
#
Of course, if vote suceeds, the lock will be held:
>>> vote_should_fail = False
#
>>> vote_should_fail = False
>>> zs.tpc_begin('1', '', '', {})
#
>>> zs.tpc_begin('1', '', '', {})
>>> zs.storea(ZODB.utils.p64(99), ZODB.utils.z64, 'x', '1')
#
>>> zs.storea(ZODB.utils.p64(99), ZODB.utils.z64, 'x', '1')
>>> _ = zs.vote('1') # doctest: +ELLIPSIS
#
>>> _ = zs.vote('1') # doctest: +ELLIPSIS
>>> '1' in server._commit_locks
#
>>> '1' in server._commit_locks
True
#
True
>>> zs.tpc_abort('1')
#
>>> zs.tpc_abort('1')
"""
"""
...
@@ -229,10 +230,10 @@ We start a transaction and vote, this leads to getting the lock.
...
@@ -229,10 +230,10 @@ We start a transaction and vote, this leads to getting the lock.
received handshake 'Z5'
received handshake 'Z5'
>>> tid1 = start_trans(zs1)
>>> tid1 = start_trans(zs1)
>>> resolved1 = zs1.vote(tid1) # doctest: +ELLIPSIS
>>> resolved1 = zs1.vote(tid1) # doctest: +ELLIPSIS
ZEO.StorageServer DEBUG
(test-addr-1) ('1') lock: transactions waiting: 0
ZEO.StorageServer BLATHER
ZEO.StorageServer BLATHER
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
ZEO.StorageServer DEBUG
(test-addr-1) ('1') lock: transactions waiting: 0
If another client tried to vote, it's lock request will be queued and
If another client tried to vote, it's lock request will be queued and
a delay will be returned:
a delay will be returned:
...
@@ -254,10 +255,10 @@ When we end the first transaction, the queued vote gets the lock.
...
@@ -254,10 +255,10 @@ When we end the first transaction, the queued vote gets the lock.
>>> zs1.tpc_abort(tid1) # doctest: +ELLIPSIS
>>> zs1.tpc_abort(tid1) # doctest: +ELLIPSIS
ZEO.StorageServer DEBUG
ZEO.StorageServer DEBUG
(test-addr-1) ('1') unlock: transactions waiting: 1
(test-addr-1) ('1') unlock: transactions waiting: 1
ZEO.StorageServer DEBUG
(test-addr-2) ('1') lock: transactions waiting: 0
ZEO.StorageServer BLATHER
ZEO.StorageServer BLATHER
(test-addr-2) Preparing to commit transaction: 1 objects, ... bytes
(test-addr-2) Preparing to commit transaction: 1 objects, ... bytes
ZEO.StorageServer DEBUG
(test-addr-2) ('1') lock: transactions waiting: 0
Let's try again with the first client. The vote will be queued:
Let's try again with the first client. The vote will be queued:
...
@@ -364,10 +365,10 @@ release the lock and one of the waiting clients will get the lock.
...
@@ -364,10 +365,10 @@ release the lock and one of the waiting clients will get the lock.
(test-addr-2) disconnected during locked transaction
(test-addr-2) disconnected during locked transaction
ZEO.StorageServer CRITICAL
ZEO.StorageServer CRITICAL
(test-addr-2) ('1') unlock: transactions waiting: 10
(test-addr-2) ('1') unlock: transactions waiting: 10
ZEO.StorageServer WARNING
(test-addr-1) ('1') lock: transactions waiting: 9
ZEO.StorageServer BLATHER
ZEO.StorageServer BLATHER
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
ZEO.StorageServer WARNING
(test-addr-1) ('1') lock: transactions waiting: 9
(In practice, waiting clients won't necessarily get the lock in order.)
(In practice, waiting clients won't necessarily get the lock in order.)
...
@@ -431,6 +432,8 @@ If clients disconnect while waiting, they will be dequeued:
...
@@ -431,6 +432,8 @@ If clients disconnect while waiting, they will be dequeued:
(test-addr-18) ('1') dequeue lock: transactions waiting: 0
(test-addr-18) ('1') dequeue lock: transactions waiting: 0
>>> zs1.tpc_abort(tid1)
>>> zs1.tpc_abort(tid1)
ZEO.StorageServer DEBUG
(test-addr-1) ('1') unlock: transactions waiting: 0
>>> logging.getLogger('ZEO').setLevel(logging.NOTSET)
>>> logging.getLogger('ZEO').setLevel(logging.NOTSET)
>>> logging.getLogger('ZEO').removeHandler(handler)
>>> logging.getLogger('ZEO').removeHandler(handler)
...
@@ -486,14 +489,16 @@ ZEOStorage as closed and see if trying to get a lock cleans it up:
...
@@ -486,14 +489,16 @@ ZEOStorage as closed and see if trying to get a lock cleans it up:
received handshake 'Z5'
received handshake 'Z5'
>>> tid1 = start_trans(zs1)
>>> tid1 = start_trans(zs1)
>>> resolved1 = zs1.vote(tid1) # doctest: +ELLIPSIS
>>> resolved1 = zs1.vote(tid1) # doctest: +ELLIPSIS
ZEO.StorageServer DEBUG
(test-addr-1) ('1') lock: transactions waiting: 0
ZEO.StorageServer BLATHER
ZEO.StorageServer BLATHER
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
ZEO.StorageServer DEBUG
(test-addr-1) ('1') lock: transactions waiting: 0
>>> zs1.connection.connection_lost(None)
>>> zs1.connection.connection_lost(None)
ZEO.StorageServer INFO
ZEO.StorageServer INFO
(test-addr-1) disconnected during locked transaction
(test-addr-1) disconnected during locked transaction
ZEO.StorageServer DEBUG
(test-addr-1) ('1') unlock: transactions waiting: 0
>>> zs2 = ZEO.tests.servertesting.client(server, '2')
>>> zs2 = ZEO.tests.servertesting.client(server, '2')
ZEO.asyncio.base INFO
ZEO.asyncio.base INFO
...
@@ -502,12 +507,14 @@ ZEOStorage as closed and see if trying to get a lock cleans it up:
...
@@ -502,12 +507,14 @@ ZEOStorage as closed and see if trying to get a lock cleans it up:
received handshake 'Z5'
received handshake 'Z5'
>>> tid2 = start_trans(zs2)
>>> tid2 = start_trans(zs2)
>>> resolved2 = zs2.vote(tid2) # doctest: +ELLIPSIS
>>> resolved2 = zs2.vote(tid2) # doctest: +ELLIPSIS
ZEO.StorageServer DEBUG
(test-addr-2) ('1') lock: transactions waiting: 0
ZEO.StorageServer BLATHER
ZEO.StorageServer BLATHER
(test-addr-2) Preparing to commit transaction: 1 objects, ... bytes
(test-addr-2) Preparing to commit transaction: 1 objects, ... bytes
ZEO.StorageServer DEBUG
(test-addr-2) ('1') lock: transactions waiting: 0
>>> zs2.tpc_abort(tid2)
>>> zs2.tpc_abort(tid2)
ZEO.StorageServer DEBUG
(test-addr-2) ('1') unlock: transactions waiting: 0
>>> logging.getLogger('ZEO').setLevel(logging.NOTSET)
>>> logging.getLogger('ZEO').setLevel(logging.NOTSET)
>>> logging.getLogger('ZEO').removeHandler(handler)
>>> logging.getLogger('ZEO').removeHandler(handler)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment