From c825f6deea9716f4a80f116aa3890cf39aef0b3e Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 13 Feb 2015 00:13:02 +0100 Subject: [PATCH] mod_mam: Don't use transactions for read access It shouldn't be necessary to query the archive in transaction context. In dirty context, the mam_meta data might be outdated when the mam_msg table is queried, but the effects will be harmless. --- mod_mam/src/mod_mam.erl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mod_mam/src/mod_mam.erl b/mod_mam/src/mod_mam.erl index d068b42..edcc969 100644 --- a/mod_mam/src/mod_mam.erl +++ b/mod_mam/src/mod_mam.erl @@ -929,9 +929,7 @@ send_fin_message(#jid{lserver = Host} = JID, QueryID, -spec query_archive(mam_query(), db_type()) -> mam_result() | {error, _}. query_archive(Query, mnesia) -> - {atomic, Result} = - mnesia:transaction(fun() -> collect_messages(Query, mnesia) end), - Result. + mnesia:sync_dirty(fun() -> collect_messages(Query, mnesia) end), -spec read_meta(mam_jid(), db_type()) -> mam_meta(). @@ -1001,7 +999,7 @@ collect_messages(#mam_query{mam_jid = {U, S}, filtered -> collect_next(Query, QueryState, Meta, N, DBType); not_found -> - ?ERROR_MSG("MAM message ~B of ~s@~s not found", [ID, U, S]), + ?DEBUG("MAM message ~B of ~s@~s not found", [ID, U, S]), collect_next(Query, QueryState, Meta, N - 1, DBType) end. @@ -1024,7 +1022,7 @@ collect_next(#mam_query{direction = aft} = Query, read_message(Key, Filter, mnesia) -> ReadMsg = fun() -> mnesia:read(mam_msg, Key) end, - case mnesia:activity(transaction, ReadMsg, [], mnesia_frag) of + case mnesia:activity(sync_dirty, ReadMsg, [], mnesia_frag) of [#mam_msg{} = Msg] -> case filter_message(Msg, Filter) of pass ->