<!-- 
RSS generated by JIRA (8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d) at Wed Feb 07 19:53:31 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>OpenDaylight JIRA</title>
    <link>https://jira.opendaylight.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.20.10</version>
        <build-number>820010</build-number>
        <build-date>22-06-2022</build-date>
    </build-info>


<item>
            <title>[CONTROLLER-638] Concurrency issue in RpcProviderRegistryImpl.java</title>
                <link>https://jira.opendaylight.org/browse/CONTROLLER-638</link>
                <project id="10113" key="CONTROLLER">controller</project>
                    <description>&lt;p&gt;With gerrit &lt;a href=&quot;https://git.opendaylight.org/gerrit/#/c/9093/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/#/c/9093/&lt;/a&gt; we unwittingly fixed a concurrency issue with the publicProxies variable. However, the same concurrency issues exist with rpcRouters as well.&lt;/p&gt;

&lt;p&gt;Basically, we synchronize when we write the the map, but we do not synchronize when we read from it. This can lead to inconsistent behavior in this class.&lt;/p&gt;</description>
                <environment>&lt;p&gt;Operating System: Mac OS&lt;br/&gt;
Platform: PC&lt;/p&gt;</environment>
        <key id="25192">CONTROLLER-638</key>
            <summary>Concurrency issue in RpcProviderRegistryImpl.java</summary>
                <type id="10104" iconUrl="https://jira.opendaylight.org/secure/viewavatar?size=xsmall&amp;avatarId=10303&amp;avatarType=issuetype">Bug</type>
                                                <status id="5" iconUrl="https://jira.opendaylight.org/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="tony.tkacik@gmail.com">Tony Tkacik</assignee>
                                    <reporter username="devin.avery@brocade.com">Devin Avery</reporter>
                        <labels>
                    </labels>
                <created>Fri, 18 Jul 2014 11:30:21 +0000</created>
                <updated>Wed, 23 Jul 2014 18:14:53 +0000</updated>
                            <resolved>Wed, 23 Jul 2014 18:14:53 +0000</resolved>
                                    <version>Helium</version>
                                                    <component>mdsal</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="48731" author="tony.tkacik@gmail.com" created="Mon, 21 Jul 2014 07:24:11 +0000"  >&lt;p&gt;Devin, I believe there is not an issue,&lt;/p&gt;

&lt;p&gt;there is &lt;br/&gt;
1. read, lock, read, write mechanism,&lt;br/&gt;
so if unsynchronized read misses, we synchronize and read again&lt;br/&gt;
if it miss, create value.&lt;/p&gt;</comment>
                            <comment id="48732" author="devin.avery@brocade.com" created="Mon, 21 Jul 2014 19:42:05 +0000"  >&lt;p&gt;Hi Tony -&lt;/p&gt;

&lt;p&gt;This is actually NOT thread safe for a few reason.&lt;/p&gt;

&lt;p&gt;1) addRpcImplementation, registerRouterInstantiationListener,  method is not synchronized. So even if another thread created the RpcRouter it is not guaranteed to be available in that method.&lt;/p&gt;

&lt;p&gt;2) The &quot;read, lock, read, write mechanism&quot; is called double-check locking and that is NOT thread safe. See this for the full details: &lt;a href=&quot;http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html&lt;/a&gt;. So for that reason the getRpcService method is not thread safe.&lt;/p&gt;

&lt;p&gt;I changed this back to a critical bug because concurrency issues are really hard to track down, fix and test. So if we find one we should fix it.&lt;/p&gt;</comment>
                            <comment id="48733" author="tpantelis" created="Tue, 22 Jul 2014 00:55:40 +0000"  >&lt;p&gt;Devin is correct. This is a form of DCL which is not thread-safe. There must be synchronization between the writes and the reads in order to guarantee reading threads see the writes.&lt;/p&gt;

&lt;p&gt;Worse, you could end up with the infamous HashMap endless loop (see &lt;a href=&quot;http://confusion.tweakblogs.net/blog/2019/nasty-java-hashmap-race-condition.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://confusion.tweakblogs.net/blog/2019/nasty-java-hashmap-race-condition.html&lt;/a&gt;) if an unsynchronized get or put on one thread happens simultaneous with a put on another thread.&lt;/p&gt;</comment>
                            <comment id="48734" author="tpantelis" created="Tue, 22 Jul 2014 01:29:19 +0000"  >&lt;p&gt;Actually the DCL mechanism in this case is OK from a visibility standpoint - if the unsync&apos;ed get returns null, the thread will hit the synchronized block which will result in previous writes by other threads done in that sync block to be visible. However there&apos;s likely compiler re-ordering optimizations that could cause issues here.&lt;/p&gt;

&lt;p&gt;Regardless, the potential for infinite loop in the HashMap is a definite issue. Basically you must synchronize every HashMap operation (get, put, remove etc) or bad things can happen.&lt;/p&gt;</comment>
                            <comment id="48735" author="tony.tkacik@gmail.com" created="Tue, 22 Jul 2014 08:42:02 +0000"  >&lt;p&gt;&lt;a href=&quot;https://git.opendaylight.org/gerrit/#/c/9221/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/#/c/9221/&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_11400" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10208" key="com.atlassian.jira.plugin.system.customfieldtypes:textfield">
                        <customfieldname>External issue ID</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1390</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10201" key="com.atlassian.jira.plugin.system.customfieldtypes:url">
                        <customfieldname>External issue URL</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[https://bugs.opendaylight.org/show_bug.cgi?id=1390]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10204" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>ODL SR Target Milestone</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10370"><![CDATA[Helium]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10000" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i02lmv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>