diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-05-03 14:57:15 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-05-03 14:57:15 +0900 |
commit | 45dc7ae2d22ceb2679a9c72367f3bb62051ce226 (patch) | |
tree | 892d0561562d6873c7609c307a93d67450edc8c2 /app/models | |
parent | 90da0d4fe2a96248f864e003c1cf7f958f46c421 (diff) | |
download | gitlab-ce-45dc7ae2d22ceb2679a9c72367f3bb62051ce226.tar.gz |
Clean up build_trace_chunk
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build_trace_chunk.rb | 17 | ||||
-rw-r--r-- | app/models/concerns/fast_destroy_all.rb | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index bdba9e6ed3c..74b56ffed53 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -80,8 +80,7 @@ module Ci break unless size > 0 self.update!(raw_data: data, data_store: :db) - key = self.class.redis_data_key(build_id, chunk_index) - self.class.redis_delete_data([key]) + self.class.redis_delete_data([redis_data_key]) end end @@ -129,22 +128,24 @@ module Ci def redis_data Gitlab::Redis::SharedState.with do |redis| - redis.get(self.class.redis_data_key(build_id, chunk_index)) + redis.get(redis_data_key) end end def redis_set_data(data) Gitlab::Redis::SharedState.with do |redis| - redis.set(self.class.redis_data_key(build_id, chunk_index), data, ex: CHUNK_REDIS_TTL) + redis.set(redis_data_key, data, ex: CHUNK_REDIS_TTL) end end - def redis_lock_key - "trace_write:#{build_id}:chunks:#{chunk_index}" + def redis_data_key + self.class.redis_data_key(build_id, chunk_index) end def in_lock - lease = Gitlab::ExclusiveLease.new(redis_lock_key, timeout: WRITE_LOCK_TTL) + write_lock_key = "trace_write:#{build_id}:chunks:#{chunk_index}" + + lease = Gitlab::ExclusiveLease.new(write_lock_key, timeout: WRITE_LOCK_TTL) retry_count = 0 until uuid = lease.try_obtain @@ -159,7 +160,7 @@ module Ci self.reload if self.persisted? return yield ensure - Gitlab::ExclusiveLease.cancel(redis_lock_key, uuid) + Gitlab::ExclusiveLease.cancel(write_lock_key, uuid) end end end diff --git a/app/models/concerns/fast_destroy_all.rb b/app/models/concerns/fast_destroy_all.rb index 7639af35b69..0f6b57ff571 100644 --- a/app/models/concerns/fast_destroy_all.rb +++ b/app/models/concerns/fast_destroy_all.rb @@ -22,7 +22,7 @@ module FastDestroyAll class_attribute :_delete_method, :_delete_params_generator before_destroy do - raise ForbiddenActionError, '`destroy` is forbbiden, please use `fast_destroy_all`' + raise ForbiddenActionError, '`destroy` and `destroy_all` are forbbiden. Please use `fast_destroy_all`' end end |