-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CLOUDSTACK-9564: Fix memory leaks in VmwareContextPool #1729
Conversation
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
dfabcc8
to
5490617
Compare
@blueorangutan help |
@rhtyd I understand these words: "help", "hello", "thanks", "package", "test" |
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-94 |
@blueorangutan test centos6 vmware-55u3 |
@rhtyd a Trillian-Jenkins test job (centos6 mgmt + vmware-55u3) has been kicked to run smoke tests |
5490617
to
ed964aa
Compare
Trillian test result (tid-181)
|
Trillian test result (tid-182)
|
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-95 |
@blueorangutan test centos7 vmware-55u3 |
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + vmware-55u3) has been kicked to run smoke tests |
ed964aa
to
3584a99
Compare
@blueorangutan package |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-97 |
3584a99
to
39a2f0b
Compare
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-98 |
Trillian test result (tid-189)
|
@blueorangutan test centos6 vmware-55u3 |
@rhtyd a Trillian-Jenkins test job (centos6 mgmt + vmware-55u3) has been kicked to run smoke tests |
Trillian test result (tid-188)
|
Trillian test result (tid-194)
|
Pinging for review -- @sateesh-chodapuneedi @koushik-das @sureshanaparti @karuturi @murali-reddy and other vmware contributors/maintainers |
Trillian test result (tid-205)
|
Trillian test result (tid-206)
|
LGTM from code change. |
39a2f0b
to
25f58f1
Compare
Thanks @murali-reddy |
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
_pool.put(context.getPoolKey(), l); | ||
Queue<VmwareContext> ctxList = _pool.get(context.getPoolKey()); | ||
if (ctxList == null) { | ||
ctxList = EvictingQueue.create(_maxIdleQueueLength); |
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.
Should we get a synchronised evictingqueue ?
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.
Yes. There may be a case, where two threads may be trying to create evicting queue for a poolKey.
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.
Since all access is in synchronized blocks this is not required. But a synchronised evictingqueue could have let you avoid some of synchronised blocks.
Again, this is not required as it is.
oldestContext.close(); | ||
} catch (Throwable t) { | ||
s_logger.error("Unexpected exception caught while trying to purge oldest VmwareContext", t); | ||
} |
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.
Although we are using a bounded queue now and that will prevent memory leaks, do we know why it should be throwing old elements -or- why the contexts are not cleaned up programmatically instead of forcefully restricting the size ?
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.
In the registerContext
method we check if the queue is full; in case it is full, we remove the oldest element and close it properly. I'll ping you on the lines where it happens.
25f58f1
to
e6dab39
Compare
if (oldestContext != null) { | ||
try { | ||
oldestContext.close(); | ||
} catch (Throwable t) { |
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.
@abhinandanprateek ^^ here we close oldest context, before adding a new one. The queue provided the FIFO semantics to purge old contexts and keep new ones around, which is why I switched from previously used arraylist.
Packaging result: ✔centos6 ✔centos7 ✔debian. JID-122 |
@blueorangutan test centos7 vmware-55u3 |
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + vmware-55u3) has been kicked to run smoke tests |
@rhtyd LGTM on code review. |
e6dab39
to
9dfedca
Compare
In a recent management server crash, it was found that the largest contributor to memory leak was in VmwareContextPool where a registry is held (arraylist) that grows indefinitely. The list itself is not used anywhere or consumed. There exists a hashmap (pool) that returns a list of contexts for existing poolkey (address/username) that is used instead. This fixes the issue by removing the arraylist registry, and limiting the length of the context list for a given poolkey. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
9dfedca
to
90a3d97
Compare
Thanks @murali-reddy @abhinandanprateek I'll proceed with merging this. We can explore considering using apache-commons pool in future. |
CLOUDSTACK-9564: Fix memory leaks in VmwareContextPoolIn a recent management server crash, it was found that the largest contributor to memory leak was in VmwareContextPool where a registry is held (arraylist) that grows indefinitely. The list itself is not used anywhere or consumed. There exists a hashmap (pool) that returns a list of contexts for existing poolkey (address/username) that is used instead. This fixes the issue by removing the arraylist registry, and limiting the length of the context list for a given poolkey. @blueorangutan package * pr/1729: CLOUDSTACK-9564: Fix memory leaks in VmwareContextPool Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
Packaging result: ✖centos6 ✔centos7 ✔debian. JID-326 |
In a recent management server crash, it was found that the largest contributor
to memory leak was in VmwareContextPool where a registry is held (arraylist)
that grows indefinitely. The list itself is not used anywhere or consumed. There
exists a hashmap (pool) that returns a list of contexts for existing poolkey
(address/username) that is used instead.
This fixes the issue by removing the arraylist registry, and limiting the
length of the context list for a given poolkey.
@blueorangutan package