fix(mnesia): load ram_copies table from 'better' copy when start#11020
Open
qzhuyan wants to merge 1 commit into
Open
fix(mnesia): load ram_copies table from 'better' copy when start#11020qzhuyan wants to merge 1 commit into
qzhuyan wants to merge 1 commit into
Conversation
Contributor
CT Test Results 2 files 61 suites 19m 8s ⏱️ Results for commit ddc6d9d. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
Without this fix, ram_copies is 'safe loaded' locally when remote nodes
have not been connected (yet). This makes the table accessible by application
becasue 'where_to_read' is set to local node().
```
mnesia:dirty_read(emqx_route_filters,1).
[]
```
Also when remote node is connected afterwards, ram_copies table will not load the 'better'
copy, this makes the data inconsistent within the cluster.
This commit fix that during mnesia start, ram_copy table should NOT
do local safe load when there is a better copy from the remote. the
where_to_read will stay in 'nowhere' and table access won't be served.
```
mnesia:dirty_read(emqx_route_filters,1).
** exception exit: {aborted,{no_exists,[emqx_route_filters,1]}}
```
After remote node is connected, local node will do `net_load_table` from
the remote.
Resue `adopt_orphans` function to resolve the conflicts when there is a
deadlock of deciding the better copy, that is the same behaviour for
disc_copies tables.
note1: BetterCopies0 = mnesia_lib:remote_copy_holders(Cs) -- Downs
note2: disc copy table has no such issue.
note3: if there is no better copy (when other nodes are down before
current one), it is correct to load from local.
dc297e9 to
ddc6d9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #11021
Without this fix, ram_copies is 'safe loaded' locally when remote nodes have not been connected (yet). This makes the table accessible by application becasue 'where_to_read' is set to local node().
Also when remote node is connected afterwards, ram_copies table will not load the 'better' copy, this makes the data inconsistent within the cluster.
This commit fix that during mnesia start, ram_copy table should NOT do local safe load when there is a better copy from the remote. the where_to_read will stay in 'nowhere' and table access won't be served.
After remote node is connected, local node will do
net_load_tablefrom the remote.Resue
adopt_orphansfunction to resolve the conflicts when there is a deadlock of deciding the better copy, that is the same behaviour for disc_copies tables.note1: BetterCopies0 = mnesia_lib:remote_copy_holders(Cs) -- Downs
note2: disc copy table has no such issue.
note3: if there is no better copy (when other nodes are down before current one), it is correct to load from local.