Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

kinto-signer raises an exception when trying to delete already deleted records #82

Merged
merged 1 commit into from
May 17, 2016

Conversation

Natim
Copy link
Member

@Natim Natim commented May 17, 2016

The exception is raised here: https://github.com/Kinto/kinto-signer/blob/master/kinto_signer/updater.py#L147

I don't know yet how this can of raise can happen but we should catch the exception.

@Natim Natim added the bug label May 13, 2016
@tarekziade
Copy link
Contributor

TB

Traceback (most recent call last):
  File "/data/kinto-dist/lib/python2.7/site-packages/pyramid/tweens.py", line 20, in excview_tween
    response = handler(request)
  File "/data/kinto-dist/lib/python2.7/site-packages/pyramid_tm/__init__.py", line 101, in tm_tween
    reraise(*exc_info)
  File "/data/kinto-dist/lib/python2.7/site-packages/pyramid_tm/__init__.py", line 90, in tm_tween
    manager.commit()
  File "/data/kinto-dist/lib/python2.7/site-packages/transaction/_manager.py", line 111, in commit
    return self.get().commit()
  File "/data/kinto-dist/lib/python2.7/site-packages/transaction/_transaction.py", line 265, in commit
    self._callBeforeCommitHooks()
  File "/data/kinto-dist/lib/python2.7/site-packages/transaction/_transaction.py", line 337, in _callBeforeCommitHooks
    hook(*args, **kws)
  File "/data/kinto-dist/lib/python2.7/site-packages/cliquet/events.py", line 84, in _notify_resource_events_before
    request.registry.notify(event)
  File "/data/kinto-dist/lib/python2.7/site-packages/pyramid/registry.py", line 91, in notify
    [ _ for _ in self.subscribers(events, None) ]
  File "/data/kinto-dist/lib/python2.7/site-packages/zope/interface/registry.py", line 328, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/data/kinto-dist/lib/python2.7/site-packages/zope/interface/adapter.py", line 596, in subscribers
    subscription(*objects)
  File "/data/kinto-dist/lib/python2.7/site-packages/pyramid/config/adapters.py", line 130, in subscriber_wrapper
    return derived_subscriber(*arg)
  File "/data/kinto-dist/lib/python2.7/site-packages/pyramid/config/adapters.py", line 103, in derived_subscriber
    return subscriber(arg[0])
  File "/data/kinto-dist/lib/python2.7/site-packages/kinto_signer/hook.py", line 53, in on_resource_changed
    updater.sign_and_update_remote()
  File "/data/kinto-dist/lib/python2.7/site-packages/kinto_signer/updater.py", line 72, in sign_and_update_remote
    self.push_records_to_destination()
  File "/data/kinto-dist/lib/python2.7/site-packages/kinto_signer/updater.py", line 147, in push_records_to_destination
    object_id=record['id'],
  File "/data/kinto-dist/lib/python2.7/site-packages/cliquet/storage/postgresql/__init__.py", line 354, in delete
    raise exceptions.RecordNotFoundError(object_id)
RecordNotFoundError: 12d3058e-22cd-XXXX-a0e7-XXXXX

@tarekziade
Copy link
Contributor

The scenario is the following:

  1. the destination collection is empty, or in a state that completely different from the stage collection
  2. the code lists records that get deleted on the stage collection
  3. the code tries to delete those records on the destination collection without checking if they exist

Catching RecordNotFoundError errors and ignoring them fixes the issue, but is this the best solution for syncing the destination collection ?

@Natim
Copy link
Member Author

Natim commented May 17, 2016

is this the best solution for syncing the destination collection ?

I think it is 👍

@Natim
Copy link
Member Author

Natim commented May 17, 2016

r? @tarekziade

@Natim Natim mentioned this pull request May 17, 2016
3 tasks
@tarekziade
Copy link
Contributor

r+

@Natim Natim merged commit 16c7bf6 into master May 17, 2016
@Natim Natim deleted the 82-skip-missing-deleted branch May 17, 2016 09:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants