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

HDDS-4673. NodeStateMap leaks internal representation of container sets #1782

Merged
merged 1 commit into from Jan 12, 2021

Conversation

elek
Copy link
Member

@elek elek commented Jan 12, 2021

JIRA: https://issues.apache.org/jira/browse/HDDS-4673

What changes were proposed in this pull request?

@jojochuang reported that some ConcurrentModificationException is visible even after #1174 (https://issues.apache.org/jira/browse/HDDS-3918)

The root cause of this issue is a leak of internal representation of sets in NodeStateMap.

NodeStateMap returns an unmodifiable copy of containers for one specific node:

Collections.unmodifiableSet(nodeToContainer.get(uuid))

With this approach the users of the nodeStateMap.getContainers method couldn't modify the set anymore. But nodeStateMap can modify the original set which is referenced (instead of copy) by the unmodifiableSet. Even if it's unmodifiable it throws an exception during the iteration if the original set is modified in the background.

How was this patch tested?

There is a new unit test method which reproduce the specific race condition with the help of CountDownLatch-es

@elek elek changed the title NodeStateMap leaks internal representation of container sets HDDS-4673. NodeStateMap leaks internal representation of container sets Jan 12, 2021
@nandakumar131 nandakumar131 merged commit a8f4d52 into apache:master Jan 12, 2021
@nandakumar131
Copy link
Contributor

Thanks @elek for taking care of this.

jojochuang pushed a commit to jojochuang/ozone that referenced this pull request Mar 11, 2021
…container sets. (apache#1782)

(cherry picked from commit a8f4d52)
Change-Id: I216148aa1f57eb8b701f8f28f2b7ed6022c0454b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants