<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:10:03 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-68154] Race in destruction of Resharding metrics can lead to calling pure virtual function</title>
                <link>https://jira.mongodb.org/browse/SERVER-68154</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Whenever ShardingDataTransformInstanceMetrics destructor is called, it will &lt;a href=&quot;https://github.com/mongodb/mongo/blob/6a9aece38e458c35e99b21f249260d018c9e6ccf/src/mongo/db/s/sharding_data_transform_cumulative_metrics.cpp#L167&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;remove the observer to itself&lt;/a&gt; (&lt;a href=&quot;https://github.com/mongodb/mongo/blob/6a9aece38e458c35e99b21f249260d018c9e6ccf/src/mongo/db/s/sharding_data_transform_instance_metrics.cpp#L90&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;) from the ShardingDataTransformCumulativeMetrics. The issue is that &lt;a href=&quot;https://github.com/mongodb/mongo/blob/6a9aece38e458c35e99b21f249260d018c9e6ccf/src/mongo/db/s/sharding_data_transform_instance_metrics.h#L72&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;ShardingDataTransformInstanceMetrics::getRecipientHighEstimateRemainingTimeMillis&lt;/a&gt; is a pure virtual function and by the time the destructor for ShardingDataTransformInstanceMetrics is being run, the child class is already destroyed (In production server, this is the ReshardingMetrics class). So there is a small window where the observer instance is still accessible and trying to call getRecipientHighEstimateRemaining on it will result in terminating the server.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2094752">SERVER-68154</key>
            <summary>Race in destruction of Resharding metrics can lead to calling pure virtual function</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="13201">Fixed</resolution>
                                        <assignee username="randolph@mongodb.com">Randolph Tan</assignee>
                                    <reporter username="randolph@mongodb.com">Randolph Tan</reporter>
                        <labels>
                    </labels>
                <created>Tue, 19 Jul 2022 20:20:41 +0000</created>
                <updated>Sun, 29 Oct 2023 21:35:31 +0000</updated>
                            <resolved>Tue, 26 Jul 2022 21:00:57 +0000</resolved>
                                                    <fixVersion>6.1.0-rc0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="4706991" author="xgen-internal-githook" created="Tue, 26 Jul 2022 20:53:21 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Randolph Tan&apos;, &apos;email&apos;: &apos;randolph@10gen.com&apos;, &apos;username&apos;: &apos;renctan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-68154&quot; title=&quot;Race in destruction of Resharding metrics can lead to calling pure virtual function&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-68154&quot;&gt;&lt;del&gt;SERVER-68154&lt;/del&gt;&lt;/a&gt; Race in destruction of Resharding metrics can lead to calling pure virtual function&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/921bba175902f9b9f29751a466383c3d7e80df7b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/921bba175902f9b9f29751a466383c3d7e80df7b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4696628" author="JIRAUSER1262262" created="Thu, 21 Jul 2022 19:43:44 +0000"  >&lt;p&gt;It seems to me that fundamentally, either 1. the metrics need to be deregistered before the child class starts getting destroyed or 2. the metrics relevant to calculating the time estimate need to survive past the child class being destroyed.&lt;/p&gt;

&lt;p&gt;For approach 1, I agree that option A is the less bad choice.&lt;/p&gt;

&lt;p&gt;For approach 2, I think the resulting code would be more convoluted than its worth.&lt;/p&gt;

&lt;p&gt;&#160;&lt;br/&gt;
I think we can close &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-67048&quot; title=&quot;Replace ShardingDataTransformCumulativeMetrics DeregistrationFunction with ScopeGuard&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-67048&quot;&gt;&lt;del&gt;SERVER-67048&lt;/del&gt;&lt;/a&gt; afterwards if we do go with option A here.&lt;/p&gt;</comment>
                            <comment id="4696303" author="renctan" created="Thu, 21 Jul 2022 17:53:48 +0000"  >&lt;p&gt;Making the function into non pure virtual appears to make the test pass. But I suspect that this only narrows the window for the race. From my understanding, the vtable is switched to pointing to ShardingDataTransformCumulativeMetrics&apos;s when it&apos;s own destructor is called, so there is still a tiny window where calls to getRecipientHighEstimateRemainingTimeMillis will attempt to call ReshardingMetrics&apos;s after it has started destroying it&apos;s own member variables.&lt;/p&gt;

&lt;p&gt;So I have 2 proposals in mind:&lt;br/&gt;
Option A: Child class is responsible for calling _deregister in it&apos;s destructor (also add invariant in base class destructor that _deregister is null).&lt;br/&gt;
pros:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;less typing&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;cons:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;not immediately obvious why child class needs to be responsible for deregistration from readability stand point.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Option B: Remove _deregister from base class and child class is responsible for it&apos;s lifetime.&lt;br/&gt;
pros:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;opposite of option A cons. No weirdness on calling _deregister since it owns it.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;cons:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;opposite of option A pros. Observer functionality and lifetime maintenance logic will need to duplicated for each child class.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I&apos;m currently leaning towards option A, what do you guys think? &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=max.hirschhorn%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;max.hirschhorn@mongodb.com&quot;&gt;max.hirschhorn@mongodb.com&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=brett.nawrocki%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;brett.nawrocki@mongodb.com&quot;&gt;brett.nawrocki@mongodb.com&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="2062987">SERVER-67048</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="390945" name="repro.diff" size="2351" author="randolph@mongodb.com" created="Tue, 19 Jul 2022 20:21:53 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 21 Jul 2022 19:43:44 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 28 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></customfieldvalue>

                        </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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            1 year, 28 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>135.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>brett.nawrocki@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>randolph@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i132sn:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0lwjs:</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_22250" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Special Downgrade Instructions Required</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="23343"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="6343">Sharding 2022-07-11</customfieldvalue>
    <customfieldvalue id="6344">Sharding 2022-07-25</customfieldvalue>
    <customfieldvalue id="6345">Sharding 2022-08-08</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10750" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Steps To Reproduce</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;Apply repro.diff and run the cpp test&lt;/p&gt;</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|i12oxz:</customfieldvalue>

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