Skip to content

Commit 8c0fd4f

Browse files
author
Loïc Hoguin
committed
Close fd open in msg store client before hibernating
1 parent 76ee654 commit 8c0fd4f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

deps/rabbit/src/rabbit_msg_store.erl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
-export([start_link/5, successfully_recovered_state/1,
1313
client_init/3, client_terminate/1, client_delete_and_terminate/1,
14-
client_ref/1,
14+
client_pre_hibernate/1, client_ref/1,
1515
write/4, write_flow/4, read/2, read_many/2, contains/2, remove/2]).
1616

1717
-export([set_maximum_since_use/2,
@@ -459,6 +459,12 @@ client_delete_and_terminate(CState = #client_msstate { client_ref = Ref }) ->
459459
ok = server_cast(CState, {client_delete, Ref}),
460460
client_maybe_close_current_file(CState).
461461

462+
-spec client_pre_hibernate(client_msstate()) -> client_msstate().
463+
464+
client_pre_hibernate(CState) ->
465+
client_maybe_close_current_file(CState),
466+
CState#client_msstate{ current_file = undefined }.
467+
462468
client_maybe_close_current_file(#client_msstate{ current_file = CurrentFile }) ->
463469
case CurrentFile of
464470
undefined -> ok;

deps/rabbit/src/rabbit_variable_queue.erl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,15 @@ timeout(State = #vqstate { index_mod = IndexMod,
804804
handle_pre_hibernate(State = #vqstate { index_mod = IndexMod,
805805
index_state = IndexState0,
806806
store_state = StoreState0,
807+
msg_store_clients = MSCState0,
807808
unconfirmed_simple = UCS,
808809
confirmed = C }) ->
810+
MSCState = msg_store_pre_hibernate(MSCState0),
809811
IndexState = IndexMod:flush(IndexState0),
810812
StoreState = rabbit_classic_queue_store_v2:sync(StoreState0),
811813
State #vqstate { index_state = IndexState,
812814
store_state = StoreState,
815+
msg_store_clients = MSCState,
813816
unconfirmed_simple = sets:new([{version,2}]),
814817
confirmed = sets:union(C, UCS) }.
815818

@@ -1349,6 +1352,10 @@ msg_store_client_init(MsgStore, Ref, MsgOnDiskFun, VHost) ->
13491352
rabbit_vhost_msg_store:client_init(VHost, MsgStore,
13501353
Ref, MsgOnDiskFun).
13511354

1355+
msg_store_pre_hibernate({MSCStateP, MSCStateT}) ->
1356+
{rabbit_msg_store:client_pre_hibernate(MSCStateP),
1357+
rabbit_msg_store:client_pre_hibernate(MSCStateT)}.
1358+
13521359
msg_store_write(MSCState, IsPersistent, SeqId, MsgId, Msg) ->
13531360
with_immutable_msg_store_state(
13541361
MSCState, IsPersistent,

0 commit comments

Comments
 (0)