/api/v4/jobs/request error: ActiveRecord::RecordNotSaved: Failed to remove the existing associated runner_session. The record failed to save after its fore...

https://sentry.gitlab.net/gitlab/gitlabcom/issues/998793/

ActiveRecord::RecordNotSaved: Failed to remove the existing associated runner_session. The record failed to save after its foreign key was set to nil.
  active_record/associations/has_one_association.rb:93:in `remove_target!'
    raise RecordNotSaved, "Failed to remove the existing associated #{reflection.name}. " \
  active_record/associations/has_one_association.rb:37:in `block in replace'
    remove_target!(options[:dependent]) if target && !target.destroyed? && assigning_another_record
  active_record/associations/has_one_association.rb:107:in `transaction_if'
    yield
  active_record/associations/has_one_association.rb:36:in `replace'
    transaction_if(save) do
  active_record/associations/has_one_association.rb:77:in `set_new_record'
    replace(record, false)
...
(140 additional frame(s) were not displayed)

ActiveRecord::RecordNotSaved: Failed to remove the existing associated runner_session. The record failed to save after its foreign key was set to nil.