<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 06:20:22 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-71936] Time-series view and bucket collection are locked in different order in validation than other places</title>
                <link>https://jira.mongodb.org/browse/SERVER-71936</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;The validate command takes the lock on the view first while create and drop take the lock on the bucket collection first. This can lead to potential deadlock.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2205334">SERVER-71936</key>
            <summary>Time-series view and bucket collection are locked in different order in validation than other places</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="13202">Works as Designed</resolution>
                                        <assignee username="dianna.hohensee@mongodb.com">Dianna Hohensee</assignee>
                                    <reporter username="yuhong.zhang@mongodb.com">Yuhong Zhang</reporter>
                        <labels>
                    </labels>
                <created>Wed, 7 Dec 2022 19:25:02 +0000</created>
                <updated>Fri, 27 Oct 2023 13:51:48 +0000</updated>
                            <resolved>Thu, 12 Jan 2023 00:14:31 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>5</watches>
                                                                                                                <comments>
                            <comment id="5107742" author="dianna.hohensee" created="Thu, 12 Jan 2023 00:14:31 +0000"  >&lt;p&gt;Closing with Works as Designed.&lt;/p&gt;</comment>
                            <comment id="5104123" author="dianna.hohensee" created="Tue, 10 Jan 2023 20:43:55 +0000"  >&lt;p&gt;Investigation notes:&lt;/p&gt;

&lt;p&gt;createCollection will first create the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/db6db2824bb9aea2692ae09725a2e4dd16c30a82/src/mongo/db/catalog/create_collection.cpp#L318-L322&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;bucket collection under locks&lt;/a&gt; that go out of scope before next creating the &lt;a href=&quot;https://github.com/mongodb/mongo/blob/db6db2824bb9aea2692ae09725a2e4dd16c30a82/src/mongo/db/catalog/create_collection.cpp#L404-L414&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;view under appropriate locks&lt;/a&gt;. So there is no bucket/view namespace lock overlap.&lt;/p&gt;

&lt;p&gt;dropCollection will drop &lt;a href=&quot;https://github.com/mongodb/mongo/blob/db6db2824bb9aea2692ae09725a2e4dd16c30a82/src/mongo/db/catalog/drop_collection.cpp#L420-L432&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the view entry under locks&lt;/a&gt; as part of a lambda internal to another function dropping the buckets collection already under &lt;a href=&quot;https://github.com/mongodb/mongo/blob/db6db2824bb9aea2692ae09725a2e4dd16c30a82/src/mongo/db/catalog/drop_collection.cpp#L202&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;locks&lt;/a&gt; before calling into &lt;a href=&quot;https://github.com/mongodb/mongo/blob/db6db2824bb9aea2692ae09725a2e4dd16c30a82/src/mongo/db/catalog/drop_collection.cpp#L292&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the lambda&lt;/a&gt;. &lt;ins&gt;Therefore, drop first acquires a bucket namespace lock and then the view namespace lock.&lt;/ins&gt; Note that the drop command &lt;a href=&quot;https://github.com/mongodb/mongo/blob/db6db2824bb9aea2692ae09725a2e4dd16c30a82/src/mongo/db/catalog/drop_collection.cpp#L503-L509&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;enters with the time-series view namespace given to the drop function&lt;/a&gt;, not the buckets namespace &#8211; affects the code path chosen.&lt;/p&gt;

&lt;p&gt;The validate cmd will &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a1013cadfd225e0eaa3a3d4a17597ade7dc8259a/src/mongo/db/catalog/collection_validation.cpp#L468&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;push the user specified namespace into the validate locking logic&lt;/a&gt; unaltered.&#160;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/master/src/mongo/db/catalog/validate_state.cpp#L68-L79&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Locks are immediately taken on the given namespace&lt;/a&gt; whether or not a collection/view exists. If the namespace is not a collection, is a view and is time-series, &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a1013cadfd225e0eaa3a3d4a17597ade7dc8259a/src/mongo/db/catalog/validate_state.cpp#L97-L102&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;then locks are taken on the buckets collection&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Ah. There is a trick here. The same variable &lt;tt&gt;_collectionLock&lt;/tt&gt; holds the user specified time-series namespace lock AND the time-series buckets collection lock: taking a lock on the buckets release the time-series view namespace locks first. We only hold one collection-level lock at a time during validation.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=yuhong.zhang%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;yuhong.zhang@mongodb.com&quot;&gt;yuhong.zhang@mongodb.com&lt;/a&gt;&#160;I think the deadlock might not be possible re the previous paragraph &#8211; I think the code could use some additional comments, though, if my analysis is correct, and you original thought &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a1013cadfd225e0eaa3a3d4a17597ade7dc8259a/src/mongo/db/catalog/validate_state.cpp#L74-L102&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;validate held two collection locks across this code&lt;/a&gt;.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2.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_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25136"><![CDATA[Storage Execution]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 10 Jan 2023 20:43:55 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        1 year, 4 weeks 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>
                            1 year, 4 weeks ago
                        </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>dianna.hohensee@mongodb.com</customfieldvalue>
            <customfieldvalue>yuhong.zhang@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i1lv1j:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|i17acn:zy</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="6684">Execution Team 2023-01-23</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|i1lh6v:</customfieldvalue>

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