- 31 Mar, 2020 1 commit
-
-
Kirill Smelkov authored
[ This is ZODB4 backport of commit bb9bf539 (https://github.com/zopefoundation/ZODB/pull/298) ] ZODB tries to avoid saving empty transactions to storage on `transaction.commit()`. The way it works is: if no objects were changed during ongoing transaction, ZODB.Connection does not join current TransactionManager, and transaction.commit() performs two-phase commit protocol only on joined DataManagers. In other words if no objects were changed, no tpc_*() methods are called at all on ZODB.Connection at transaction.commit() time. This way application servers like Zope/ZServer/ERP5/... can have something as try: # process incoming request transaction.commit() # processed ok except: transaction.abort() # problem: log + reraise in top-level code to process requests without creating many on-disk transactions with empty data changes just because read-only requests were served. Everything is working as intended. However at storage level, FileStorage currently also checks whether transaction that is being committed also comes with empty data changes, and _skips_ saving transaction into disk *at all* for such cases, even if it has been explicitly told to commit the transaction via two-phase commit protocol calls done at storage level. This creates the situation, where contrary to promise in ZODB/interfaces.py(*), after successful tpc_begin/tpc_vote/tpc_finish() calls made at storage level, transaction is _not_ made permanent, despite tid of "committed" transaction being returned to caller. In other words FileStorage, when asked to commit a transaction, even if one with empty data changes, reports "ok" and gives transaction ID to the caller, without creating corresponding transaction record on disk. This behaviour is a) redundant to application-level avoidance to create empty transaction on storage described in the beginning, and b) creates problems: The first problem is that application that works at storage-level might be interested in persisting transaction, even with empty changes to data, just because it wants to save the metadata similarly to e.g. `git commit --allow-empty`. The other problem is that an application view and data in database become inconsistent: an application is told that a transaction was created with corresponding transaction ID, but if the storage is actually inspected, e.g. by iteration, the transaction is not there. This, in particular, can create problems if TID of committed transaction is reported elsewhere and that second database client does not find the transaction it was told should exist. I hit this particular problem with wendelin.core. In wendelin.core, there is custom virtual memory layer that keeps memory in sync with data in ZODB. At commit time, the memory is inspected for being dirtied, and if a page was changed, virtual memory layer joins current transaction _and_ forces corresponding ZODB.Connection - via which it will be saving data into ZODB objects - to join the transaction too, because it would be too late to join ZODB.Connection after 2PC process has begun(+). One of the format in which data are saved tries to optimize disk space usage, and it actually might happen, that even if data in RAM were dirtied, the data itself stayed the same and so nothing should be saved into ZODB. However ZODB.Connection is already joined into transaction and it is hard not to join it because joining a DataManager when the 2PC is already ongoing does not work. This used to work ok with wendelin.core 1, but with wendelin.core 2 - where separate virtual filesystem is also connected to the database to provide base layer for arrays mappings - this creates problem, because when wcfs (the filesystem) is told to synchronize to view the database @tid of committed transaction, it can wait forever waiting for that, or later, transaction to appear on disk in the database, creating application-level deadlock. I agree that some more effort might be made at wendelin.core side to avoid committing transactions with empty data at storage level. However the most clean way to fix this problem in my view is to fix FileStorage itself, because if at storage level it was asked to commit something, it should not silently skip doing so and dropping even non-empty metadata + returning ok and committed transaction ID to the caller. As described in the beginning this should not create problems for application-level ZODB users, while at storage-level the implementation is now consistently matching interface and common sense. ---- (*) tpc_finish: Finish the transaction, making any transaction changes permanent. Changes must be made permanent at this point. ... https://github.com/zopefoundation/ZODB/blob/5.5.1-35-gb5895a5c2/src/ZODB/interfaces.py#L828-L831 (+) https://lab.nexedi.com/kirr/wendelin.core/blob/9ff5ed32/bigfile/file_zodb.py#L788-822
-
- 30 Apr, 2018 1 commit
-
-
Jim Fulton authored
Tests running and passing on windows. (cherry picked from commit 87fd29eb83512c177854d9aab3d998478192797c)
-
- 08 Apr, 2017 2 commits
-
-
Julien Muchembled authored
-
Jim Fulton authored
This backports the following commits: 6d673057 244bb92b
-
- 03 Apr, 2017 1 commit
-
-
Kirill Smelkov authored
... instead of silently creating empty database on such opens. Use-case for this are utilities like e.g. zodbdump and zodbcmp which expect such storage opens to fail so that the tool can know there is no such storage and report it to user. In contrast current state is: read-only opens get created-on-the-fly empty storage with no content, but which can be iterated over without getting any error. This way e.g. `zodbdump non-existent.fs` produces empty output _and_ exit code 0 which is not what caller expects. (cherry picked from commit 30bbabf19e837b4ca9e35fab5d5c1278b078fe45)
-
- 06 Feb, 2017 1 commit
-
-
Julien Muchembled authored
-
- 02 Feb, 2017 5 commits
-
-
Julien Muchembled authored
-
Julien Muchembled authored
This backports a change from commit 227953b9. NEO, as well as ZEO+server_sync (ERP5 backports this feature with a monkey-patch), pings the server (primary master node in the case of NEO) on new transactions. However, this round-trip is actually performed by the thread that also does tasks requiring to lock the DB, like processing of invalidations. Since transaction 1.6.1 (more precisely commit e581a120a6), IStorage.sync() is called indirectly by DB.open() when a transaction has already begun, and the DB must not be locked when this happens.
-
Jason Madden authored
Doing so leads to race conditions. In particular, there can be an AttributeError. See https://github.com/zodb/zodbshootout/issues/26 for details. (cherry picked from commit f8cf23ec)
-
Jason Madden authored
Don't require persistent at setup time. We don't build native code that needs those headers anymore. Fixes #119. (cherry picked from commit d7dae8b1)
-
Jim Fulton authored
This is also a workaround for pypa/setuptools#864, since the default pypy3 on Travis is quite old. (cherry picked from commit def73970 and 5dcca55e)
-
- 27 Nov, 2016 2 commits
-
-
Jim Fulton authored
-
Jim Fulton authored
Fixed to work with transaction 2.0.3.
-
- 25 Nov, 2016 1 commit
-
-
Jim Fulton authored
-
- 27 Sep, 2016 2 commits
-
-
Jim Fulton authored
Simplify the README file to avoid out of date information
-
Jim Fulton authored
We have the same information scattered around in different places, which increases the chance that some of it will be out of date. See the end of: https://groups.google.com/forum/#!topic/zodb/fy6RRVAF9-s I want to try to avoid duplicating zodb.org.
-
- 12 Sep, 2016 2 commits
-
-
Jim Fulton authored
Clear Connection.transaction_manager on close. Fixes #114 for ZODB 4.
-
Jason Madden authored
-
- 09 Sep, 2016 1 commit
-
-
Jim Fulton authored
Call _p_resolveConflict() even if a conflicting change doesn't change the state
-
- 21 Aug, 2016 2 commits
-
-
Julien Muchembled authored
-
Julien Muchembled authored
This reverts to the behaviour of 3.10.3 and older.
-
- 04 Aug, 2016 1 commit
-
-
Jim Fulton authored
-
- 27 Jul, 2016 2 commits
-
-
Jim Fulton authored
checkTransactionalUndoIterator: do not expect iterator to return sorted oids
-
Julien Muchembled authored
-
- 26 Jul, 2016 1 commit
-
-
Jim Fulton authored
fstail: print the txn offset and header size, instead of only the data offset
-
- 13 Jul, 2016 1 commit
-
-
Julien Muchembled authored
-
- 12 Jul, 2016 8 commits
-
-
Julien Muchembled authored
Before: 2016-07-01 09:41:50.416574: hash=d7101c5ee7b8e412d7b6d54873204421e09b7f34 user='' description='' length=1629 offset=58990284 After: 2016-07-01 09:41:50.416574: hash=d7101c5ee7b8e412d7b6d54873204421e09b7f34 user='' description='' length=1629 offset=58990261 (+23) The structure of a FileStorage DB is such that it's easy to revert the last transactions, by truncating the file at the right offset. With the above change, `fstail` can now be used to get this offset. In the above example: truncate -s 58990261 Data.fs would delete the transaction and all those after.
-
Jim Fulton authored
Refactored FileStorage transactional undo
-
Jim Fulton authored
-
Jim Fulton authored
Fix handle_all_serials for the new and old protocols.
-
Jason Madden authored
-
Jim Fulton authored
-
Jim Fulton authored
As part of a project to provide object-level commit locks for ZEO, I'm refactiring FileStorage to maintain transaction-specific data in Tranaction.data. This involved undo. In trying to figure this out, I found: - A bug in _undoDataInfo, which I verified with some tests and - _transactionalUndoRecord was maddeningly difficult to reason about (and thus change). I was concerned less by the bug than my inability to know whether a change to the code would be correct. So I refactored the code, mainly transactionalUndoRecord, to make the code easier to understand, fixing some logic errors (I'm pretty sure) along the way. This included lots of comments. (Comments are much easier to compose when you're working out logic you didn't understand.) In addition to makeing the code cleaner, it allows undo to be handled in cases that weren't handled before.
-
Jim Fulton authored
-
- 09 Jul, 2016 1 commit
-
-
Jason Madden authored
-
- 08 Jul, 2016 1 commit
-
-
Jim Fulton authored
-
- 05 Jul, 2016 3 commits
-
-
Jim Fulton authored
Only tpc_vote can report resolved conflicts with the new commit protocol
-
Julien Muchembled authored
-
Julien Muchembled authored
-
- 04 Jul, 2016 1 commit
-
-
Jim Fulton authored
-