summaryrefslogtreecommitdiff
path: root/app/models/internal_id.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/internal_id.rb')
-rw-r--r--app/models/internal_id.rb24
1 files changed, 4 insertions, 20 deletions
diff --git a/app/models/internal_id.rb b/app/models/internal_id.rb
index dbd82dda06e..f50f28deffe 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