diff --git a/src/ra_log_segment.erl b/src/ra_log_segment.erl index f830b2fd..18788209 100644 --- a/src/ra_log_segment.erl +++ b/src/ra_log_segment.erl @@ -116,17 +116,17 @@ open(Filename, Options) -> process_file(true, Mode, Filename, Fd, Options) -> AccessPattern = maps:get(access_pattern, Options, random), - if AccessPattern == random andalso - Mode == read -> - %% advise for random access for any data beyond our best guess - %% index size, readers could pass `max_count` in the config to - %% ensure this is correct - ConfMaxCount = maps:get(max_count, Options, ?SEGMENT_MAX_ENTRIES), - Offset = ?HEADER_SIZE + (ConfMaxCount * ?INDEX_RECORD_SIZE_V2), - ok = file:advise(Fd, Offset, 0, random); - true -> - ok - end, + % if AccessPattern == random andalso + % Mode == read -> + % %% advise for random access for any data beyond our best guess + % %% index size, readers could pass `max_count` in the config to + % %% ensure this is correct + % ConfMaxCount = maps:get(max_count, Options, ?SEGMENT_MAX_ENTRIES), + % Offset = ?HEADER_SIZE + (ConfMaxCount * ?INDEX_RECORD_SIZE_V2), + % ok = file:advise(Fd, Offset, 0, random); + % true -> + % ok + % end, case read_header(Fd) of {ok, Version, MaxCount} -> MaxPending = maps:get(max_pending, Options, ?SEGMENT_MAX_PENDING), @@ -286,7 +286,7 @@ fold(#state{cfg = #cfg{mode = read} = Cfg, -spec is_modified(state()) -> boolean(). is_modified(#state{cfg = #cfg{fd = Fd}, - data_offset = DataOffset} = State) -> + data_offset = DataOffset} = State) -> case is_full(State) of true -> %% a full segment cannot be appended to.