Skip to content

Commit

Permalink
update_index: avoid "MySQL has gone away error" with workers
Browse files Browse the repository at this point in the history
This fixes an issue with a stale database connection being passed to
a multiprocessing worker when using `--remove`

Thanks to @ebressler for the patch

Closes #1201
  • Loading branch information
Eric Bressler (Platform) authored and acdha committed May 29, 2015
1 parent cecb459 commit 3fe4e96
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions haystack/management/commands/update_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ def update_backend(self, label, using):
pool.join()

if self.remove:
# Close the database connection to avoid a “MySQL has gone away” error
# when using workers:
db.close_connection()

if self.start_date or self.end_date or total <= 0:
# They're using a reduced set, which may not incorporate
# all pks. Rebuild the list with everything.
Expand Down

0 comments on commit 3fe4e96

Please sign in to comment.