Duplicate key errors when uploading attachments

Either through user error (double-submit) or retry caused by timeouts,
we often get errors raised due to duplicate keys because the same
attachment is uploaded twice in quick succession. These changes handle
this specific case.
Merge pull request #1367 from alphagov/duplicate-attachment-ordering-keys-bug-68177788

Duplicate key errors when uploading attachments