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

[#3388]Remove the deleted roles and permissions info during reloading role info #3419

Closed
wants to merge 7 commits into from

Conversation

yanjunnf
Copy link
Contributor

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

#3388

Brief changelog

We should remove these already deleted roles, permissions during reloading nacos role info.

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@CLAassistant
Copy link

CLAassistant commented Jul 23, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ yanjunnf
❌ junyan29


junyan29 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@yanjunnf
Copy link
Contributor Author

yanjunnf commented Jul 23, 2020

Why do not clear roleSet, roleInfoMap and permissionInfoMap before putAll/addAll?
The clear method cannot guarantee the whole logic as a atomic operation.
For example, roleSet.clear() finished to execute, but now this thread is suspended, then antoher thread try to get all roles, it will get a empty list since the roleSet object was cleared.

@yanjunnf
Copy link
Contributor Author

license/cla Pending — Contributor License Agreement is not signed yet.
I really signed several times, but this message still shows.

@KomachiSion
Copy link
Collaborator

license/cla Pending — Contributor License Agreement is not signed yet.
I really signed several times, but this message still shows.

The reason is your git username and email is not your github id.
So the git commit log author is junyan29, but you signed CLA is for yanjunnf.

It's different.

Solution is to set the git username and email to your github id.

Search in search engine, you can get many answer.

@KomachiSion
Copy link
Collaborator

KomachiSion commented Jul 23, 2020

And for the PR content, I describe in PR before you submit.

Why don't clear all map and then putAll again, but to remove one by one. I think the new put is all data for users and permissions.

@chuntaojun Is my understanding correct?

@KomachiSion KomachiSion added the kind/bug Category issues or prs related to bug. label Jul 23, 2020
@KomachiSion KomachiSion added this to the 1.3.2 milestone Jul 23, 2020
@yanjunnf
Copy link
Contributor Author

And for the PR content, I describe in PR before you submit.

Why don't clear all map and then putAll again, but to remove one by one. I think the new put is all data for users and permissions.

@chuntaojun Is my understanding correct?

The clear method cannot guarantee the whole logic as a atomic operation.
For example, roleSet.clear() finished to execute, but at this time, this thread is suspended, then antoher thread try to get all roles, it will get a empty list since the roleSet object was cleared, that may cuase the empty role/permission list showes on UI part.
Remove one by one, that can reduce impaction.

@chuntaojun
Copy link
Collaborator

I think this is too complicated, but logically, there are only reads to the map, not writes. You can take advantage of the volatile property, replace the application directly, and then destroy the old Map

@KomachiSion
Copy link
Collaborator

I agree with @chuntaojun, if you think about the thread safe, you can use a tmp map/set to save new data from persistence, and directly replace them.

@KomachiSion
Copy link
Collaborator

Once more about the CLA, I check your commit log, it contain many merge branch, I recommend that you use rebase to squash them. And if there are still junyan29's commit. I think you should revert them and re commit with yanjunnf

@yanjunnf
Copy link
Contributor Author

Thanks for your reply.
Yes, I agree with you in priciple about keeping the code clean and simple.
I though about to use tmp object and replace, If that we have to remove “final “ modifier for class members roleSet, roleInfoMap and permissionInfoMap.

@KomachiSion
Copy link
Collaborator

KomachiSion commented Jul 24, 2020

If these map/set need to be reset, remove final will be ok. @chuntaojun What's your idea?

@chuntaojun
Copy link
Collaborator

chuntaojun commented Jul 24, 2020 via email

@yanjunnf yanjunnf closed this Jul 25, 2020
@yanjunnf yanjunnf deleted the issue-#3388 branch July 25, 2020 03:57
@yanjunnf
Copy link
Contributor Author

Closed it and recreate a new PR([#3388]Reset nacos roles, permissions during reloading role info from database) to fix issue 3388 since CLA problem.

@KomachiSion KomachiSion removed this from the 1.3.2 milestone Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants