Description
MetricStatisticsProvider makes getStats as synchronized. This can cause contention in concurrent scenarios specially when lots of Sessions are created as the stats instance are looked at time of session creation
"qtp618865225-3444" #3444 prio=5 os_prio=0 tid=0x00007f7fe5083800 nid=0x7629 waiting for monitor entry [0x00007f7fdb9f7000] java.lang.Thread.State: BLOCKED (on object monitor) at org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider.getStats(MetricStatisticsProvider.java:129) - waiting to lock <0x00000003c1bfb1d0> (a org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider) at org.apache.jackrabbit.oak.plugins.metric.MetricStatisticsProvider.getCounterStats(MetricStatisticsProvider.java:107) at org.apache.jackrabbit.oak.stats.StatisticManager.getStatsCounter(StatisticManager.java:99) at org.apache.jackrabbit.oak.jcr.session.SessionStats.<init>(SessionStats.java:83) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.<init>(SessionDelegate.java:150) at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl$1.<init>(RepositoryImpl.java:301) at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.createSessionDelegate(RepositoryImpl.java:299) at org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl.login(RepositoryImpl.java:281) at com.adobe.granite.repository.impl.CRX3RepositoryImpl.login(CRX3RepositoryImpl.java:94)
Instead of current approach it should use ConcurrentHashMap and still ensure that duplicate metric instance did not get created