Better exclusive lock for merge trains
Problem to solve
Currently, train processor locks the thread until it's finished refreshing all the following merge requests in a train.
This is safe, however, could cause a race condition in the following case:
RefreshMergeRequestsService: PID-1
Case: MR3 pipeline finished
v
| MR1 | MR2 | MR3 | MR4 | MR5 |
RefreshMergeRequestsService: PID-2
Case: MR1 pipeline finished
v <= should be processed
| MR1 | MR2 | MR3 | MR4 | MR5 |
We should process MR1 in PID-2 in the above case, otherwise, MR1 won't be merged.