<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:45:29 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-37261] CurrentOp shouldn&apos;t read OpCtx decorations</title>
                <link>https://jira.mongodb.org/browse/SERVER-37261</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;The currentOp command loops over all Clients, and for any that have an associated OpCtx and OperationContextSession it &lt;a href=&quot;https://github.com/mongodb/mongo/blob/f8592013b46a5c463c7cf52e0883d94a62742489/src/mongo/db/pipeline/pipeline_d.cpp#L934&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;reads the ReadConcernArgs decoration off the OpCtx&lt;/a&gt;.  This isn&apos;t valid as there&apos;s no synchronization around writing to the decoration other than that it can only happen from the thread running the OpCtx.&lt;br/&gt;
This means that there&apos;s a data race when reading the ReadConcernArgs decoration as it could be modified by the thread running the OpCtx while it is being read by currentOp.&lt;/p&gt;</description>
                <environment></environment>
        <key id="608251">SERVER-37261</key>
            <summary>CurrentOp shouldn&apos;t read OpCtx decorations</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="vesselina.ratcheva@mongodb.com">Vesselina Ratcheva</assignee>
                                    <reporter username="spencer@mongodb.com">Spencer Brody</reporter>
                        <labels>
                    </labels>
                <created>Fri, 21 Sep 2018 19:25:50 +0000</created>
                <updated>Mon, 8 Jan 2024 15:23:15 +0000</updated>
                            <resolved>Thu, 8 Nov 2018 19:56:03 +0000</resolved>
                                                    <fixVersion>4.1.6</fixVersion>
                                    <component>Replication</component>
                                        <votes>0</votes>
                                    <watches>9</watches>
                                                                                                                <comments>
                            <comment id="2056444" author="vesselina.ratcheva" created="Thu, 8 Nov 2018 19:56:03 +0000"  >&lt;p&gt;Closing this, as it&apos;s completed. Feel free to file additional ticket(s) as you see fit.&lt;/p&gt;</comment>
                            <comment id="2055288" author="xgen-internal-githook" created="Thu, 8 Nov 2018 00:21:34 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Vesselina Ratcheva&apos;, &apos;email&apos;: &apos;vesselina.ratcheva@10gen.com&apos;, &apos;username&apos;: &apos;vessy-mongodb&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-37261&quot; title=&quot;CurrentOp shouldn&amp;#39;t read OpCtx decorations&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-37261&quot;&gt;&lt;del&gt;SERVER-37261&lt;/del&gt;&lt;/a&gt; Protect setting ReadConcernArgs decoration on OperationContext with client lock&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/304855678fc014d7b5f840a77023381a3315f86c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/304855678fc014d7b5f840a77023381a3315f86c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2054577" author="tess.avitabile" created="Wed, 7 Nov 2018 15:46:12 +0000"  >&lt;p&gt;Not at all, I think it&apos;s a good idea to think about how we can handle the concurrency of decorations better.&lt;/p&gt;</comment>
                            <comment id="2054566" author="kaloian.manassiev" created="Wed, 7 Nov 2018 15:41:19 +0000"  >&lt;p&gt;Yes, yes - I didn&apos;t mean to derail this change now (already approved the CR).&lt;/p&gt;</comment>
                            <comment id="2054559" author="tess.avitabile" created="Wed, 7 Nov 2018 15:36:51 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kaloian.manassiev&quot; class=&quot;user-hover&quot; rel=&quot;kaloian.manassiev&quot;&gt;kaloian.manassiev&lt;/a&gt;, would it be alright with you if &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=vesselina.ratcheva&quot; class=&quot;user-hover&quot; rel=&quot;vesselina.ratcheva&quot;&gt;vesselina.ratcheva&lt;/a&gt; pushes her changes to take the client lock when setting the ReadConcernArgs decoration, in order to fix the failure? We can file a ticket with the proposed refactor.&lt;/p&gt;</comment>
                            <comment id="2054551" author="schwerin" created="Wed, 7 Nov 2018 15:33:04 +0000"  >&lt;p&gt;Good point, Tess.&lt;br/&gt;
On Wed, Nov 7, 2018 at 2:58 PM Tess Avitabile (Jira) &amp;lt;jira@mongodb.org&amp;gt;&lt;/p&gt;
</comment>
                            <comment id="2054472" author="tess.avitabile" created="Wed, 7 Nov 2018 14:57:20 +0000"  >&lt;p&gt;It would be preferable if the thread that owns the OperationContext does not need to hold the Client lock in order to read the decorations--it should only need the Client lock in order to modify them.&lt;/p&gt;</comment>
                            <comment id="2054259" author="schwerin" created="Wed, 7 Nov 2018 10:33:04 +0000"  >&lt;p&gt;The getter would &lt;b&gt;only&lt;/b&gt; accept unique_lock&amp;lt;&amp;gt;, but yeah, I was thinking&lt;br/&gt;
along those lines.&lt;/p&gt;

&lt;p&gt;On Wed, Nov 7, 2018, 10:25 AM Kaloian Manassiev (Jira) &amp;lt;jira@mongodb.org&amp;gt;&lt;/p&gt;
</comment>
                            <comment id="2054253" author="kaloian.manassiev" created="Wed, 7 Nov 2018 10:24:44 +0000"  >&lt;blockquote&gt;&lt;p&gt;The decorations that were intended to be accessed in that way would be accessed through getters that took const unique_lock&amp;lt;Client&amp;gt;&amp;amp; or similar instead of Client*, thus enforcing that the caller held the Client lock when accessing them.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Actually I like this idea. So perhaps decorations that need to be synchronized on the client would derive from a separate &quot;SynchronizedDecoration&quot; class, whose &lt;tt&gt;get&lt;/tt&gt; method also accepts a &lt;tt&gt;unique_lock&amp;lt;T&amp;gt;&amp;amp;&lt;/tt&gt; of some parent type. Is this what you meant?&lt;/p&gt;</comment>
                            <comment id="2054245" author="schwerin" created="Wed, 7 Nov 2018 10:18:04 +0000"  >&lt;p&gt;I don&#8217;t think it makes sense for all decorations to have internal concurrency control and its incumbent overhead when only a few are accessed off-thread.&lt;/p&gt;

&lt;p&gt;Even if the overhead were free, I don&#8217;t think it&#8217;s wise to assume that separately synchronizing a bunch of individual decorations will lead to correct behavior - some decorations may change in concert with each other, e.g. I could imagine having the off-thread decorations somehow kept separately and in a way where they could only be accessed by threads that held the Client lock, though.&lt;/p&gt;

&lt;p&gt;The decorations that were intended to be accessed in that way would be accessed through getters that took &lt;tt&gt;const unique_lock&amp;lt;Client&amp;gt;&amp;amp;&lt;/tt&gt; or similar instead of &lt;tt&gt;Client*&lt;/tt&gt;, thus enforcing that the caller held the Client lock when accessing them.&lt;/p&gt;</comment>
                            <comment id="2054211" author="kaloian.manassiev" created="Wed, 7 Nov 2018 08:57:18 +0000"  >&lt;p&gt;So I looked at the code review for this and while it is correct as implemented, using the client lock to protect access/modifications to the decorations of OperationContext is not a very future-proof way to solve this. There are probably 50 decorations on the OpCtx now and we managed to catch this one, but who knows what the issues are with the other.&lt;/p&gt;

&lt;p&gt;In my opinion, it should be the responsibility of the decorations to have internal concurrency control of their own if they can be read from outside the OperationContext&apos;s thread and the meaning of the client mutex should be to just ensure that the Client and the OperationContext object won&apos;t disappear from underneath whoever is reading it.&lt;/p&gt;

&lt;p&gt;Does it make sense to bake this mechanism in the Decoration class itself (or at least the one for OperationContext), where the &lt;tt&gt;get&lt;/tt&gt; method returns a locked ScopedObject (with the correct operators so we don&apos;t have to retype every use)?&lt;/p&gt;</comment>
                            <comment id="2048163" author="siyuan.zhou@10gen.com" created="Wed, 31 Oct 2018 20:58:08 +0000"  >&lt;p&gt;Even if we cache the read concern in&#160;TransactionParticipant, the access to it still has to be synchronized, maybe under the transaction participant&apos;s mutex. The client&apos;s mutex is designed to protect the concurrent access of operation context, so it&apos;s very reasonable to follow this pattern unless it doesn&apos;t work.&lt;/p&gt;</comment>
                            <comment id="2046917" author="siyuan.zhou@10gen.com" created="Tue, 30 Oct 2018 22:14:14 +0000"  >&lt;p&gt;Discussed with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mira.carey%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;mira.carey@mongodb.com&quot;&gt;mira.carey@mongodb.com&lt;/a&gt;, we already &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a66a5578d5b006cef85b16eac05c96b58c877ebe/src/mongo/db/pipeline/mongo_process_common.cpp#L62&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;acquire the client lock&lt;/a&gt; when reporting currentOp. We should protect the two places where we set the read concern in &lt;tt&gt;service_entry_point_common.cpp&lt;/tt&gt; with the client lock.&lt;/p&gt;

&lt;p&gt;We probably need to change the title too.&lt;/p&gt;</comment>
                            <comment id="2010896" author="william.schultz" created="Fri, 21 Sep 2018 19:44:42 +0000"  >&lt;p&gt;As per my comment on BF-10109, for this specific case it may be simpler to just store the ReadConcernArgs on the Session/TransactionParticipant object and keep it there, so we can always have access to them, instead of worrying about them going back and forth between the OperationContext and the Session/TransactionParticipant, on every stash/unstash event. That way we wouldn&apos;t have to worry about modifying the locking rules for the ReadConcernArgs decoration.&lt;/p&gt;</comment>
                            <comment id="2010879" author="schwerin" created="Fri, 21 Sep 2018 19:37:40 +0000"  >&lt;p&gt;If we want to read the read concern, we could start acquiring the client lock before setting it. I don&#8217;t know where we&#8217;d document that rule, but it&#8217;s the standard way we deal with data that&#8217;s read from currentOp.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                                        </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="585022">SERVER-36499</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>15.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>Fri, 21 Sep 2018 19:37:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 13 weeks, 6 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_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>
                            5 years, 13 weeks, 6 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.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>schwerin@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>kaloian.manassiev@mongodb.com</customfieldvalue>
            <customfieldvalue>siyuan.zhou@mongodb.com</customfieldvalue>
            <customfieldvalue>spencer@mongodb.com</customfieldvalue>
            <customfieldvalue>tess.avitabile@mongodb.com</customfieldvalue>
            <customfieldvalue>vesselina.ratcheva@mongodb.com</customfieldvalue>
            <customfieldvalue>william.schultz@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hu8l8f:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr8rdr:</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="2542">Repl 2018-10-22</customfieldvalue>
    <customfieldvalue id="2543">Repl 2018-11-05</customfieldvalue>
    <customfieldvalue id="2605">Repl 2018-11-19</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|hu87hr:</customfieldvalue>

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