<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:08:41 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-67644] Certain ServerStatusMetricFields can lead to a data race</title>
                <link>https://jira.mongodb.org/browse/SERVER-67644</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Unless &lt;em&gt;ServerStatusMetricField&lt;/em&gt; relies on a storage container which provides thread-safe primitives, the &lt;em&gt;serverStatus&lt;/em&gt; command can report corrupted data if one thread is reading the contents of a field while another is writing to it.&lt;/p&gt;

&lt;p&gt;The current code base contains at least &lt;a href=&quot;https://github.com/10gen/mongo/blob/35eb6deef0f47505104e8ff066c695369776c070/src/mongo/db/repl/replication_coordinator_impl.cpp#L166-L169&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;one instance&lt;/a&gt; of it where a &lt;em&gt;ServerStatusMetricField&lt;/em&gt; is built out of a &lt;em&gt;std::string&lt;/em&gt; which doesn&apos;t guarantee thread safety.&lt;/p&gt;

&lt;p&gt;It is worth to notice that this should be carefully designed as it could lead to service degradation due to the introduction of currently inexistent contention and metrics are spread throughout all of the code base.&lt;/p&gt;

&lt;p&gt;Acceptance Criteria: Either create a mechanism to atomically swap the contents of a &lt;em&gt;ServerStatusMetricField&lt;/em&gt; or make sure all stored types are thread-safe by design.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2079516">SERVER-67644</key>
            <summary>Certain ServerStatusMetricFields can lead to a data race</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="billy.donahue@mongodb.com">Billy Donahue</assignee>
                                    <reporter username="daniel.morilha@mongodb.com">Daniel Morilha</reporter>
                        <labels>
                            <label>tsan</label>
                    </labels>
                <created>Wed, 29 Jun 2022 14:14:33 +0000</created>
                <updated>Sun, 29 Oct 2023 21:36:13 +0000</updated>
                            <resolved>Sun, 14 Aug 2022 07:22:16 +0000</resolved>
                                                    <fixVersion>6.1.0-rc0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="4748853" author="xgen-internal-githook" created="Sun, 14 Aug 2022 07:02:36 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-67644&quot; title=&quot;Certain ServerStatusMetricFields can lead to a data race&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-67644&quot;&gt;&lt;del&gt;SERVER-67644&lt;/del&gt;&lt;/a&gt; fix racy std::string metric&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/ad7b2d0fa2e8557bcb83170d599992710b883db4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/ad7b2d0fa2e8557bcb83170d599992710b883db4&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="4748437" author="billy.donahue" created="Sat, 13 Aug 2022 09:17:24 +0000"  >&lt;p&gt;We have a `synchronized_value&amp;lt;T&amp;gt;` that we can leverage here to make arbitrary metrics thread-safe.&lt;br/&gt;
I had to use that anyway for the std::string metric fix so we might as well make it generally available.&lt;br/&gt;
Then we would support anything that can be .append&apos;ed to a BSONObjBuilder.&lt;/p&gt;</comment>
                            <comment id="4747323" author="JIRAUSER1268551" created="Fri, 12 Aug 2022 16:29:43 +0000"  >&lt;p&gt;This was picked up by the thread sanitizer and I am not convinced this is a good fix. I think while this API is relatively new we can make it race free (so a situation like this can never happen in the future).&lt;/p&gt;

&lt;p&gt;I suggest we do something similar to &lt;a href=&quot;https://openmetrics.io/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://openmetrics.io/&lt;/a&gt; (which is the same as Prometheus) where they provide ~5 types of metrics. makeServerStatusMetric could be split into about 5 functions makeServerStatusCounter/makeServerStatusSafeString/makeServerStatusNumber/etc that provide thread safe metrics and prevent an issue like this in the future.&lt;/p&gt;</comment>
                            <comment id="4673856" author="billy.donahue" created="Tue, 12 Jul 2022 15:43:40 +0000"  >&lt;p&gt;After looking at the ServerStatusMetric uses, I think the &quot;lastStateTransition&quot; std::string metric is the only case of a race.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/10gen/mongo/blob/35eb6deef0f47505104e8ff066c695369776c070/src/mongo/db/repl/replication_coordinator_impl.cpp#L166-L169&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/10gen/mongo/blob/35eb6deef0f47505104e8ff066c695369776c070/src/mongo/db/repl/replication_coordinator_impl.cpp#L166-L169&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One possible fix would be changing it from &lt;tt&gt;std::string&lt;/tt&gt; to &lt;tt&gt;synchronized_value&amp;lt;std::string&amp;gt;&lt;/tt&gt;. This might work because synchronized_value is assignable convertible from its &lt;tt&gt;value_type&lt;/tt&gt;. but it might not work. Depends on how the metric is used.  Maybe a generic synchronized_value metric would be useful.&lt;/p&gt;

&lt;p&gt;On the other hand maybe that one case where repl is using a string as a metric can be done in a different way.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="2033700">SERVER-65987</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="2070686">SERVER-67333</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.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>Tue, 12 Jul 2022 15:43:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 25 weeks, 3 days 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-2398</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, 25 weeks, 3 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>alex.neben@mongodb.com</customfieldvalue>
            <customfieldvalue>billy.donahue@mongodb.com</customfieldvalue>
            <customfieldvalue>daniel.morilha@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i10gu7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i0jbag:</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="6399">Service Arch 2022-08-22</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|i102zj:</customfieldvalue>

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