|
149 | 149 | -type gc_state() :: #gc_state { dir :: file:filename(), |
150 | 150 | index_ets :: ets:tid(), |
151 | 151 | file_summary_ets :: ets:tid(), |
152 | | - file_handles_ets :: ets:tid(), |
153 | | - msg_store :: server() |
| 152 | + file_handles_ets :: ets:tid() |
154 | 153 | }. |
155 | 154 |
|
156 | 155 | -type server() :: pid() | atom(). |
@@ -760,8 +759,7 @@ init([VHost, Type, BaseDir, ClientRefs, StartupFunState]) -> |
760 | 759 | #gc_state { dir = Dir, |
761 | 760 | index_ets = IndexEts, |
762 | 761 | file_summary_ets = FileSummaryEts, |
763 | | - file_handles_ets = FileHandlesEts, |
764 | | - msg_store = self() |
| 762 | + file_handles_ets = FileHandlesEts |
765 | 763 | }), |
766 | 764 |
|
767 | 765 | CreditDiscBound = rabbit_misc:get_env(rabbit, msg_store_credit_disc_bound, |
@@ -814,7 +812,6 @@ prioritise_call(Msg, _From, _Len, _State) -> |
814 | 812 |
|
815 | 813 | prioritise_cast(Msg, _Len, _State) -> |
816 | 814 | case Msg of |
817 | | - {compacted_file, _File} -> 8; |
818 | 815 | {client_dying, _Pid} -> 7; |
819 | 816 | _ -> 0 |
820 | 817 | end. |
@@ -914,16 +911,7 @@ handle_cast({remove, CRef, MsgIds}, State) -> |
914 | 911 | ignore -> State2 |
915 | 912 | end |
916 | 913 | end, State, MsgIds), |
917 | | - noreply(State1); |
918 | | - |
919 | | -handle_cast({compacted_file, File}, |
920 | | - State = #msstate { file_summary_ets = FileSummaryEts }) -> |
921 | | - %% This can return false if the file gets deleted immediately |
922 | | - %% after compaction ends, but before we can process this message. |
923 | | - %% So this will become a no-op and we can ignore the return value. |
924 | | - _ = ets:update_element(FileSummaryEts, File, |
925 | | - {#file_summary.locked, false}), |
926 | | - noreply(State). |
| 914 | + noreply(State1). |
927 | 915 |
|
928 | 916 | handle_info(sync, State) -> |
929 | 917 | noreply(internal_sync(State)); |
@@ -2011,8 +1999,7 @@ compact_file(File, State = #gc_state { file_summary_ets = FileSummaryEts }) -> |
2011 | 1999 | compact_file(File, FileSize, |
2012 | 2000 | State = #gc_state { index_ets = IndexEts, |
2013 | 2001 | file_summary_ets = FileSummaryEts, |
2014 | | - dir = Dir, |
2015 | | - msg_store = Server }) -> |
| 2002 | + dir = Dir }) -> |
2016 | 2003 | %% Get metadata about the file. Will be used to calculate |
2017 | 2004 | %% how much data was reclaimed as a result of compaction. |
2018 | 2005 | [#file_summary{file_size = FileSize}] = ets:lookup(FileSummaryEts, File), |
@@ -2048,8 +2035,6 @@ compact_file(File, FileSize, |
2048 | 2035 | Reclaimed = FileSize - TruncateSize, |
2049 | 2036 | ?LOG_DEBUG("Compacted segment file number ~tp; ~tp bytes can now be reclaimed", |
2050 | 2037 | [File, Reclaimed]), |
2051 | | - %% Tell the message store to update its state. |
2052 | | - gen_server2:cast(Server, {compacted_file, File}), |
2053 | 2038 | %% Tell the GC process to truncate the file. |
2054 | 2039 | %% |
2055 | 2040 | %% We will truncate later when there are no readers. We want current |
@@ -2158,6 +2143,8 @@ truncate_file(File, Size, ThresholdTimestamp, #gc_state{ file_summary_ets = File |
2158 | 2143 | ok = file:close(Fd), |
2159 | 2144 | true = ets:update_element(FileSummaryEts, File, |
2160 | 2145 | {#file_summary.file_size, Size}), |
| 2146 | + true = ets:update_element(FileSummaryEts, File, |
| 2147 | + {#file_summary.locked, false}), |
2161 | 2148 | ?LOG_DEBUG("Truncated file number ~tp; new size ~tp bytes", [File, Size]), |
2162 | 2149 | ok |
2163 | 2150 | end |
|
0 commit comments