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
SPIKE: Research Annotations not created in DB despite "successful" POST /api/annotations
request
#4704
Comments
The fact that you were only able to reproduce it in production, not locally, suggests that it might have something to do with concurrent transactions that are happening at the same time as the transaction that fails. This is what it turned out to be with a previous session rollback issue we had. Really hard to debug unfortunately |
I can report that I encountered this issue multiple times when doing a bulk POSTs of scibot annotations (40,000) to |
Some relevant chatter from the #eng-sr channel back in July 2017: https://hypothes-is.slack.com/archives/C074BUPEG/p1499245083385744 "closed with a dirty session" errors are still being reported frequently in Sentry: https://sentry.io/hypothesis/h/issues/232281261/ |
It was on November 9th. If you run an api query to fetch all the annotations that show up here: https://hypothes.is/users/scibot?q=group%3A__world__ you should be able to get the timestamps for all the POSTs. They were running consecutively, so you could probably narrow down to +/- 100ms the times when one was missed (the issue occured) by looking for gaps in the submissions (those were done in 3 batches so there will be bigger gaps as well). |
Good to know. So I guess it's possible this bug was introduced recently, though I've got a feeling it has been here for a while and we never noticed. |
This possibly also happened recently to @heatherstaines who tried to reply to an annotation she had just made. She also says it happened to her a few weeks back. If this is the case it may mean that it's more serious than just batch imports. |
POST /api/annotations
requestPOST /api/annotations
request
A slightly more useful script for reproducing the issue that does not leave hundreds of annotations around requiring cleanup afterwards: https://gist.github.com/robertknight/24e9a408472e62c910b8d6c522edda64 |
Following the discussion in https://groups.google.com/forum/#!topic/sqlalchemy/eGxpQBChXQw implement a utility class which can be used to check whether any changes have been made in a `Session` but not yet committed to the DB. This is part of an investigation into #4704
…hanges The previous `session.dirty` check only tested for _changes_ to existing DB objects which have not been flushed. It did not check for added or deleted model objects which had not yet been flushed to the DB, or for changes which have been flushed inside a transaction but not yet _committed_. When debugging #4704 we want to specifically catch additions (of annotations) to the DB which have been flushed (by `storage.create_annotation`) but not yet committed.
Following the discussion in https://groups.google.com/forum/#!topic/sqlalchemy/eGxpQBChXQw implement a utility class which can be used to check whether any changes have been made in a `Session` but not yet committed to the DB. This is part of an investigation into #4704
…hanges The previous `session.dirty` check only tested for _changes_ to existing DB objects which have not been flushed. It did not check for added or deleted model objects which had not yet been flushed to the DB, or for changes which have been flushed inside a transaction but not yet _committed_. When debugging #4704 we want to specifically catch additions (of annotations) to the DB which have been flushed (by `storage.create_annotation`) but not yet committed.
Tonight I was running a test that led to me interactively create and then immediately delete annotations. Once out of a few dozen attempts, a delete provoked a 404. |
That's very interesting, as I make and delete annotations all the time in
connections with the demos. I can't recall getting a 404--unless perhaps I
had deleted the group in another tab, then went to try to delete an
annotation in that group on another tab. Still, it doesn't stand out in my
mind as something that I've experienced often.
Heather
…On Fri, Jan 5, 2018 at 12:55 AM, Jon Udell ***@***.***> wrote:
Tonight I was running a test that led to me interactively creating and
then immediately deleting annotations. Once out of a few dozen attempts, a
delete provoked a 404.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4704 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AXoiFxjuDwgqEL1skv4JwupYEqWYGv85ks5tHbk0gaJpZM4QsBso>
.
--
Heather Ruland Staines
Director, Partnerships
Hypothes.is
M: 203-400-1716
Skype: heather.staines
|
Following the discussion in https://groups.google.com/forum/#!topic/sqlalchemy/eGxpQBChXQw implement a utility class which can be used to check whether any changes have been made in a `Session` but not yet committed to the DB. This is part of an investigation into #4704
…hanges The previous `session.dirty` check only tested for _changes_ to existing DB objects which have not been flushed. It did not check for added or deleted model objects which had not yet been flushed to the DB, or for changes which have been flushed inside a transaction but not yet _committed_. When debugging #4704 we want to specifically catch additions (of annotations) to the DB which have been flushed (by `storage.create_annotation`) but not yet committed.
Based on additional logging added in #4728 we've learned a few things:
Taking (2) and (3) together, that strongly suggests this is related to the earlier issues with zope.sqlalchemy's internal |
@nlisgo and myself have both experienced situations where, when creating a large number (eg. 500 or 1000) of annotations with a sequence of requests, a small number of annotations are subsequently missing from the DB despite all of the
POST /api/annotations
requests returning a 200 response with a valid payload.So far I have only been able to reproduce the issue in production, not locally.
Steps to reproduce
API_KEY
constant below with a valid developer token and run the script against prod.Expected result
All 500 annotations are created successfully
Actual result
I saw a small number of annotations which were "created" successfully yet do not subsequently appear in the DB or in Elasticsearch.
Notes
The text was updated successfully, but these errors were encountered: