[
https://issues.apache.org/jira/browse/OAK-4483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15339174#comment-15339174
]
Chetan Mehrotra edited comment on OAK-4483 at 6/22/16 11:18 AM:
----------------------------------------------------------------
Fixed - Reduced the synchronized scope with double check pattern. First check
would be done for stats with given name without lock. If not found stat would
be created within a lock. Per current usage the stat names are finite (i.e. not
based on runtime values) so map should get initialized in early stages and post
that sync block would not be accessed
* trunk - 1749275
* 1.4 - 1749654
was (Author: chetanm):
Fixed - Reduced the synchronized scope with double check pattern. First check
would be done for stats with given name without lock. If not found stat would
be created within a lock. Per current usage the stat names are finite (i.e. not
based on runtime values) so map should get initialized in early stages and post
that sync block would not be accessed
* trunk - 1749275
> Remove synchronized access requirement from MetricStatisticsProvider#getStats
> -----------------------------------------------------------------------------
>
> Key: OAK-4483
> URL: https://issues.apache.org/jira/browse/OAK-4483
> Project: Jackrabbit Oak
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.4
> Reporter: Chetan Mehrotra
> Assignee: Chetan Mehrotra
> Fix For: 1.6, 1.5.4, 1.4.4
>
>
> {{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
> {noformat}
> "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)
> {noformat}
> Instead of current approach it should use ConcurrentHashMap and still ensure
> that duplicate metric instance did not get created
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)