Possible Deadlocks
I only looked at the code and didn't try it out, but I believe that there are possible deadlock situations, and therefore blocking until the timeout. Because other pipelines can enter the running
state before the call to gitlab-job-guard
.
Example:
- Pipeline 1 starts.
- Pipeline 2 starts.
- Pipeline 1 calls
gitlab-job-guard
and blocks because there is a conflicting Pipeline 2. - Pipeline 2 calls
gitlab-job-guard
and blocks because there is a conflicting Pipeline 1.
This is not a problem in the default situation in which Pipeline 1 executes gitlab-job-guard
before Pipeline 2 starts (this is not guaranteed in any way):
- Pipeline 1 starts.
- Pipeline 1 calls
gitlab-job-guard
and does not block. It continues executing. - Pipeline 2 starts.
- Pipeline 2 calls
gitlab-job-guard
and blocks because there is a conflicting Pipeline 1. - Pipeline 1 finishes.
-
gitlab-job-guard
in Pipeline 2 detects that there are no conflicting pipelines anymore. It continues executing. - Pipeline 2 finishes.
With more than two pipelines it is more likely to result in problems:
- Pipeline 1 starts.
- Pipeline 1 calls
gitlab-job-guard
and does not block. It continues executing. - Pipeline 2 starts.
- Pipeline 2 calls
gitlab-job-guard
and blocks because there is a conflicting Pipeline 1. - Pipeline 3 starts.
- Pipeline 1 finishes.
- Pipeline 2 continues to block because there is a conflicting Pipeline 3.
- Pipeline 3 calls
gitlab-job-guard
and blocks because there is a conflicting Pipelines 2.