-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid Sqlalchemy errors from prior harvest rollbacks #445
Open
bonnland
wants to merge
4
commits into
ckan:master
Choose a base branch
from
bonnland:fix-validation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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 seems related: If validation errors cause a session rollback, then is there a problem with adding a |
bonnland
changed the title
Validate before DB transaction boundary
Avoid Sqlalchemy errors from rollback
May 20, 2021
bonnland
changed the title
Avoid Sqlalchemy errors from rollback
Avoid Sqlalchemy errors from prior harvest rollbacks
May 20, 2021
Sorry for the extra commits; I'm relatively new to PRs. |
bonnland
commented
May 20, 2021
@@ -260,6 +260,7 @@ def create(cls, message, object, stage=u'Fetch', line=None): | |||
# Clear any in-progress sqlalchemy transactions | |||
try: | |||
Session.rollback() | |||
Session.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if Session.remove()
is somehow different/better than Session.close()
.
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.
I'm leaving the original description below the divider. I realize now that the proposed code change doesn't really address the root problem: why are rollbacks happening in the first place?
I managed to test harvesting of our records in a remote debugging session using the
harvester run_test
command. No rollbacks happen when I do this. It makes me wonder if the queue states are not quite right.I have one theory:
Does this sound plausible? If so, the simple solution is to stop re-submitting invalid records to the fetch queue.
Original Description of PR
This may be addressing the same issue as #312 and may be related to #151.
The WAFs that we harvest often contain metadata records that fail our extra validation rules.
Here's the behavior I'm seeing with ckanext-harvest version 1.3.3, when we harvest a WAF containing records that fail validation:
This harvest job eventually times out, though sometimes many hours after the timeout value of 5 minutes that we have set. We are 6 hours behind UTC time zone, I don't know if this matters.
If there are no invalid records in the WAF, then the second harvest job completes successfully. It is only when re-harvesting a WAF with one or more invalid records that the second harvest produces this stack trace and harvest job that remains stuck for hours.