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
fix(mnesia_acl): introduce optimized schema and migration process #5885
Conversation
maybe it is safer not to remove the old table and just leave it or? |
In general, there is one assumption that all nodes in the cluster should participate in the migration but I wonder if users is ok with that since normally they try a new version on one of the nodes then decide if they should go for it or fallback, especially when they want to try the fix in this PR on the new node only. |
I am just putting the limitation here and I am not asking for a change. |
@k32 do you remember where is the code for data export & import ? |
Code for the data import/export is located in this module: |
a9a7368
to
e1c09bc
Compare
8f7d1c2
to
2609814
Compare
1e1c4f4
to
fd3fe5b
Compare
Great job! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I am not familiar with QLC, someone should review that part. |
fd3fe5b
to
fcdb9ac
Compare
login_match_spec_new(LoginSpec) -> | ||
[{{?ACL_TABLE2, LoginSpec, '_'}, [], ['$_']}]. | ||
|
||
login_match_spec_old(LoginSpec) -> | ||
[{{?ACL_TABLE, {LoginSpec, '_'}, '_', '_', '_'}, [], ['$_']}]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would it make sense to use a pattern that does not depend on field order or changes?
Like:
login_match_spec_new(LoginSpec) ->
[{#?ACL_TABLE2{_ = '_', who = LoginSpec}, [], ['$_']}].
login_match_spec_old(LoginSpec) ->
[{#?ACL_TABLE{_ = '_', filter = {LoginSpec, '_'}}, [], ['$_']}].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now dialyzer hates it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One trick to use record definition for ets match, and still have sane types is the following:
-record(foo, {a, b}). %% Record definition doesn't specify field types
-type foo() :: #foo{a :: foo(), b :: bar()}. %% Create a typedef that specifies field types and use it in the specs instead of #foo{} type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then we will loose useful warnings too 🤔
I mean, when we put #foo{b = NotABar}
unintentionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that was bad for dialyzer, sorry. 🙊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using record is better.
we can suppress dialyzer warnings. e.g. -dialyzer({nowarn_function,foo/3})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that we can't just disable warnings for single funs, because dialyzer looses their typings and fails in other places, like https://github.com/emqx/emqx/runs/4013130567?check_suite_focus=true#step:6:87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a variant with ets:fun2ms
that also allows to construct matchspecs without concerning about unspecified fields.
Additionally, the external API of emqx_acl_mnesia_db
module now does not receive match_head parts.
d6dae1f
to
0860f90
Compare
2f1317e
to
6d48bbf
Compare
This is an optimization to fix #5506