Runner version update

We do update version and revision of Runner in Database.

We did discover today @maratkalibek that on GitLab.com we have a few floppy runners.

The runners that use the same token on more then one instance, and these runners are running different versions. This forces a constant UPDATE of version and revision stored for this runner.

This leads to a lot of vacuuming of ci_runners due to updates:

                                              substring                                               | calls |    total_time    | rows  |    average_time    
------------------------------------------------------------------------------------------------------+-------+------------------+-------+--------------------
 UPDATE "ci_runners" SET "version" = $1, "revision" = $2, "updated_at" = $3 WHERE "ci_runners"."id" = | 22637 | 3091.20400000001 | 22637 |  0.136555373945311
  • 22637 updates from last hour

A way to find these floppy runners:

ids_revs=Ci::Runner.where('updated_at > ?', 15.second.ago).where.not(revision: nil).order(:id).pluck(:id, :revision)
ids = ids_revs.map(&:first)
ids_revs = ids_revs.inject({}) { |h,k| h[k.first]=k.last; h }

# execute in a few seconds a few times
puts Ci::Runner.where(id: ids_revs.map(&:first)).pluck(:id, :version, :revision).select { |k| ids_revs[k.first] != k.last }.map(&:to_s)

(I did count 5 of them on GitLab.com)

This seems like a really strong candidate to fix. Probably we should solve that ASAP.

cc @pcarranza @stanhu @yorickpeterse