From 0b0938ff8cd2a0527dd62aa69155f6bf6c9b8437 Mon Sep 17 00:00:00 2001 From: Yosuke Hara Date: Sat, 22 Jul 2017 23:32:59 +0900 Subject: [PATCH] Fixed for leo-project/leofs/issues/783 --- src/leo_mq_server.erl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/leo_mq_server.erl b/src/leo_mq_server.erl index 9d610f8..d320b35 100644 --- a/src/leo_mq_server.erl +++ b/src/leo_mq_server.erl @@ -196,14 +196,10 @@ init([Id, WorkerSeqNum, #mq_properties{db_name = DBName, %% @doc gen_server callback - Module:handle_call(Request, From, State) -> Result handle_call({enqueue, KeyBin, MessageBin}, _From, #state{backend_db_id = BackendDbId} = State) -> - Reply_1 = - case leo_backend_db_server:get(BackendDbId, KeyBin) of - not_found -> - put_message(KeyBin, MessageBin, BackendDbId); - _ -> - ok - end, - {reply, Reply_1, State}; + %% ALways insert/overwrite the latest message of an object because its message includes 'metadata' + %% in case of object-recovery to keep its object's consistency + Reply = put_message(KeyBin, MessageBin, BackendDbId), + {reply, Reply, State}; handle_call(dequeue, _From, #state{backend_db_id = BackendDbId} = State) -> Reply = case catch leo_backend_db_server:first(BackendDbId) of