[ 
https://issues.apache.org/jira/browse/GEODE-6287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16745349#comment-16745349
 ] 

Barry Oglesby commented on GEODE-6287:
--------------------------------------

When a client connects to a distributed system and registers interest, the 
Region's FilterProfile's clientMap (an IDMap) registers the 
ClientProxyMembershipID in both the realIDs and wireIDs like:
{noformat}
realIDs=\{identity(192.168.2.12(client-register:52879:loner):63013:2327c553:client-register,connection=2=1};
wireIDs=\{1=identity(192.168.2.12(client-register:52879:loner):63013:2327c553:client-register,connection=2}
{noformat}
When the client leaves normally, the UnregisterInterest command is invoked 
which removes the interest and the region. Part of that behavior is to remove 
the regionName from the set of regions.
{noformat}
this.regions.remove(regionName)
{noformat}
Then ClientInterestList.clearClientInterestList is then invoked which is 
supposed to clear the FilterProfile for each region, but the regions are 
already cleared by the UnregisterInterest command, so this method doesn't do 
anything.

Then, LocalRegion.cleanupForClient is invoked which invokes 
FilterProfile.cleanupForClient. This method currently only closes CQs (which 
also cleans up the cqMap which is also an IDMap like the clientMap).

At the end of this, the clientMap's realIDs and wireIDs still contain the 
ClientProxyMembershipID.

The cleanupForClient method could be changed to also clean up the clientMap.

Note: If the client is killed abnormally, the UnregisterInterest command is not 
invoked, so the interest and the region is not cleaned up normally. When 
ClientInterestList.clearClientInterestList is called, the set of regions still 
contains the region, and the IDMap is cleaned up properly.

====

Here is a stack trace showing the ClientProxyMembershipID being registered:
{noformat}
java.lang.Exception: Stack trace
 at java.lang.Thread.dumpStack(Thread.java:1333)
 at 
org.apache.geode.internal.cache.FilterProfile$IDMap.getWireID(FilterProfile.java:2032)
 at 
org.apache.geode.internal.cache.FilterProfile.getClientIDForMaps(FilterProfile.java:1615)
 at 
org.apache.geode.internal.cache.FilterProfile.registerClientInterest(FilterProfile.java:261)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy$ClientInterestList.registerClientInterest(CacheClientProxy.java:2052)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy.registerClientInterest(CacheClientProxy.java:1270)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.registerClientInterest(CacheClientNotifier.java:1194)
 at 
org.apache.geode.internal.cache.tier.sockets.command.RegisterInterest61.cmdExecute(RegisterInterest61.java:200)
 at 
org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:178)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:844)
 at 
org.apache.geode.internal.cache.tier.sockets.OriginalServerConnection.doOneMessage(OriginalServerConnection.java:74)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1218)
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at 
org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:613)
 at 
org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121)
 at java.lang.Thread.run(Thread.java:745)
{noformat}
Here is a stack trace showing the UnregisterInterest command unregistering the 
client interest:
{noformat}
java.lang.Exception: Stack trace
 at java.lang.Thread.dumpStack(Thread.java:1333)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy$ClientInterestList.unregisterClientInterest(CacheClientProxy.java:2085)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy.unregisterClientInterest(CacheClientProxy.java:1330)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.unregisterClientInterest(CacheClientNotifier.java:1245)
 at 
org.apache.geode.internal.cache.tier.sockets.command.UnregisterInterest.cmdExecute(UnregisterInterest.java:144)
 at 
org.apache.geode.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:178)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.doNormalMessage(ServerConnection.java:844)
 at 
org.apache.geode.internal.cache.tier.sockets.OriginalServerConnection.doOneMessage(OriginalServerConnection.java:75)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1215)
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at 
org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:613)
 at 
org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121)
 at java.lang.Thread.run(Thread.java:745)
{noformat}
Here is a stack trace showing clearClientInterestList being invoked:
{noformat}
java.lang.Exception: Stack trace
 at java.lang.Thread.dumpStack(Thread.java:1333)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy$ClientInterestList.clearClientInterestList(CacheClientProxy.java:2156)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy.terminateDispatching(CacheClientProxy.java:891)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientProxy.close(CacheClientProxy.java:793)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.closeDeadProxies(CacheClientNotifier.java:1713)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.unregisterClient(CacheClientNotifier.java:724)
 at 
org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor.unregisterClient(ClientHealthMonitor.java:270)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.handleTermination(ServerConnection.java:958)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.handleTermination(ServerConnection.java:878)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1226)
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at 
org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:613)
 at 
org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121)
 at java.lang.Thread.run(Thread.java:745)
{noformat}
Here is a stack trace showing cleanupForClient being invoked:
{noformat}
java.lang.Exception: Stack trace
 at java.lang.Thread.dumpStack(Thread.java:1333)
 at 
org.apache.geode.internal.cache.FilterProfile.cleanupForClient(FilterProfile.java:935)
 at 
org.apache.geode.internal.cache.LocalRegion.cleanupForClient(LocalRegion.java:10610)
 at 
org.apache.geode.internal.cache.GemFireCacheImpl.cleanupForClient(GemFireCacheImpl.java:3408)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.removeClientProxy(CacheClientNotifier.java:1630)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.closeDeadProxies(CacheClientNotifier.java:1731)
 at 
org.apache.geode.internal.cache.tier.sockets.CacheClientNotifier.unregisterClient(CacheClientNotifier.java:724)
 at 
org.apache.geode.internal.cache.tier.sockets.ClientHealthMonitor.unregisterClient(ClientHealthMonitor.java:270)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.handleTermination(ServerConnection.java:958)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.handleTermination(ServerConnection.java:878)
 at 
org.apache.geode.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1226)
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at 
org.apache.geode.internal.cache.tier.sockets.AcceptorImpl.lambda$initializeServerConnectionThreadPool$3(AcceptorImpl.java:613)
 at 
org.apache.geode.internal.logging.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:121)
 at java.lang.Thread.run(Thread.java:745)
{noformat}

> When a client connects, registers interest and disconnects normally, its 
> ClientProxyMembershipID is not cleaned up and a memory leak occurs
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GEODE-6287
>                 URL: https://issues.apache.org/jira/browse/GEODE-6287
>             Project: Geode
>          Issue Type: Bug
>          Components: client queues, client/server
>            Reporter: Barry Oglesby
>            Assignee: Barry Oglesby
>            Priority: Major
>
> When a client connects to a distributed system and registers interest, the 
> Region's FilterProfile's clientMap (an IDMap) registers the 
> ClientProxyMembershipID in both the realIDs and wireIDs like:
> {noformat}
> realIDs={identity(192.168.2.12(client-register:52879:loner):63013:2327c553:client-register,connection=2=1};
> wireIDs={1=identity(192.168.2.12(client-register:52879:loner):63013:2327c553:client-register,connection=2}
> {noformat}
> When the client leaves normally, the UnregisterInterest command is invoked 
> which removes the interest and the region. Part of that behavior is to remove 
> the regionName from the set of regions.
> {noformat}
> this.regions.remove(regionName)
> {noformat}
> Then ClientInterestList.clearClientInterestList is then invoked which is 
> supposed to clear the FilterProfile for each region, but the regions are 
> already cleared by the UnregisterInterest command, so this method doesn't do 
> anything.
> Then, LocalRegion.cleanupForClient is invoked which invokes 
> FilterProfile.cleanupForClient. This method currently only closes CQs (which 
> also cleans up the cqMap which is also an IDMap like the clientMap).
> At the end of this, the clientMap's realIDs and wireIDs still contain the 
> ClientProxyMembershipID.
> The cleanupForClient method could be changed to also clean up the clientMap.
> Note: If the client is killed abnormally, the UnregisterInterest command is 
> not invoked, so the interest and the region is not cleaned up normally. When 
> ClientInterestList.clearClientInterestList is called, the set of regions 
> still contains the region, and the IDMap is cleaned up properly.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to