MM-53747: Do not start if job is in-progress as well. (#24115)

We missed this out last time. It's possible in an HA
scenario for a second pod to start later while the other
job is in-progress. In that case, it would schedule
two jobs.

https://mattermost.atlassian.net/browse/MM-53747

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2023-07-26 20:32:50 +05:30
коммит произвёл GitHub
родитель f10487c511
Коммит b47754e268
9 изменённых файлов: 247 добавлений и 6 удалений

Просмотреть файл

@@ -4534,6 +4534,22 @@ func (s *TimerLayerJobStore) Save(job *model.Job) (*model.Job, error) {
return result, err
}
func (s *TimerLayerJobStore) SaveOnce(job *model.Job) (*model.Job, error) {
start := time.Now()
result, err := s.JobStore.SaveOnce(job)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("JobStore.SaveOnce", success, elapsed)
}
return result, err
}
func (s *TimerLayerJobStore) UpdateOptimistically(job *model.Job, currentStatus string) (bool, error) {
start := time.Now()