Closed Bug 1172416 Opened 9 years ago Closed 9 years ago

Internal server error when saving article edit

Categories

(developer.mozilla.org Graveyard :: General, defect)

All
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: petercpg, Assigned: jezdez)

References

Details

(Keywords: in-triage, Whiteboard: [specification][type:bug])

What did you do?
================
1. Open https://developer.mozilla.org/zh-TW/Add-ons
2. Edit article contents
3. Save article

What happened?
==============
Internal Server Error was encountered, while the changes were saved.

What should have happened?
==========================
No error thrown out

Is there anything else we should know?
======================================
https://errormill.mozilla.org/mdn/mdn/group/398180/ :

DoesNotExist: Revision matching query does not exist.

Stacktrace (most recent call last):

  File "django/core/handlers/base.py", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "newrelic/hooks/framework_django.py", line 497, in wrapper
    return wrapped(*args, **kwargs)
  File "django/views/decorators/csrf.py", line 77, in wrapped_view
    return view_func(*args, **kwargs)
  File "django/views/decorators/http.py", line 41, in inner
    return func(request, *args, **kwargs)
  File "kuma/wiki/decorators.py", line 32, in _added_header
    response = func(request, *args, **kwargs)
  File "kuma/authkeys/decorators.py", line 33, in process
    return func(request, *args, **kwargs)
  File "kuma/wiki/decorators.py", line 107, in process
    return func(request, *args, **kwargs)
  File "django/views/decorators/http.py", line 147, in inner
    response = func(request, *args, **kwargs)
  File "django/db/transaction.py", line 224, in inner
    return func(*args, **kwargs)
  File "newrelic/api/function_trace.py", line 110, in literal_wrapper
    return wrapped(*args, **kwargs)
  File "kuma/wiki/views.py", line 519, in document
    request, doc, rendering_params)
  File "kuma/wiki/views.py", line 289, in _get_html_and_errors
    r_body, r_errors = doc.get_rendered(cache_control, base_url)
  File "newrelic/api/function_trace.py", line 110, in literal_wrapper
    return wrapped(*args, **kwargs)
  File "kuma/wiki/models.py", line 444, in get_rendered
    self.schedule_rendering(cache_control, base_url)
  File "kuma/wiki/models.py", line 484, in schedule_rendering
    self.render(cache_control, base_url)
  File "kuma/wiki/models.py", line 548, in render
    parent_json = json.dumps(self.parent.build_json_data())
  File "kuma/wiki/models.py", line 570, in build_json_data
    revision = translation.current_revision
  File "django/db/models/fields/related.py", line 350, in __get__
    rel_obj = qs.get(**params)
  File "django/db/models/query.py", line 366, in get
    % self.model._meta.object_name)
I got an ISE on save earlier today too. I failed to report it like a good boy. :(
So the document showing this error seems to have lost its current revision, and doesn't have any other revision assigned.

Even more so, it seems to be a broken redirect chain:

1. document 126053 with the path /fr/docs/Mozilla/Add-ons redirects to

2. document 126171 with the path /fr/docs/temp_addons which redirects to

3. document 75131 with the path /fr/docs/Mozilla/Add-ons/ (note the trailing slash)

The document under 3 isn't a redirect, but doesn't have a current revision either.

Since we are stripping trailing slashes (IIRC) accessing document 3. redirects back to 1.

The issue shows up when trying to render sibling translations of the main document (/en-US/Add-ons, document 9544), so my best guess is that this is some kind of data integrity issue that happened when we were down or when the database went away while saving a document. I would recommend fixing the document and seeing if we stop getting errors.
(In reply to Jannis Leidel [:jezdez] from comment #4)
> So the document showing this error seems to have lost its current revision,
> and doesn't have any other revision assigned.
> 
> Even more so, it seems to be a broken redirect chain:
> 
> 1. document 126053 with the path /fr/docs/Mozilla/Add-ons redirects to
> 
> 2. document 126171 with the path /fr/docs/temp_addons which redirects to
> 
> 3. document 75131 with the path /fr/docs/Mozilla/Add-ons/ (note the trailing
> slash)
> 
> The document under 3 isn't a redirect, but doesn't have a current revision
> either.
> 
> Since we are stripping trailing slashes (IIRC) accessing document 3.
> redirects back to 1.
> 
> The issue shows up when trying to render sibling translations of the main
> document (/en-US/Add-ons, document 9544), so my best guess is that this is
> some kind of data integrity issue that happened when we were down or when
> the database went away while saving a document. I would recommend fixing the
> document and seeing if we stop getting errors.

OK... how do we fix it? Edit the contents in the Django admin panel? Since saving changes is broken...
:sheppy If the admin doesn't work, I would like to have permission to fix the data for you manually (in the Python console or maybe even in the database shell).

I would propose to:

1. get rid of documents 1 and 2

2. fix the slug of document 3 to not have a trailing slash and set the current revision to one that matches the documents title and slug

Would that suffice?
Flags: needinfo?(eshepherd)
:sheppy Can you clarify if that strategy is okay with you?
Assignee: nobody → jezdez
Status: NEW → ASSIGNED
(In reply to Jannis Leidel [:jezdez] from comment #9)
> :sheppy Can you clarify if that strategy is okay with you?

Sorry for the delayed reply --

I think that's probably okay. I'm slightly concerned that this means that any saved bookmarks or links to the older doc location will be broken by this. But I think that's an acceptable risk under the circumstances.
Flags: needinfo?(eshepherd)
Ok, I think I've fixed things now. Can you check out https://developer.mozilla.org/fr/docs/Mozilla/Add-ons?
Flags: needinfo?(eshepherd)
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
(In reply to Jannis Leidel [:jezdez] from comment #11)
> Ok, I think I've fixed things now. Can you check out
> https://developer.mozilla.org/fr/docs/Mozilla/Add-ons?

I believe this is good enough. I'll call this closed; if there are residual problems left over from this, please feel free to file a new bug or reopen this one.
Flags: needinfo?(eshepherd)
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.