diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-06-18 17:56:16 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-06-18 17:56:16 +0900 |
commit | 494673793d6b4491b2a7843f0614e5bcb3d88a3c (patch) | |
tree | a909451fa3453ec5efb7ea6b6110eca67fa524b2 | |
parent | 71e30c011957229dfa4029b9b04e5308ceed4fcd (diff) | |
download | gitlab-ce-494673793d6b4491b2a7843f0614e5bcb3d88a3c.tar.gz |
Rename persisted? to data_persisted?
-rw-r--r-- | app/models/ci/build_trace_chunk.rb | 18 | ||||
-rw-r--r-- | app/workers/ci/build_trace_chunk_flush_worker.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/build_trace_chunk_spec.rb | 4 |
3 files changed, 10 insertions, 14 deletions
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb index 179c5830678..59096f54f0b 100644 --- a/app/models/ci/build_trace_chunk.rb +++ b/app/models/ci/build_trace_chunk.rb @@ -75,9 +75,7 @@ module Ci raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0 raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize) - in_lock(*lock_params) do - self.reload if self.persisted? - + in_lock(*lock_params) do # Write opetation is atomic unsafe_set_data!(data.byteslice(0, offset) + new_data) end @@ -100,21 +98,19 @@ module Ci (start_offset...end_offset) end - def persisted? + def data_persisted? !redis? end - def persist! - in_lock(*lock_params) do - self.reload if self.persisted? - - unsafe_move_to!(self.class.persist_store) + def persist_data! + in_lock(*lock_params) do # Write opetation is atomic + unsafe_migrate_to!(self.class.persist_store) end end private - def unsafe_move_to!(new_store) + def unsafe_migrate_to!(new_store) return if data_store == new_store.to_s return unless size > 0 @@ -143,7 +139,7 @@ module Ci end def schedule_to_persist - return if persisted? + return if data_persisted? Ci::BuildTraceChunkFlushWorker.perform_async(id) end diff --git a/app/workers/ci/build_trace_chunk_flush_worker.rb b/app/workers/ci/build_trace_chunk_flush_worker.rb index 8e08ccbc414..49ff0f4ab94 100644 --- a/app/workers/ci/build_trace_chunk_flush_worker.rb +++ b/app/workers/ci/build_trace_chunk_flush_worker.rb @@ -5,7 +5,7 @@ module Ci def perform(build_trace_chunk_id) ::Ci::BuildTraceChunk.find_by(id: build_trace_chunk_id).try do |build_trace_chunk| - build_trace_chunk.persist! + build_trace_chunk.persist_data! end end end diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb index f0c36067c87..79e0f1f20bf 100644 --- a/spec/models/ci/build_trace_chunk_spec.rb +++ b/spec/models/ci/build_trace_chunk_spec.rb @@ -286,8 +286,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do end end - describe '#persist!' do - subject { build_trace_chunk.persist! } + describe '#persist_data!' do + subject { build_trace_chunk.persist_data! } context 'when data_store is redis' do let(:data_store) { :redis } |