[Rails5] MySQL milliseconds problem

Note: add rails5 to a branch name to trigger rails5 specific CI jobs.

https://gitlab.com/jlemaes/gitlab-ce/-/jobs/77350673

Note: this is MySQL only problem. It's not reproducible on PostgreSQL.

Failures:

  1) MergeRequest behaves like throttled touch #touch updates the updated_at timestamp
     Failure/Error: expect(subject.updated_at).to eq(Time.zone.now)

       expected: 2018-06-25 23:04:21.519727340 +0000
            got: 2018-06-25 23:04:21.000000000 +0000

       (compared using ==)
     Shared Example Group: "throttled touch" called from ./spec/models/merge_request_spec.rb:2115
     # ./spec/support/shared_examples/throttled_touch.rb:6:in `block (4 levels) in <top (required)>'
     # ./spec/support/shared_examples/throttled_touch.rb:4:in `block (3 levels) in <top (required)>'

  2) MergeRequest behaves like throttled touch #touch updates the object at most once per minute
     Failure/Error: expect(subject.updated_at).to eq(first_updated_at)

       expected: 2018-06-25 23:02:24.746231637 +0000
            got: 2018-06-25 23:02:24.000000000 +0000

       (compared using ==)
     Shared Example Group: "throttled touch" called from ./spec/models/merge_request_spec.rb:2115
     # ./spec/support/shared_examples/throttled_touch.rb:17:in `block (3 levels) in <top (required)>'

  3) Ci::RetryBuildService#execute when user has ability to execute build behaves like build duplication reject acessors does not clone updated_at build attribute
     Failure/Error: expect(new_build.send(attribute)).not_to eq build.send(attribute)

       expected: value != 2018-06-25 23:06:55.000000000 +0000
            got: 2018-06-25 23:06:55.000000000 +0000

       (compared using ==)
     Shared Example Group: "build duplication" called from ./spec/services/ci/retry_build_service_spec.rb:112
     # ./spec/services/ci/retry_build_service_spec.rb:79:in `block (5 levels) in <top (required)>'

  4) Keys::LastUsedService#execute updates the key when it has not been used recently
     Failure/Error: expect(key.last_used_at).to eq(time)

       expected: 2018-06-25 23:13:09.830359378 +0000
            got: 2018-06-25 23:13:09.000000000 +0000

       (compared using ==)
     # ./spec/services/keys/last_used_service_spec.rb:11:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:160:in `block (2 levels) in <top (required)>'

  5) Keys::LastUsedService#execute does not update the key when it has been used recently
     Failure/Error: expect(key.last_used_at).to eq(time)

       expected: 2018-06-25 23:12:10.328356389 +0000
            got: 2018-06-25 23:12:10.000000000 +0000

       (compared using ==)
     # ./spec/services/keys/last_used_service_spec.rb:20:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:160:in `block (2 levels) in <top (required)>'

Finished in 10 minutes 38 seconds (files took 21.13 seconds to load)
1530 examples, 5 failures, 26 pending
Edited by blackst0ne