41
41
-define (HEADER_SIZE , 64 ). % % bytes
42
42
-define (ENTRY_SIZE , 32 ). % % bytes
43
43
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
-
53
44
-include_lib (" rabbit_common/include/rabbit.hrl" ).
54
45
% % Set to true to get an awful lot of debug logs.
55
46
-if (false ).
@@ -538,7 +529,6 @@ terminate(VHost, Terms, State0 = #qi { dir = Dir,
538
529
ok = file :sync (Fd ),
539
530
ok = file :close (Fd )
540
531
end , OpenFds ),
541
- file_handle_cache :release_reservation (),
542
532
% % Write recovery terms for faster recovery.
543
533
_ = rabbit_recovery_terms :store (VHost ,
544
534
filename :basename (rabbit_file :binary_to_filename (Dir )),
@@ -555,7 +545,6 @@ delete_and_terminate(State = #qi { dir = Dir,
555
545
_ = maps :map (fun (_ , Fd ) ->
556
546
ok = file :close (Fd )
557
547
end , OpenFds ),
558
- file_handle_cache :release_reservation (),
559
548
% % Erase the data on disk.
560
549
ok = erase_index_dir (rabbit_file :binary_to_filename (Dir )),
561
550
State # qi { segments = #{},
@@ -626,18 +615,9 @@ new_segment_file(Segment, SegmentEntryCount, State = #qi{ segments = Segments })
626
615
% % using too many FDs when the consumer lags a lot. We
627
616
% % limit at 4 because we try to keep up to 2 for reading
628
617
% % and 2 for writing.
629
- reduce_fd_usage (SegmentToOpen , State = # qi { fds = OpenFds })
618
+ reduce_fd_usage (_SegmentToOpen , State = # qi { fds = OpenFds })
630
619
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 ;
641
621
reduce_fd_usage (SegmentToOpen , State = # qi { fds = OpenFds0 }) ->
642
622
case OpenFds0 of
643
623
#{SegmentToOpen := _ } ->
@@ -868,7 +848,6 @@ delete_segment(Segment, State0 = #qi{ fds = OpenFds0 }) ->
868
848
State = case maps :take (Segment , OpenFds0 ) of
869
849
{Fd , OpenFds } ->
870
850
ok = file :close (Fd ),
871
- file_handle_cache :set_reservation (? STORE_FD_RESERVATIONS + map_size (OpenFds )),
872
851
State0 # qi { fds = OpenFds };
873
852
error ->
874
853
State0
0 commit comments