<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:47:46 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>[SERVER-59650] Insert after refine can lead to unsafe access to the chunk manager</title>
                <link>https://jira.mongodb.org/browse/SERVER-59650</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;CollectionMetadata offers a method to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/04a2a0050956a305c241a438b82a6d183a6df12a/src/mongo/db/s/collection_metadata.h#L184-L187&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;get a weak reference to the chunk manager&lt;/a&gt; it points to.&lt;/p&gt;

&lt;p&gt;It has been observed a case in which this led to the chunk manager being cleared up while still used by an op observer.&lt;/p&gt;

&lt;p&gt;The flow that led to hit the error - right after a &lt;tt&gt;refineCollectionShardKey&lt;/tt&gt; was the following:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;The application of an insert oplog entry on a secondary triggered &lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/db/s/shard_server_op_observer.cpp#L248&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ShardServerOpObserver::onInserts&lt;/a&gt; (yes, the observer is also active on secondaries)&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/db/s/shard_server_op_observer.cpp#L184&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;incrementChunkOnInsertOrUpdate&lt;/a&gt; got called with a &lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/db/s/shard_server_op_observer.cpp#L312&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;pointer to the old chunk manager&lt;/a&gt; as argument, and succeeded to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/db/s/shard_server_op_observer.cpp#L190-L191&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;get the old shard key&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Upon calling &lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/db/s/shard_server_op_observer.cpp#L198&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;findIntersectingChunkWithSimpleCollation&lt;/a&gt;, the chunk manager got cleared up (because the pointer was not shared) and the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/s/chunk_manager.cpp#L386&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;chunk info&lt;/a&gt; was not found&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="1861866">SERVER-59650</key>
            <summary>Insert after refine can lead to unsafe access to the chunk manager</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="antonio.fuschetto@mongodb.com">Antonio Fuschetto</assignee>
                                    <reporter username="pierlauro.sciarelli@mongodb.com">Pierlauro Sciarelli</reporter>
                        <labels>
                            <label>sharding-wfbf-day</label>
                    </labels>
                <created>Fri, 27 Aug 2021 16:49:50 +0000</created>
                <updated>Fri, 21 Oct 2022 10:42:25 +0000</updated>
                            <resolved>Fri, 21 Oct 2022 10:41:50 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4918008" author="JIRAUSER1259062" created="Fri, 21 Oct 2022 09:54:41 +0000"  >&lt;p&gt;The initial idea of referring to a chunk manager object with a shared pointer (instead of a raw one) does not resolve the problem since the life type of the collection metadata is the actual root cause of the issue. Indeed, the collection metadata is deleted while and insert/update operation is in progress on the secondaries, causing a memory access violation (dangling pointer error) of the chunk manager.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://github.com/mongodb/mongo/blob/706e2ae7402066800716f296331f614e1e0e528c/src/mongo/db/s/shard_server_op_observer.cpp#L198&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;findIntersectingChunkWithSimpleCollation&lt;/a&gt; function, which triggers the described problem, will no longer be used in 6.0 branch and higher (see &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-70758&quot; title=&quot;Stop tracking chunk writes in versions supporting data-size aware balancing&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-70758&quot;&gt;&lt;del&gt;SERVER-70758&lt;/del&gt;&lt;/a&gt;). As for the other branches, a synchronization mechanism would be needed to ensure that the collection metadata was not deleted while an insert/update operation is in progress on the secondaries. After a discussion with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=pierlauro.sciarelli%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;pierlauro.sciarelli@mongodb.com&quot;&gt;pierlauro.sciarelli@mongodb.com&lt;/a&gt;, a proper solution would be costly in terms of performance, as well as development.&lt;/p&gt;

&lt;p&gt;Considering that a problem of this nature has never occurred in real environments (external customers), we believe it is appropriate to ignore the problem on old branches, at least for now. Closing as won&#8217;t fix.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="2164008">SERVER-70758</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 21 Oct 2022 09:54:41 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 15 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-70758'>SERVER-70758</a></s>]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>antonio.fuschetto@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 15 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>antonio.fuschetto@mongodb.com</customfieldvalue>
            <customfieldvalue>pierlauro.sciarelli@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzzign:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0uuq0:1i</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>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="6287">Sharding EMEA 2022-08-08</customfieldvalue>
    <customfieldvalue id="6395">Sharding EMEA 2022-08-22</customfieldvalue>
    <customfieldvalue id="6396">Sharding EMEA 2022-09-05</customfieldvalue>
    <customfieldvalue id="6397">Sharding EMEA 2022-09-19</customfieldvalue>
    <customfieldvalue id="6550">Sharding EMEA 2022-10-03</customfieldvalue>
    <customfieldvalue id="6551">Sharding EMEA 2022-10-17</customfieldvalue>
    <customfieldvalue id="6552">Sharding EMEA 2022-10-31</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hzz4pb:</customfieldvalue>

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