<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:00:10 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-3675] Change Streams: KillCursor command fails with &quot;error 143 (CursorInUse)&quot;</title>
                <link>https://jira.mongodb.org/browse/JAVA-3675</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;I&apos;ve built an application using the reactive mongoDB driver for Java. The user can subscribe to updates from a collection using WebSockets, so he can be notified if new data has been inserted. However, when calling dispose() of the change stream subscription, the DB returns the following error:&lt;/p&gt;

&lt;p&gt;command sent by the driver:&lt;/p&gt;

&lt;p&gt;&#160;&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;   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;Sending command &apos;{&quot;killCursors&quot;: &quot;data&quot;, &quot;cursors&quot;: [6306540676380622125], &quot;$db&quot;: &quot;mellolam&quot;, &quot;$clusterTime&quot;: {&quot;clusterTime&quot;: {&quot;$timestamp&quot;: {&quot;t&quot;: 1585725298, &quot;i&quot;: 1}}, &quot;signature&quot;: {&quot;hash&quot;: {&quot;$binary&quot;: {&quot;base64&quot;: &quot;FdRr7trb+s/1rPx4C/C/RBD6e14=&quot;, &quot;subType&quot;: &quot;00&quot;}}, &quot;keyId&quot;: 6745367209201106945}}, &quot;lsid&quot;: {&quot;id&quot;: {&quot;$binary&quot;: {&quot;base64&quot;: &quot;whXfu4cvRWiS6kfPc0V9xQ==&quot;, &quot;subType&quot;: &quot;04&quot;}}}}&apos; with request id 67 to database xxxx on connection [connectionId{localValue:11, serverValue:329204}] to server xxxx&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;&#160;&lt;/p&gt;

&lt;p&gt;response from the server:&lt;/p&gt;

&lt;p&gt;&#160;&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;   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;com.mongodb.MongoCommandException: Command failed with error 143 (CursorInUse): &apos;cursor id 6306540676380622125 is already in use&apos; on server xxxx. The full response is {&quot;operationTime&quot;: {&quot;$timestamp&quot;: {&quot;t&quot;: 1585725298, &quot;i&quot;: 1}}, &quot;ok&quot;: 0.0, &quot;errmsg&quot;: &quot;cursor id 6306540676380622125 is already in use&quot;, &quot;code&quot;: 143, &quot;codeName&quot;: &quot;CursorInUse&quot;, &quot;$clusterTime&quot;: {&quot;clusterTime&quot;: {&quot;$timestamp&quot;: {&quot;t&quot;: 1585725298, &quot;i&quot;: 1}}, &quot;signature&quot;: {&quot;hash&quot;: {&quot;$binary&quot;: &quot;FdRr7trb+s/1rPx4C/C/RBD6e14=&quot;, &quot;$type&quot;: &quot;00&quot;}, &quot;keyId&quot;: {&quot;$numberLong&quot;: &quot;6745367209201106945&quot;}}}}&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;&#160;&lt;/p&gt;

&lt;p&gt;(full stack trace in the attachment)&lt;/p&gt;

&lt;p&gt;I&apos;ve implemented the same functionality using the reactive template as well as calling .watch() on the collection &quot;manually&quot;.&#160;Both implementations produced the same error.&lt;/p&gt;

&lt;p&gt;The implementation is as follows: A method returns a Flux of Document (or a ChangeStreamPublisher of Document) from which I then subscribe to using subscribe(). The resulting Disposable is assigned to a variable, which is then used to call dispose() if the client cancels the change stream updates.&#160; After calling dispose() the driver sends the killCursors command and the above error is thrown.&#160;&lt;/p&gt;

&lt;p&gt;The error does not impact any of my logic and I haven&apos;t found a way to catch it either. The getMore operation is successfully killed on the server and no data insert events are pushed to the client any more.&#160;&lt;/p&gt;

&lt;p&gt;Googling for this error code returned nothing useful, so I don&apos;t have anything to go off.&lt;/p&gt;

&lt;p&gt;I would be glad if you guys could either tell me what I&apos;m doing wrong or if this is actually a bug in the driver (possible racing condition?).&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Cheers and keep up the great work!&lt;/p&gt;

&lt;p&gt;David&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1299566">JAVA-3675</key>
            <summary>Change Streams: KillCursor command fails with &quot;error 143 (CursorInUse)&quot;</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</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="13203">Gone away</resolution>
                                        <assignee username="john.stewart@mongodb.com">John Stewart</assignee>
                                    <reporter username="david@akenza.com">David Giger</reporter>
                        <labels>
                    </labels>
                <created>Wed, 1 Apr 2020 07:36:47 +0000</created>
                <updated>Fri, 27 Oct 2023 19:48:27 +0000</updated>
                            <resolved>Wed, 15 Apr 2020 21:00:23 +0000</resolved>
                                                                    <component>Change Streams</component>
                    <component>Reactive Streams</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="3027754" author="david@akenza.com" created="Mon, 6 Apr 2020 17:14:17 +0000"  >&lt;p&gt;Hi John,&lt;/p&gt;

&lt;p&gt;Yes I can give that a shot. I&apos;ll let you know of the outcomes.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
David&lt;/p&gt;</comment>
                            <comment id="3027690" author="john.stewart" created="Mon, 6 Apr 2020 16:48:00 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=david%40akenza.com&quot; class=&quot;user-hover&quot; rel=&quot;david@akenza.com&quot;&gt;david@akenza.com&lt;/a&gt; Reviewing the stack trace you provided, it aligns exactly with the stack trace for &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-3487&quot; title=&quot;com.mongodb.MongoException: state should be: open when closing an change stream&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-3487&quot;&gt;&lt;del&gt;JAVA-3487&lt;/del&gt;&lt;/a&gt;. The fix for &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-3487&quot; title=&quot;com.mongodb.MongoException: state should be: open when closing an change stream&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-3487&quot;&gt;&lt;del&gt;JAVA-3487&lt;/del&gt;&lt;/a&gt; was backported to version 3.12 of the Java driver. Would it be possible for you to upgrade your Java driver to see if this issue resolves?&lt;/p&gt;</comment>
                            <comment id="3027577" author="david@akenza.com" created="Mon, 6 Apr 2020 16:07:24 +0000"  >&lt;p&gt;Hi Jeffrey,&lt;/p&gt;

&lt;p&gt;Thanks for your reply!&lt;/p&gt;

&lt;p&gt;We use a replica set hosted on MongoDB Atlas with edition/version &quot;MongoDB 3.6.17 Enterprise&quot;.&lt;/p&gt;

&lt;p&gt;Regarding driver version, I&apos;m using the Maven artifact &quot;mongodb-driver-async&quot; with version &quot;3.11.2&quot;. It&apos;s a dependency of &quot;spring-boot-starter-data-mongodb-reactive&quot; which we&apos;re using to build our Services with.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
David&lt;br/&gt;
&#160;&lt;br/&gt;
&#160;&lt;/p&gt;</comment>
                            <comment id="3027273" author="jeff.yemin" created="Mon, 6 Apr 2020 14:24:51 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=david%40akenza.com&quot; class=&quot;user-hover&quot; rel=&quot;david@akenza.com&quot;&gt;david@akenza.com&lt;/a&gt;, please let us know what version of the driver and server you are using, and whether it&apos;s a replica set or sharded cluster.&lt;/p&gt;</comment>
                            <comment id="3020548" author="david@akenza.com" created="Wed, 1 Apr 2020 07:56:29 +0000"  >&lt;p&gt;I&apos;ve added the file stacktrace_for_callback_error.txt. This is the error which is thrown by the package &quot;org.mongodb.driver.operation&quot; when the above MongoException is thrown.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br/&gt;
David&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="254432" name="error_143_stacktrace.txt" size="5013" author="david@akenza.com" created="Wed, 1 Apr 2020 07:30:37 +0000"/>
                            <attachment id="254433" name="stacktrace_for_callback_error.txt" size="7259" author="david@akenza.com" created="Wed, 1 Apr 2020 07:49:40 +0000"/>
                    </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|hx0bzb:</customfieldvalue>

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