django-haystack / django-haystack/celery-haystack

When using a database table broker, django-celery-transactions breaks commit_on_success decorator

Open
#17 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
226
Forks
95
PR merge metrics
No merged PRs in 30d

Description

This is a curious one; I'm only guessing this is the right project to report the bug; I don't see an obvious way to fix it though, and it is a bit of an edge case.

  • My function uses @transaction.commit_on_success.
  • It saves a model instance that is attached to a search index.
  • Via a post_save hook, celery-haystack wants to send the update task to celery.
  • django-celery-transactions holds the task back for now.
  • My function ends, commit_on_success executes a COMMIT, sets the connection is_dirty flag to False.
  • django-celery-transactions, via it's post_commit patching, now triggers the celery task sends.
  • Since I'm using the database broker, the database connection is dirtied again in this step.
  • Finally, the code of Django's commit_on_success decorator calls leave_transaction_management, which checks the dirty flag and fails with: ```django-celery-transactions`.

This is using Django 1.5 and Haystack 2 Beta.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the sequence involving Django 1.5's transaction.commit_on_success, the post_save hook, django-celery-transactions' post_commit patching, and a database broker. Trace the connection's is_dirty flag through the final leave_transaction_management call. Done means the Celery task can be sent after commit without the decorator failing.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.