Bug 64628 - tomcat6/7/8/9 processorCache is no remove from the processors of RequestGroupInfo in concurrent release
Summary: tomcat6/7/8/9 processorCache is no remove from the processors of RequestGroup...
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 9.0.5
Hardware: All All
: P2 critical (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-27 04:56 UTC by Gavin.peng
Modified: 2020-08-11 13:12 UTC (History)
1 user (show)



Attachments
too many processor in processors of RequestGroupInfo (164.82 KB, image/png)
2020-07-27 04:56 UTC, Gavin.peng
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin.peng 2020-07-27 04:56:46 UTC
Created attachment 37374 [details]
too many processor in processors of RequestGroupInfo

httpnio processor release exist processor no unregister from jmx bean at concurrent invoke push method of RecycledProcessors

@SuppressWarnings("sync-override") // Size may exceed cache size a bit
 @Override
 public boolean push(Processor processor) {
            int cacheSize = handler.getProtocol().getProcessorCache();
            boolean offer = cacheSize == -1 ? true : size.get() < cacheSize;
            //avoid over growing our cache or add after we have stopped
            boolean result = false;
            if (offer) {
                result = super.push(processor);
                if (result) {
                    size.incrementAndGet();
                }
            }
            if (!result) handler.unregister(processor);
            return result;
 }



cacheSize default is 200,if current size is 199 is lower 200 and two thread 
push processor at the same time ,all offer is true,so result also is true.
so processor cache is more than 200 ,so no do unregister with processor,

so the processor don't remove from the processors of RequestGroupInfo

and running time too long,the processor cache is too many,because new create processor is do register to jmx and add to the processors of RequestGroupInfo

so the sync-override is need add
Comment 1 Gavin.peng 2020-07-31 07:13:22 UTC
now we use the processorCache params resolve the problem,by set processorCache=0
but can't use cache,create byte[] for every request

please help me thanks
Comment 2 Gavin.peng 2020-08-10 03:42:28 UTC
any body can help please。we has many tomcat has gc problem online
Comment 3 Mark Thomas 2020-08-10 14:26:49 UTC
The root cause analysis is not correct.

While the size of the cache may exceed the configured size slightly (as per the comment) it won't exceed it excessively as shown in the attachment.

9.0.5 is 2.5 years old and there have been many fixes since then including at least one that addresses an issue that has the same symptoms as presented here.

If the issue is still observable with the latest 9.0.x release then feel free to re-open this issue, provide the *minimal* steps to recreate it from a clean install and someone will take a look.
Comment 4 Gavin.peng 2020-08-11 13:12:07 UTC
Thanks Mark Thomas 's help ,the cache size exceed shown in the attachment is tomcat6,the default cache size is -1 in tomcat6,so has many request processor cached 

the tomcat7/8/9 the default cache is is 200,may be the size of the cache may exceed the configured size slightly (as per the comment),but if concurrent request is too many at a moment,the cache is also exceed the configured size

the code is flow of tomcat9.0.37:


@SuppressWarnings("sync-override") // Size may exceed cache size a bit
 @Override
 public boolean push(Processor processor) {
            int cacheSize = handler.getProtocol().getProcessorCache();
            boolean offer = cacheSize == -1 ? true : size.get() < cacheSize;
            //avoid over growing our cache or add after we have stopped
            boolean result = false;
            if (offer) {
                result = super.push(processor);
                if (result) {
                    size.incrementAndGet();
                }
            }
            if (!result) handler.unregister(processor);
            return result;
 }

may be override the method of push at will?,we upgrade tomcat to tomcat9

thanks