Make chunked upload jobs robust in face of exceptions.
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 6 Apr 2014 02:15:26 +0000 (23:15 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sun, 6 Apr 2014 02:15:26 +0000 (23:15 -0300)
commiteef642ef1d0aa68420d334fe25bb7f7a8f5a5540
tree0602105221fcbeb1dc28fa0268775e9b2f0ce737
parentad937e5033e1d3449171ed27f3803bf149b7a2e8
Make chunked upload jobs robust in face of exceptions.

If an exception occurs when creating the new image page during
PublishStashedFile (for example, if ExternalStorage servers
become overloaded), the job is aborted, but the current
transaction is not aborted. Then the next job comes along, does
$dbw->begin(), which implicitly commits the current open
transactions, causing database corruption (entries in page table
with page_latest = 0).

This patch ensures that if some unknown exception occurs during
the job, that the database gets rolled back to a known good state.

I also plan to make a separate patch to make the recordUpload
code handle exceptions properly. Nonetheless, I think its
important that the general job code be as robust as possible.

Bug: 32551
Change-Id: Icb5e06e81700e5dcf0d4e739c7b2bb3221e718b8
includes/jobqueue/jobs/AssembleUploadChunksJob.php
includes/jobqueue/jobs/PublishStashedFileJob.php