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
Kirill Smelkov
ZODB
Commits
ebb95ed2
Commit
ebb95ed2
authored
Mar 12, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Checkpointing review progress.
parent
b1cbf426
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
19 deletions
+25
-19
src/ZODB/tests/testmvcc.py
src/ZODB/tests/testmvcc.py
+25
-19
No files found.
src/ZODB/tests/testmvcc.py
View file @
ebb95ed2
...
@@ -17,16 +17,17 @@ Multi-version concurrency control tests
...
@@ -17,16 +17,17 @@ Multi-version concurrency control tests
Multi-version concurrency control (MVCC) exploits storages that store
Multi-version concurrency control (MVCC) exploits storages that store
multiple revisions of an object to avoid read conflicts. Normally
multiple revisions of an object to avoid read conflicts. Normally
when an object is read from the storage, its most recent revision
s
is
when an object is read from the storage, its most recent revision is
read. Under MVCC, an older revision
is
read so that the transaction
read. Under MVCC, an older revision
may be
read so that the transaction
sees a consistent view of the database.
sees a consistent view of the database.
ZODB guarantees execution-time consistency: A single transaction will
ZODB guarantees execution-time consistency: A single transaction will
always see a consistent view of the database while it is executing.
always see a consistent view of the database while it is executing.
If transaction A is running, has already read an object O1, and a
n
If transaction A is running, has already read an object O1, and a
external
transaction B modifies object O2, then transaction A can no
different
transaction B modifies object O2, then transaction A can no
longer read the current revision of O2. It must either read the
longer read the current revision of O2. It must either read the
version of O2 that is consistent with O1 or raise a ReadConflictError.
version of O2 that is consistent with O1 or raise a ReadConflictError.
When MVCC is in use, A will do the former.
This note includes doctests that explain how MVCC is implemented (and
This note includes doctests that explain how MVCC is implemented (and
test that the implementation is correct). The tests use a
test that the implementation is correct). The tests use a
...
@@ -61,26 +62,31 @@ Connection high-water mark
...
@@ -61,26 +62,31 @@ Connection high-water mark
--------------------------
--------------------------
The ZODB Connection tracks a transaction high-water mark, which
The ZODB Connection tracks a transaction high-water mark, which
represents the latest transaction id that can be read by the current
bounds the latest transaction id that can be read by the current
transaction and still present a consistent view of the database. When
transaction and still present a consistent view of the database.
a transaction commits, the database sends invalidations to all the
Transactions with ids up to but not including the high-water mark
other transactions; the invalidation contains the transaction id and
are OK to read. When a transaction commits, the database sends
the oids of modified objects. The Connection stores the high-water
invalidations to all the other connections; the invalidation contains
mark in _txn_time, which is set to None until an invalidation arrives.
the transaction id and the oids of modified objects. The Connection
stores the high-water mark in _txn_time, which is set to None until
an invalidation arrives.
>>> cn = db.open()
>>> cn = db.open()
>>> print cn._txn_time
None
>>> cn.invalidate(100, dict.fromkeys([1, 2]))
>>> cn._txn_time
>>> cn._txn_time
>>> cn.invalidate(1, dict.fromkeys([1, 2]))
100
>>> cn.invalidate(200, dict.fromkeys([1, 2]))
>>> cn._txn_time
>>> cn._txn_time
1
100
>>> cn.invalidate(2, dict.fromkeys([1, 2]))
>>> cn._txn_time
1
The high-water mark is set to the transaction id of the first
A connection's high-water mark is set to the transaction id taken from
transaction, because transaction ids must be monotonically increasing.
the first invalidation processed by the connection. Transaction ids are
It is reset at transaction boundaries.
monotonically increasing, so the first one seen during the current
transaction remains the high-water mark for the duration of the
transaction.
XXX We'd like simple abort and commit calls to make txn boundaries,
XXX We'd like simple abort and commit calls to make txn boundaries,
but that doesn't work unless an object is modified. sync() will abort
but that doesn't work unless an object is modified. sync() will abort
...
...
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