Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wrap mria ro_transaction with maybe_middleman/3 #134

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/mria.erl
Expand Up @@ -341,16 +341,16 @@ wait_for_tables(Tables) ->

-spec ro_transaction(mria_rlog:shard(), fun(() -> A)) -> t_result(A).
ro_transaction(?LOCAL_CONTENT_SHARD, Fun) ->
mnesia:transaction(fun ro_transaction/1, [Fun]);
maybe_middleman(mnesia, transaction, [fun ro_transaction/1, [Fun]]);
ro_transaction(Shard, Fun) ->
case mria_rlog:role() of
core ->
mnesia:transaction(fun ro_transaction/1, [Fun]);
maybe_middleman(mnesia, transaction, [fun ro_transaction/1, [Fun]]);
replicant ->
?tp(mria_ro_transaction, #{role => replicant}),
case mria_status:upstream(Shard) of
{ok, AgentPid} ->
Ret = mnesia:transaction(fun ro_transaction/1, [Fun]),
Ret = maybe_middleman(mnesia, transaction, [fun ro_transaction/1, [Fun]]),
%% Now we check that the agent pid is still the
%% same, meaning the replicant node haven't gone
%% through bootstrapping process while running the
Expand Down