<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:53:19 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-61785] API for detecting conflicts among TenantMigrationDonor POS instances is racy.</title>
                <link>https://jira.mongodb.org/browse/SERVER-61785</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-60752&quot; title=&quot;API for detecting conflicts among PrimaryOnlyService instances&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-60752&quot;&gt;&lt;del&gt;SERVER-60752&lt;/del&gt;&lt;/a&gt; introduced a new API for detecting conflicts among POS instances. As part of that ticket, to detect different migration id with same tenant id conflicts, the tenant migration donor(TMD) &lt;a href=&quot;https://github.com/mongodb/mongo/blob/348fd9169533326d1d034a1dc9c408ebf60c74ec/src/mongo/db/repl/tenant_migration_donor_service.cpp#L165&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;API&lt;/a&gt; was made to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/348fd9169533326d1d034a1dc9c408ebf60c74ec/src/mongo/db/repl/tenant_migration_donor_service.cpp#L427&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;wait&lt;/a&gt; for the existing TMD instance&apos;s initial state doc to be majority committed. This can lead to 3-way deadlocks. I think, accidentally, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-60953&quot; title=&quot;TenantMigrationDonorService::getDurableState should return a future&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-60953&quot;&gt;&lt;del&gt;SERVER-60953&lt;/del&gt;&lt;/a&gt;, fixed that 3 way deadlock issue but made the API (PrimaryOnlyService::checkIfConflictsWithOtherInstances) racy.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Racy scenario:&lt;/b&gt;&lt;/p&gt;
&lt;div class=&apos;table-wrap&apos;&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;th class=&apos;confluenceTh&apos;&gt;TMD Instance 1&lt;br/&gt;
 Migration ID 1 + Tenant ID 1&lt;/th&gt;
&lt;th class=&apos;confluenceTh&apos;&gt;TMD Instance 2 &lt;br/&gt;
 Migration ID 2 + Tenant ID 1&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;Calls getOrCreateInstance()
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/primary_only_service.cpp#L512&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Acquires&lt;/a&gt; POS Mutex
	&lt;ul&gt;
		&lt;li&gt;Calls &lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/primary_only_service.cpp#L535&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;checkIfConflictsWithOtherInstances()&lt;/a&gt;
		&lt;ul&gt;
			&lt;li&gt;No conflicts detected&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;Create Instance1&lt;/li&gt;
		&lt;li&gt;Schedules Instance:run() to run &lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/primary_only_service.cpp#L750-L764&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;asynchronously&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Insert Instance1 into POS in-memory &lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/primary_only_service.cpp#L768&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;map&lt;/a&gt; (keyed using MigrationID)&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Release POS Mutex&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&#160;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&#160;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;Calls getOrCreateInstance()
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Acquires POS Mutex
	&lt;ul&gt;
		&lt;li&gt;Calls checkIfConflictsWithOtherInstances()
		&lt;ul&gt;
			&lt;li&gt;&lt;b&gt;No conflicts detected as Instance 1 durable state is &lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/tenant_migration_donor_service.cpp#L160-L162&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;empty&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
		&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;Create Instance2.&lt;/li&gt;
		&lt;li&gt;Schedules Instance:run() to run asynchronously&lt;/li&gt;
		&lt;li&gt;Insert Instance2 into POS in-memory map&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Release POS Mutex&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;Instance1::run() starts
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/tenant_migration_donor_service.cpp#L479-L486&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Persists&lt;/a&gt; state doc with Migration ID 1 + Tenant ID 1.&lt;/li&gt;
	&lt;li&gt;Durable state gets updated to non-empty&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&#160;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;&#160;&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;Instance2::run() starts
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Persists state doc with Migration ID 2 + Tenant ID 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;


&lt;p&gt;&lt;b&gt;Additional notes on 3-way deadlock scenario:&lt;/b&gt;&lt;br/&gt;
 1)&#160;Instance 2 holds POS mutex (as part of getOrCreateInstance()) and wait for Instance1 initial state doc to be majority committed.&lt;br/&gt;
 2) Stepdown thread holds RSTL in mode X and tries to acquire POS mutex to execute POS onStepDown() (to interrupt active instances) and blocks behind Instance 2.&lt;br/&gt;
 3) Instance 1 tries to acquire RSTL in IX mode to write the initial state doc but blocks behind the stepdown thread.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1935057">SERVER-61785</key>
            <summary>API for detecting conflicts among TenantMigrationDonor POS instances is racy.</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="backlog-server-serverless">[DO NOT USE] Backlog - Server Serverless</assignee>
                                    <reporter username="suganthi.mani@mongodb.com">Suganthi Mani</reporter>
                        <labels>
                    </labels>
                <created>Mon, 29 Nov 2021 21:04:46 +0000</created>
                <updated>Fri, 27 Oct 2023 13:52:10 +0000</updated>
                            <resolved>Tue, 30 Nov 2021 00:50:51 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4216245" author="suganthi.mani" created="Tue, 30 Nov 2021 00:50:21 +0000"  >&lt;p&gt;I misread the code. I somehow thought, we skip the tenant id conflict &lt;a href=&quot;https://github.com/10gen/mongo/blob/09c682abb6cab352b1751f1f9b083a9fedaae1ee/src/mongo/db/repl/tenant_migration_donor_service.cpp#L160-L164&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;check&lt;/a&gt; when the durable state of the existing instance is empty. The code has no racy issues. So, closing this ticket.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1899590">SERVER-60752</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1907221">SERVER-60953</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>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25131"><![CDATA[Serverless]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 10 weeks, 2 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>
                            2 years, 10 weeks, 2 days 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>backlog-server-serverless</customfieldvalue>
            <customfieldvalue>suganthi.mani@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|i0bxon:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hzva8f:</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_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|i0bjtz:</customfieldvalue>

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