algoliasearch-django icon indicating copy to clipboard operation
algoliasearch-django copied to clipboard

Algolia doesn't handle Django Atomic Transactions

Open sameerkumar18 opened this issue 6 years ago • 3 comments

  • Django version: 2.0.6
  • Algolia Django integration version: 1.7.0
  • Language Version: Python 3.6.5

Consider - Auto-Index to be True

Description

While in a Django atomic transaction, if anytime save() is called - algolia is instantly updated. If due to some exception that atomic transaction fails, Algolia would still be updated with invalid values that do not match the database.

Steps To Reproduce

Step 1 - Import your model from app, import django transaction

>>> from myapp import mymodel
>>> from django import transaction

Step 2 - Start a transaction // Consider there is boolean field status in model mymodel

>>> with transaction.atomic():
            obj = mymodel.objects.first()
            obj.status = False
            obj.save() # Algolia gets updated here
            raise Exception('something here') # This cancels/doesn't commit anything to the database

sameerkumar18 avatar Jan 12 '19 17:01 sameerkumar18

Thanks for bring this up to our attention, we will take a look soon as possible.

nunomaduro avatar Jan 14 '19 14:01 nunomaduro

Any update here @nunomaduro ?

sameerkumar18 avatar Aug 01 '19 14:08 sameerkumar18

Any update on this issue @nunomaduro ?

mohiuddin06617 avatar Jan 16 '23 09:01 mohiuddin06617