diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-05-28 13:44:07 +0300 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-05-28 13:46:03 +0300 |
commit | f2cc1169e8c4e4ed209df0c6b50c1f5b69f5fdb0 (patch) | |
tree | 3f6a6659a02d1730ed34950daa26f24824dc3df7 /app/models | |
parent | cfdd80ec10c669a6f6811aef02b0df233a709881 (diff) |
Remove double-checked internal id generation.
This was needed for a transition phase only. For details see #45389.
Closes #45389.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/internal_id.rb | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/app/models/internal_id.rb b/app/models/internal_id.rb index 189942c5ad8..f7f930e86ed 100644 --- a/app/models/internal_id.rb +++ b/app/models/internal_id.rb @@ -24,12 +24,9 @@ class InternalId < ActiveRecord::Base # # The operation locks the record and gathers a `ROW SHARE` lock (in PostgreSQL). # As such, the increment is atomic and safe to be called concurrently. - # - # If a `maximum_iid` is passed in, this overrides the incremented value if it's - # greater than that. This can be used to correct the increment value if necessary. - def increment_and_save!(maximum_iid) + def increment_and_save! lock! - self.last_value = [(last_value || 0) + 1, (maximum_iid || 0) + 1].max + self.last_value = (last_value || 0) + 1 save! last_value end @@ -93,16 +90,7 @@ class InternalId < ActiveRecord::Base # and increment its last value # # Note this will acquire a ROW SHARE lock on the InternalId record - - # Note we always calculate the maximum iid present here and - # pass it in to correct the InternalId entry if it's last_value is off. - # - # This can happen in a transition phase where both `AtomicInternalId` and - # `NonatomicInternalId` code runs (e.g. during a deploy). - # - # This is subject to be cleaned up with the 10.8 release: - # https://gitlab.com/gitlab-org/gitlab-ce/issues/45389. - (lookup || create_record).increment_and_save!(maximum_iid) + (lookup || create_record).increment_and_save! end end @@ -128,15 +116,11 @@ class InternalId < ActiveRecord::Base InternalId.create!( **scope, usage: usage_value, - last_value: maximum_iid + last_value: init.call(subject) || 0 ) end rescue ActiveRecord::RecordNotUnique lookup end - - def maximum_iid - @maximum_iid ||= init.call(subject) || 0 - end end end |