<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:06 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-365] Poor concurrency handling in DBApiLayer.doGetCollection</title>
                <link>https://jira.mongodb.org/browse/JAVA-365</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;It seems that the synchronized block has been put in place in order to guarantee that a particular DBCollection is uniquely created and returned to the caller.&lt;/p&gt;

&lt;p&gt;The synchronization is needed because the operation as a whole must be atomic. However, it adds an extra lock/unlock beyond that provided by synchronizedMap on _collections, and this can significantly negatively affect performance in highly concurrent situations which call this essential function.&lt;/p&gt;

&lt;p&gt;One solution could be to not use synchronizedMap, and instead handle locking ourselves by always wrapping uses of _collections with synchronized blocks. This would reduce the number of blocking lock acquisitions.&lt;/p&gt;

&lt;p&gt;However, a &lt;b&gt;much&lt;/b&gt; better solution is for _collection to be ConcurrentHashMap. We would then never have to use synchronized blocks, and in this case could check the result of a putIfAbsent call:&lt;/p&gt;

&lt;p&gt;MyCollection existing = _collections.putIfAbsent(name , c);&lt;br/&gt;
if (existing != null) c = existing;&lt;/p&gt;

&lt;p&gt;This code would guarantee uniqueness of the collection, and offer much better throughput in high concurrency.&lt;/p&gt;</description>
                <environment></environment>
        <key id="17807">JAVA-365</key>
            <summary>Poor concurrency handling in DBApiLayer.doGetCollection</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="antoine">Antoine Girbal</assignee>
                                    <reporter username="tal.liron">Tal Liron</reporter>
                        <labels>
                    </labels>
                <created>Thu, 2 Jun 2011 16:05:55 +0000</created>
                <updated>Tue, 25 Jun 2013 16:54:26 +0000</updated>
                            <resolved>Fri, 12 Aug 2011 00:53:27 +0000</resolved>
                                    <version>2.6.1</version>
                                                    <component>Performance</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="48311" author="auto" created="Fri, 12 Aug 2011 00:51:39 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;agirbal&apos;, u&apos;name&apos;: u&apos;agirbal&apos;, u&apos;email&apos;: u&apos;antoine@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-365&quot; title=&quot;Poor concurrency handling in DBApiLayer.doGetCollection&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-365&quot;&gt;&lt;del&gt;JAVA-365&lt;/del&gt;&lt;/a&gt;: Poor concurrency handling in DBApiLayer.doGetCollection&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/31980422622c49e40f6213c634c3267b07f7af80&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/31980422622c49e40f6213c634c3267b07f7af80&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="48310" author="antoine" created="Fri, 12 Aug 2011 00:51:08 +0000"  >&lt;p&gt;the concurrency performance impact is minimal here, regular java sync is very fast now and rarely a bottleneck.&lt;br/&gt;
But for sake of code cleanliness I&apos;ll switch to concurrentMap&lt;/p&gt;</comment>
                            <comment id="47821" author="tal.liron" created="Wed, 10 Aug 2011 18:35:55 +0000"  >&lt;p&gt;Two months, and still no comment from the dev team?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhc13:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14749</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>