4141-define (HEADER_SIZE , 64 ). % % bytes
4242-define (ENTRY_SIZE , 32 ). % % bytes
4343
44- % % The file_handle_cache module tracks reservations at
45- % % the level of the process. This means we cannot
46- % % handle them independently in the store and index.
47- % % Because the index may reserve more FDs than the
48- % % store the index becomes responsible for this and
49- % % will always reserve at least 2 FDs, and release
50- % % everything when terminating.
51- -define (STORE_FD_RESERVATIONS , 2 ).
52-
5344-include_lib (" rabbit_common/include/rabbit.hrl" ).
5445% % Set to true to get an awful lot of debug logs.
5546-if (false ).
@@ -538,7 +529,6 @@ terminate(VHost, Terms, State0 = #qi { dir = Dir,
538529 ok = file :sync (Fd ),
539530 ok = file :close (Fd )
540531 end , OpenFds ),
541- file_handle_cache :release_reservation (),
542532 % % Write recovery terms for faster recovery.
543533 _ = rabbit_recovery_terms :store (VHost ,
544534 filename :basename (rabbit_file :binary_to_filename (Dir )),
@@ -555,7 +545,6 @@ delete_and_terminate(State = #qi { dir = Dir,
555545 _ = maps :map (fun (_ , Fd ) ->
556546 ok = file :close (Fd )
557547 end , OpenFds ),
558- file_handle_cache :release_reservation (),
559548 % % Erase the data on disk.
560549 ok = erase_index_dir (rabbit_file :binary_to_filename (Dir )),
561550 State # qi { segments = #{},
@@ -626,18 +615,9 @@ new_segment_file(Segment, SegmentEntryCount, State = #qi{ segments = Segments })
626615% % using too many FDs when the consumer lags a lot. We
627616% % limit at 4 because we try to keep up to 2 for reading
628617% % and 2 for writing.
629- reduce_fd_usage (SegmentToOpen , State = # qi { fds = OpenFds })
618+ reduce_fd_usage (_SegmentToOpen , State = # qi { fds = OpenFds })
630619 when map_size (OpenFds ) < 4 ->
631- % % The only case where we need to update reservations is
632- % % when we are opening a segment that wasn't already open,
633- % % and we are not closing another segment at the same time.
634- case OpenFds of
635- #{SegmentToOpen := _ } ->
636- State ;
637- _ ->
638- file_handle_cache :set_reservation (? STORE_FD_RESERVATIONS + map_size (OpenFds ) + 1 ),
639- State
640- end ;
620+ State ;
641621reduce_fd_usage (SegmentToOpen , State = # qi { fds = OpenFds0 }) ->
642622 case OpenFds0 of
643623 #{SegmentToOpen := _ } ->
@@ -868,7 +848,6 @@ delete_segment(Segment, State0 = #qi{ fds = OpenFds0 }) ->
868848 State = case maps :take (Segment , OpenFds0 ) of
869849 {Fd , OpenFds } ->
870850 ok = file :close (Fd ),
871- file_handle_cache :set_reservation (? STORE_FD_RESERVATIONS + map_size (OpenFds )),
872851 State0 # qi { fds = OpenFds };
873852 error ->
874853 State0
0 commit comments