Provide the ability to perform a fine-grained rollback, rather than the full You issue a rollback, the entire transaction is rolled back. You build up a series of database operations awaiting a commit or rollback. However, once you open a transaction with atomic(), Savepoints aren’t especially useful if you are using autocommit, the defaultīehavior of Django. They’re empty operations – they don’t actually do anything. Other backends provide the savepoint functions, but Savepoints areĪvailable with the SQLite, PostgreSQL, Oracle, and MySQL (when using the InnoDB Part of a transaction, rather than the full transaction. Calling on_commit() whenĪutocommit is disabled and you are not within an atomic block will result in anĪ savepoint is a marker within a transaction that enables you to roll back On-commit functions only work with autocommit modeĪnd the atomic() (or ATOMIC_REQUESTS) transaction API. When in autocommit mode and outside of an atomic() block, the function Implicit transaction, preventing the connection from going back into autocommit The commit (because otherwise any queries done in a callback would open an Two-phase commit such as the psycopg Two-Phase Commit protocol support and the optional Two-Phase Commit ExtensionsĬallbacks are not run until autocommit is restored on the connection following Then you don’t want to use the on_commit() hook. If it’s not (if your follow-up action is soĬritical that its failure should mean the failure of the transaction itself), For the intended use cases (mail notifications, background They are executedĬonditionally upon the success of the transaction, but they are not part of Your callbacks are executed after a successful commit, so a failure in aĬallback will not cause the transaction to roll back. Savepoints, even for the outermost block. You may use atomic when autocommit is turned off. The overhead of savepoints is noticeable. If there is one, and the outermost block otherwise. Perform the rollback when exiting the first parent block with a savepoint You can disable the creation of savepoints for inner blocks by setting the
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |