alphagov/whitehall — pull request #1638 by heathd (2014-08-01 12:02:40+00:00)
Title: Avoid race condition in scheduled publications after data sync

/cc @alext

The nightly data sync from prod->staging takes a while and there's a
potential race condition whereby a document which is scheduled for
publication during this time would not get enqueued on the staging side.
That's because by the time the DataSyncComplete job runs on staging it
is now 'overdue' and so this task would not have enqueued it.

I checked the behaviour of `Sidekiq::Worker#perform_at`[1]. If you
schedule a task in the past then it will run it immediately, which seems
like a reasonable behaviour in this context.

This PR therefore removes the constraint that the `queue_missing_jobs`
rake task should only enqueue future scheduled documents. Instead it
enqueues all scheduled documents including overdue ones.

[1]
https://github.com/mperham/sidekiq/blob/a652117e2e78603450e65985e7061c133599803d/lib/sidekiq/worker.rb#L50-L51