Skip to content

Commit

Permalink
Merge pull request #69 from rabbitmq/mk-consistent-returned-invalid-o…
Browse files Browse the repository at this point in the history
…ffset-epoch-atom

Make init_reader and init_data_reader use a consistent return value
  • Loading branch information
michaelklishin authored Mar 18, 2022
2 parents 46185f8 + 27220a8 commit 167d3ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/osiris_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ truncate_to(Name, Range, [{E, ChId} | NextEOs], SegInfos) ->
{offset_out_of_range,
empty | {offset(), offset()}}} |
{error,
{invalid_last_epoch_offset, epoch(), offset()}}.
{invalid_last_offset_epoch, epoch(), offset()}}.
init_data_reader({StartChunkId, PrevEOT}, #{dir := Dir} = Config) ->
SegInfos = build_log_overview(Dir),
Range = offset_range_from_segment_infos(SegInfos),
Expand Down Expand Up @@ -849,7 +849,7 @@ check_chunk_has_expected_epoch(ChunkId, Epoch, SegInfos) ->
not_found ->
%% this is unexpected and thus an error
{error,
{invalid_last_epoch_offset, Epoch, unknown}};
{invalid_last_offset_epoch, Epoch, unknown}};
{found, SegmentInfo = #seg_info{file = _PrevSeg}} ->
%% prev segment exists, does it have the correct
%% epoch?
Expand All @@ -858,7 +858,7 @@ check_chunk_has_expected_epoch(ChunkId, Epoch, SegInfos) ->
ok;
{ChunkId, OtherEpoch, _} ->
{error,
{invalid_last_epoch_offset, Epoch, OtherEpoch}}
{invalid_last_offset_epoch, Epoch, OtherEpoch}}
end
end.

Expand Down
2 changes: 1 addition & 1 deletion test/osiris_log_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ init_data_reader_truncated(Config) ->
osiris_log:close(L2),

% %% however attaching with a different epoch should be disallowed
?assertEqual({error, {invalid_last_epoch_offset, 2, 1}},
?assertEqual({error, {invalid_last_offset_epoch, 2, 1}},
osiris_log:init_data_reader({750, {2, 700, ?LINE}}, RConf)),
osiris_log:close(L2),
ok.
Expand Down

0 comments on commit 167d3ef

Please sign in to comment.