-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PsqlDosBackend
: Use transaction whenever mutating session state
Storing a node while iterating over the result of `QueryBuilder.iterall` would raise `sqlalchemy.exc.InvalidRequestError` with the message: Can't operate on closed transaction inside context manager. The problem was that the `Node` implementation for the `PsqlDosBackend`, the `SqlaNode` class, would not consistently open a transaction, using the `PsqlDosBackend.transaction` method, whenever it mutated the state of the session, and would then straight up commit to the current session. For example, when storing a new node, the `store` method would simply call save. Through the `ModelWrapper`, this would call commit on the session, but that was the session being used for the iteration. The same problem was present for the `SqlaGroup` implementation that had a number of places where sessions state was mutated without opening a transaction first. The problem is fixed therefore by consistently opening a transaction before making changes to the session. The `transaction` implementation is slightly changed as any `SqlaIntegrityError` raised during the context is now converted into an `aiida.common.exceptions.IntegrityError` to make it backend independent.
- Loading branch information
Showing
10 changed files
with
101 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters