Fix AutoMergeProcessWorker raises an error for merged MRs

Merged Shinya Maeda requested to merge fix-on-train-method-in-mr into master

What does this MR do?

This MR fixes the exception report => #121989 (closed).

Confirmed that the problem can be reproduced by the following steps:

  1. Multiple pipelines finished simulteniously in multiple MRs
  2. Each pipeline invokes AutoMergeProcessWorker to refresh and merge merge requests on train.
  3. Since RefreshMergeRequestsService is concurrent-safe architecture, it exclusively locks the process with one of the MRs. The rest of the items are enqueued and waiting until the currently-running process finished.
  4. After the currently-running process finished, it refreshes the other MRs, but it's already processed (merged) at the 3., it's no longer processible, thus raises an error.

This means Merge Train is functional however causing unnecessary exceptions and triggering sidekiq retry.

Close #121989 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Shinya Maeda