alphagov/whitehall — pull request #1475 by tekin (2014-05-12 14:16:05+00:00)
Title: Delay search indexing to work around transaction

Scheduled publishing is currently performed every 15 minutes across all
backend machines (keeps all machines equal and introduces redundancy
into the process) using a rake task. Each due edition is published by
EditionPublishingWorker, which performs the action with a transaction
lock so that only one backend machine will actually succeed if more
than one attempt to publish the same edition. The issue is that whilst
the transation is in progress, the edition will remain in a "scheduled"
state. And because search indexing is performed asynchronously by
sidekiq, it is sometimes the case that the search indexing job will be
picked up and attempted before the transaction can complete. This
results in the edition not being indexed, as EditionPublishingWorker
will not index a non-"published" edition.

This change introduces a 10 second delay to the search indexing
job to give the transaction enough time to complete.

Note that this is a temporary measure to get scheduled editions
indexing reliably. A story is to be spun up for a fuller solution that
doesn't rely on a transaction lock when publishing scheduled editions.