Fix issues with the jsonstorage table#935
Open
BryceStevenWilley wants to merge 2 commits into
Open
Conversation
sqlalchemy doesn't have an `Index` attribute on the `db` Engine object anymore.
Have previously run into errors (duplicate id) that then cascasde and prevent any user from writing to the jsonstorage table. This change makes the functions call `rollback()` to properly start a new sqlalchemy transaction and isolate the DB error to only the original affected user.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tried fixing 3 specific things here:
Changed
db.IndextoIndex. The former doesn't work anymore, giving an errorAttributeError: 'Engine' object has no attribute 'Index'.1We switched our jsonstorage table to an externally hosted SQL database recently and have run into issues in production with
This error has happened twice within a week. This shouldn't be happening, but from reading the SQLAlchemy docs it seems that we need to use
server_defaultto prevent SQL Alchemy from automatically assuming the default of the value? I'm less sure this fix is correct, but it doesn't change current functionality.When we do run into a call that violates the duplicate key, all other writes to the jsonstorage table will fail with
To prevent this from happening, this change catches excepts that occur when writing or deleting from the jsonstorage table and calls
rollback().Footnotes
I can't find where this is failing during normal docassemble runs, but the error can be recreated in python. ↩