Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
8c4c5a61
Commit
8c4c5a61
authored
Feb 08, 2017
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed: newTransaction was being called in open even in explicit-transaction mode.
parent
48d96cc9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
23 deletions
+44
-23
src/ZODB/Connection.py
src/ZODB/Connection.py
+19
-16
src/ZODB/tests/testConnection.py
src/ZODB/tests/testConnection.py
+25
-7
No files found.
src/ZODB/Connection.py
View file @
8c4c5a61
...
@@ -902,22 +902,25 @@ class Connection(ExportImport, object):
...
@@ -902,22 +902,25 @@ class Connection(ExportImport, object):
# New code is in place. Start a new cache.
# New code is in place. Start a new cache.
self
.
_resetCache
()
self
.
_resetCache
()
# This newTransaction is to deal with some pathalogical cases:
if
not
self
.
explicit_transactions
:
#
# This newTransaction is to deal with some pathalogical cases:
# a) Someone opens a connection when a transaction isn't
#
# active and proceeeds without calling begin on a
# a) Someone opens a connection when a transaction isn't
# transaction manager. We initialize the transaction for
# active and proceeeds without calling begin on a
# the connection, but we don't do a storage sync, since
# transaction manager. We initialize the transaction for
# this will be done if a well-nehaved application calls
# the connection, but we don't do a storage sync, since
# begin, and we don't want to penalize well-behaved
# this will be done if a well-nehaved application calls
# transactions by syncing twice, as storage syncs might be
# begin, and we don't want to penalize well-behaved
# expensive.
# transactions by syncing twice, as storage syncs might be
# b) Lots of tests assume that connection transaction
# expensive.
# information is set on open.
# b) Lots of tests assume that connection transaction
#
# information is set on open.
# Fortunately, this is a cheap operation. It doesn't really
#
# cost much, if anything.
# Fortunately, this is a cheap operation. It doesn't
self
.
newTransaction
(
None
,
False
)
# really cost much, if anything. Well, except for
# RelStorage, in which case it adds a server round
# trip.
self
.
newTransaction
(
None
,
False
)
transaction_manager
.
registerSynch
(
self
)
transaction_manager
.
registerSynch
(
self
)
...
...
src/ZODB/tests/testConnection.py
View file @
8c4c5a61
...
@@ -1323,7 +1323,25 @@ class TestConnection(unittest.TestCase):
...
@@ -1323,7 +1323,25 @@ class TestConnection(unittest.TestCase):
db
.
close
()
db
.
close
()
def
test_explicit_transactions_no_newTransactuon_on_afterCompletion
(
self
):
def
test_explicit_transactions_no_newTransactuon_on_afterCompletion
(
self
):
db
=
ZODB
.
DB
(
None
)
syncs
=
[]
from
.MVCCMappingStorage
import
MVCCMappingStorage
storage
=
MVCCMappingStorage
()
new_instance
=
storage
.
new_instance
def
new_instance2
():
inst
=
new_instance
()
sync
=
inst
.
sync
def
sync2
(
*
args
):
sync
()
syncs
.
append
(
1
)
inst
.
sync
=
sync2
return
inst
storage
.
new_instance
=
new_instance2
db
=
ZODB
.
DB
(
storage
)
del
syncs
[:]
# Need to do this to clear effect of getting the
# root object
# We don't want to depend on latest transaction package, so
# We don't want to depend on latest transaction package, so
# just set attr for test:
# just set attr for test:
...
@@ -1331,8 +1349,7 @@ class TestConnection(unittest.TestCase):
...
@@ -1331,8 +1349,7 @@ class TestConnection(unittest.TestCase):
tm
.
explicit
=
True
tm
.
explicit
=
True
conn
=
db
.
open
(
tm
)
conn
=
db
.
open
(
tm
)
syncs
=
[]
self
.
assertEqual
(
len
(
syncs
),
0
)
conn
.
_storage
.
sync
=
syncs
.
append
conn
.
transaction_manager
.
begin
()
conn
.
transaction_manager
.
begin
()
self
.
assertEqual
(
len
(
syncs
),
1
)
self
.
assertEqual
(
len
(
syncs
),
1
)
conn
.
transaction_manager
.
commit
()
conn
.
transaction_manager
.
commit
()
...
@@ -1342,17 +1359,18 @@ class TestConnection(unittest.TestCase):
...
@@ -1342,17 +1359,18 @@ class TestConnection(unittest.TestCase):
conn
.
transaction_manager
.
abort
()
conn
.
transaction_manager
.
abort
()
self
.
assertEqual
(
len
(
syncs
),
2
)
self
.
assertEqual
(
len
(
syncs
),
2
)
conn
.
close
()
conn
.
close
()
db
.
close
(
)
self
.
assertEqual
(
len
(
syncs
),
2
)
# For reference, in non-explicit mode:
# For reference, in non-explicit mode:
db
=
ZODB
.
DB
(
None
)
conn
=
db
.
open
()
conn
=
db
.
open
()
self
.
assertEqual
(
len
(
syncs
),
3
)
conn
.
_storage
.
sync
=
syncs
.
append
conn
.
_storage
.
sync
=
syncs
.
append
conn
.
transaction_manager
.
begin
()
conn
.
transaction_manager
.
begin
()
self
.
assertEqual
(
len
(
syncs
),
3
)
conn
.
transaction_manager
.
abort
()
self
.
assertEqual
(
len
(
syncs
),
4
)
self
.
assertEqual
(
len
(
syncs
),
4
)
conn
.
transaction_manager
.
abort
()
self
.
assertEqual
(
len
(
syncs
),
5
)
conn
.
close
()
conn
.
close
()
db
.
close
()
db
.
close
()
class
StubDatabase
:
class
StubDatabase
:
...
...
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