<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:54:57 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-1575] Remove unnecessary synchronization in NettyStream</title>
                <link>https://jira.mongodb.org/browse/JAVA-1575</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;NettyStream has been observed getting into deadlocks when multiple items call &lt;tt&gt;stream.writeAsync&lt;/tt&gt; - notably &lt;tt&gt;ParallelCollectionScanOperationSpecification.should visit all documents asynchronously&lt;/tt&gt; would consistently lock.&lt;/p&gt;

&lt;p&gt;I removed the synchronization requirements round it the readAsync and writeAsync methods and but the new approach code needs reviewing.&lt;/p&gt;</description>
                <environment></environment>
        <key id="171706">JAVA-1575</key>
            <summary>Remove unnecessary synchronization in NettyStream</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="ross@mongodb.com">Ross Lawley</reporter>
                        <labels>
                    </labels>
                <created>Fri, 28 Nov 2014 20:02:50 +0000</created>
                <updated>Tue, 31 Mar 2015 20:09:29 +0000</updated>
                            <resolved>Mon, 8 Dec 2014 14:49:31 +0000</resolved>
                                                    <fixVersion>3.0.0</fixVersion>
                                    <component>Connection Management</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="869336" author="jeff.yemin" created="Tue, 31 Mar 2015 20:09:29 +0000"  >&lt;p&gt;Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released.&lt;/p&gt;</comment>
                            <comment id="818036" author="xgen-internal-githook" created="Fri, 30 Jan 2015 18:45:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;jyemin&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;}
&lt;p&gt;Message: Added open/openAsync methods to Stream interface to make implementation simpler. Before this, implementations&lt;br/&gt;
either had to open in the constructor or in write/writeAsync.&lt;br/&gt;
Also removed unnecessary synchronization in NettyStream that made it prone to deadlock.  The Stream client&lt;br/&gt;
is responsible for ensuring that there is at most one call to read/readAsync and one to write/writeAsync going on&lt;br/&gt;
concurrently, so Stream implementations do not have to do their own synchronization.&lt;/p&gt;

&lt;p&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1584&quot; title=&quot;Add Stream.open/openAsync methods&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1584&quot;&gt;&lt;del&gt;JAVA-1584&lt;/del&gt;&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1575&quot; title=&quot;Remove unnecessary synchronization in NettyStream&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1575&quot;&gt;&lt;del&gt;JAVA-1575&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/b9ff37e15e86a7aba11812a2183283fb165c57ab&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/b9ff37e15e86a7aba11812a2183283fb165c57ab&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="782676" author="jeff.yemin" created="Wed, 10 Dec 2014 14:57:55 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;jyemin&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;}
&lt;p&gt;Message: NettyStream does need some synchronization between threads calling readAsync and Netty threads calling methods in InboundBufferHandler class&lt;/p&gt;

&lt;p&gt;Branch: 3.0.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/10283244d8cee7e173df6d98621a14e085a66c03&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/10283244d8cee7e173df6d98621a14e085a66c03&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="778474" author="xgen-internal-githook" created="Thu, 4 Dec 2014 16:26:09 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;jyemin&apos;, u&apos;name&apos;: u&apos;Jeff Yemin&apos;, u&apos;email&apos;: u&apos;jeff.yemin@10gen.com&apos;}
&lt;p&gt;Message: Added open/openAsync methods to Stream interface to make implementation simpler. Before this, implementations&lt;br/&gt;
either had to open in the constructor or in write/writeAsync.&lt;br/&gt;
Also removed unnecessary synchronization in NettyStream that made it prone to deadlock.  The Stream client&lt;br/&gt;
is responsible for ensuring that there is at most one call to read/readAsync and one to write/writeAsync going on&lt;br/&gt;
concurrently, so Stream implementations do not have to do their own synchronization.&lt;/p&gt;

&lt;p&gt; &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1584&quot; title=&quot;Add Stream.open/openAsync methods&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1584&quot;&gt;&lt;del&gt;JAVA-1584&lt;/del&gt;&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-1575&quot; title=&quot;Remove unnecessary synchronization in NettyStream&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-1575&quot;&gt;&lt;del&gt;JAVA-1575&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: 3.0.x&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/b9ff37e15e86a7aba11812a2183283fb165c57ab&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/b9ff37e15e86a7aba11812a2183283fb165c57ab&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="778093" author="jeff.yemin" created="Thu, 4 Dec 2014 03:39:25 +0000"  >&lt;p&gt;I see the deadlock, and it&apos;s in our own code, not Netty.&lt;/p&gt;

&lt;p&gt;The problem is that you have one NIO thread with this stack&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;NettyStream@2.writeAsync&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// chain of callback&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;NettyStream@1.readAsync&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;and another NIO thread with this stack:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;NettyStream@1.writeAsync&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// chain of callback&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;NettyStream@2.readAsync&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;If both readAsync and writeAsync are synchronized, that spells deadlock. &lt;/p&gt;

&lt;p&gt;So these methods should not be synchronized at all, and it&apos;s up to the caller, InternalStreamConnection, to ensure proper synchronization, which I believe it already does.&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|hrf3s7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>690</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="351">Java Sprint 12</customfieldvalue>

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