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

Make CETS joining logic more reliable #12

Merged
merged 17 commits into from
Aug 4, 2023
Merged

Make CETS joining logic more reliable #12

merged 17 commits into from
Aug 4, 2023

Conversation

arcusfelis
Copy link
Contributor

@arcusfelis arcusfelis commented Aug 1, 2023

This issue addresses MIM-1968.

The changes include:

  • Tests for cets_join
  • Step function to write tests for joining procedure
  • Fixes for the logic - we do more validation before applying the changes
  • We set join_ref when we join - all nodes should have the same join_ref after joining.
  • We actually check join_ref before sending messages, check check_server in cets module.
  • We don't catch errors for long calls anymore - it confuses result types. It also leads to nested {error, {error, _}_} when there is long call inside of a long operation
  • There is an issue in cover code reports, so we have to make a map outside of LOG_ERROR call and pass it into it. I don't think there would be any performance issues (unless someone disables all log messages), but still we could fix it once OTP fixes cover tool. For now I prefer good cover reports - they actually allow to find errors in logic Coverage is broken for multiline logging call erlang/otp#7531

@arcusfelis arcusfelis marked this pull request as draft August 1, 2023 20:38
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Patch coverage: 97.22% and project coverage change: +4.40% 🎉

Comparison is base (b4fefc9) 86.29% compared to head (2cbb2d4) 90.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #12      +/-   ##
==========================================
+ Coverage   86.29%   90.69%   +4.40%     
==========================================
  Files           8        8              
  Lines         372      430      +58     
==========================================
+ Hits          321      390      +69     
+ Misses         51       40      -11     
Files Changed Coverage Δ
src/cets_discovery_file.erl 62.50% <0.00%> (ø)
src/cets_call.erl 80.00% <75.00%> (+4.00%) ⬆️
src/cets.erl 99.41% <100.00%> (+3.25%) ⬆️
src/cets_join.erl 97.93% <100.00%> (+5.21%) ⬆️
src/cets_long.erl 84.37% <100.00%> (+11.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Add step function into cets_join
So servers could verify if join_ref matches
Add join_fails_before_send_dump_and_there_are_pending_remote_ops testcase
Add join_fails_in_check_fully_connected testcase
…stcase

Add join_fails_because_pids_do_not_match_for_nodes_in_segment testcase
They break coverage report (underreported lines)
Add check_do_not_overlap into cets_join
@arcusfelis arcusfelis marked this pull request as ready for review August 3, 2023 21:32
Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code itself is OK for me 👍
I only have an issue with the actual concept of steps, which are checkpoints between steps. I think a cleaner option would be to use a fold operation over a list of steps.

For example, see:

I also consider the new syntax for logging errors a bit of verbose, and now we contruct the terms even if logs are disabled for the given level, which kind of defeats the purpose of the macro...

JoinRef.

-spec run_step(step(), join_opts()) -> ok.
run_step(Step, #{step_handler := F}) ->
Copy link
Member

@chrzaszcz chrzaszcz Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this is counter-intuitive, because this function isn't actually running the step, but runs some custom injected logic between steps. It's a lot of bending the code to fit the tests, and gives the impression of being overly complicated...

Result ->
Result
end.

join2(_Info, LocalPid, RemotePid) ->
join2(_Info, LocalPid, RemotePid, JoinOpts) ->
run_step(join_start, JoinOpts),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it would be cleaner if there was a lists:foldl over a list of functions performing the actual steps, and in tests you could use meck to inject some logic when needed - by changing the actual step function.

Copy link
Member

@chrzaszcz chrzaszcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cleaner with the checkpoints

@chrzaszcz chrzaszcz merged commit 6094d51 into main Aug 4, 2023
6 checks passed
@chrzaszcz chrzaszcz deleted the mu-cets-join-tests branch August 4, 2023 11:48
@arcusfelis arcusfelis mentioned this pull request Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants