You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "zyj5340 (via GitHub)" <gi...@apache.org> on 2026/01/14 01:53:46 UTC

[I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

zyj5340 opened a new issue, #25138:
URL: https://github.com/apache/pulsar/issues/25138

   ### Search before reporting
   
   - [x] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
   
   
   ### Read release policy
   
   - [x] I understand that [unsupported versions](https://pulsar.apache.org/contribute/release-policy/#supported-versions) don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
   
   
   ### User environment
   
   Pulsar Proxy version: 2.11.0
   Java version: java17
   
   ### Issue Description
   
   When process a PRODUCER request  in ParserProxyHandler, it will add an element in ParserProxyHandler.producerHashMap, but when the producer closed it still maintain in this map, it cause memory leak in pulsar proxy. This type of leakage also exists when processing SUBSCRIBE request.
   
   ### Error messages
   
   ```text
   
   ```
   
   ### Reproducing the issue
   
   Use different pulsar client to create Producer or Consumer through Pulsar Proxy.
   
   ### Additional information
   
   ParserProxyHandler should remove the element related to the producer or consumer once they are closed or channelInactive.
   
   ### Are you willing to submit a PR?
   
   - [ ] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3749322785

   > [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel
   
   The title of the issue doesn't make sense since the memory leak is only within a single channel since the ParserProxyHandler instances aren't shared.
   
   https://github.com/apache/pulsar/blob/1b74fe07bd24e079434769de2c52222761d88ca1/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/DirectProxyHandler.java#L418-L453


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3749515913

   > Yes, usually used in dev environment, it is usedful to trace the client behavior. Although it is not meant for production usage, but it may still sometimes cause problem in pulsar-proxy so that we need to spend time to figure out the reason why pulsar-proxy doesn't work normally and restart the proxy. It looks like they are defined as "static final".
    
   @zyj5340 Oh yes, you are right that this leaks across the complete Proxy instance due to the `static final` usage.
   The code should be refactored to get rid of the `static final` usage. Most likely the 2 separate instances need to share the common "context" with the shared producer and consumer maps. One way to achieve that would be to create a new nested class "Context" in ParserProxyHandler which contains the producerHashMap and consumerHashMap. The constructor of ParserProxyHandler would require this instance.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3748244652

   Yes, this bug seems to exist. However, I wouldn't recommend using ParserProxyHandler in production due to it's high overhead. What is your requirement for using it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "zyj5340 (via GitHub)" <gi...@apache.org>.
zyj5340 commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3749446566

   > > ParserProxyHandler should remove the element related to the producer or consumer once they are closed or channelInactive.
   > 
   > The instance is for the channel, so this problem applies only when a single client closes producers or consumers. Since ParserProxyHandler isn't meant for production usage, I wouldn't consider this a severe problem.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari closed issue #25138: [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel
URL: https://github.com/apache/pulsar/issues/25138


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3749612834

   @zyj5340 I created a fix in #25142, please review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "zyj5340 (via GitHub)" <gi...@apache.org>.
zyj5340 closed issue #25138: [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel
URL: https://github.com/apache/pulsar/issues/25138


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "zyj5340 (via GitHub)" <gi...@apache.org>.
zyj5340 commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3749371677

   It looks like they are defined as "static final".
   https://github.com/apache/pulsar/blob/1b74fe07bd24e079434769de2c52222761d88ca1/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ParserProxyHandler.java
   `public class ParserProxyHandler extends ChannelInboundHandlerAdapter {
   
   
       //inbound
       protected static final String FRONTEND_CONN = "frontendconn";
       //outbound
       protected static final String BACKEND_CONN = "backendconn";
   
       private final String connType;
   
       private final int maxMessageSize;
       private final ChannelId peerChannelId;
       private final ProxyService service;
   
   
       /**
        * producerid + channelid as key.
        */
       private static final Map<String, String> producerHashMap = new ConcurrentHashMap<>();
   
       /**
        * consumerid + channelid as key.
        */
       private static final Map<String, String> consumerHashMap = new ConcurrentHashMap<>();`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] Memory leak in ParserProxy when process a PRODUCER or SUBSCRIBE request in different channel [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on issue #25138:
URL: https://github.com/apache/pulsar/issues/25138#issuecomment-3749315983

   > ParserProxyHandler should remove the element related to the producer or consumer once they are closed or channelInactive.
   
   The instance is for the channel, so this problem applies only when a single client closes producers or consumers. Since ParserProxyHandler isn't meant for production usage, I wouldn't consider this a severe problem.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org