<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:29:32 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-32206] Catalog change to declare an index as multikey must be timestamped.</title>
                <link>https://jira.mongodb.org/browse/SERVER-32206</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There are two cases to resolve. The &lt;a href=&quot;https://github.com/mongodb/mongo/blob/a89e8f0d97b860beb93d71569f2b155fee87f120/src/mongo/db/index/index_access_method.cpp#L509-L518&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;first is easier&lt;/a&gt;. The second is a little trickier:&lt;/p&gt;

&lt;p&gt;When a document is inserted/updated into a collection that can require multiple entries in an index (e.g: the value of an indexed field is an array), the index&apos;s &quot;multikey&quot; field must be set to true.&lt;/p&gt;

&lt;p&gt;This update is currently done as a &lt;a href=&quot;https://github.com/mongodb/mongo/blob/7aa806063d/src/mongo/db/catalog/index_catalog_entry_impl.cpp#L283-L316&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;side-transaction&lt;/a&gt; to avoid write conflicts. Being a side-transaction throws away the ability to inherit a timestamp from the insert/update request.&lt;/p&gt;

&lt;p&gt;Proposed solutions can be classified as:&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Remove the side transaction. Solutions here have varying degrees of effort to still allow for serialization of updates to the document to prevent a worst case scenario where progress slows down (stops?)&lt;/li&gt;
	&lt;li&gt;Assign a timestamp to the write that is at least as early as any updates that are part of the request requiring this update.
	&lt;ul&gt;
		&lt;li&gt;A bit more clever, introduce an error case when inserts require the &lt;tt&gt;multikey&lt;/tt&gt; field to be changed to &lt;tt&gt;true&lt;/tt&gt;. Top-level handlers should translate this error to setting &lt;tt&gt;multikey&lt;/tt&gt; to true (in a &quot;before?-transaction&quot;) followed by performing the insert. An explicit timestamp would still need to be chosen, but there might be less plumbing required to make the timestamp and transaction meet.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ol&gt;
</description>
                <environment></environment>
        <key id="469311">SERVER-32206</key>
            <summary>Catalog change to declare an index as multikey must be timestamped.</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="judah.schvimer@mongodb.com">Judah Schvimer</assignee>
                                    <reporter username="daniel.gottlieb@mongodb.com">Daniel Gottlieb</reporter>
                        <labels>
                            <label>rollback-functional</label>
                    </labels>
                <created>Thu, 7 Dec 2017 17:35:34 +0000</created>
                <updated>Mon, 30 Oct 2023 23:10:07 +0000</updated>
                            <resolved>Fri, 2 Feb 2018 15:50:32 +0000</resolved>
                                                    <fixVersion>3.7.2</fixVersion>
                                    <component>Storage</component>
                                        <votes>0</votes>
                                    <watches>6</watches>
                                                                                                                <comments>
                            <comment id="1793256" author="xgen-internal-githook" created="Fri, 2 Feb 2018 15:46:55 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;judah@mongodb.com&apos;, &apos;name&apos;: &apos;Judah Schvimer&apos;, &apos;username&apos;: &apos;judahschvimer&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-32206&quot; title=&quot;Catalog change to declare an index as multikey must be timestamped.&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-32206&quot;&gt;&lt;del&gt;SERVER-32206&lt;/del&gt;&lt;/a&gt; timestamp catalog change to declare index multikey&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/b2a7398e663ef090a651a93bedfc6d107a64cf33&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/b2a7398e663ef090a651a93bedfc6d107a64cf33&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1772097" author="judah.schvimer" created="Thu, 11 Jan 2018 21:23:36 +0000"  >&lt;p&gt;Upon discussion with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=daniel.gottlieb&quot; class=&quot;user-hover&quot; rel=&quot;daniel.gottlieb&quot;&gt;daniel.gottlieb&lt;/a&gt;, we will remove the side transaction.&lt;/p&gt;

&lt;p&gt;On a primary, we can simply assign this write the same timestamp as the index creation, insert, or update that caused this index to become multikey. This is because if two operations concurrently try to change the index to be multikey, they will conflict and the loser will simply get a higher timestamp and go into the oplog second with a later optime.&lt;/p&gt;

&lt;p&gt;On a secondary, writes must get the timestamp of their oplog entry, and the multikey change must occur at the timestamp of the earliest write that makes the index multikey. Secondaries only serialize writes by document, not by collection. If two inserts/updates that both make the index multikey are applied out of order, changing the index to multikey at the insert timestamps would change the index to multikey at the latter timestamp, which would be wrong. Index creations are applied serially with CRUD ops, so multikey index commits cannot conflict.&lt;/p&gt;

&lt;p&gt;To prevent this we can do one of two things:&lt;br/&gt;
1. On secondaries we can abort any WT transaction that tries to set an index to be multikey in a batch of oplog entries. We then would reapply that batch serially. This would require either propagating down to the IndexCatalogEntry the fact that we&apos;re applying an entry on a secondary in a batch, or propagating up the fact that multikey is being set and making the decision at a higher level.&lt;br/&gt;
2. As Dan mentioned above, introduce an error case when inserts or updates require the multikey field to be changed to true. SyncTail could then see this error and set the multikey field to true. The insert/update timestamp could either be combined with the error information and we could do the write at the minimum of these timestamps, or we could simply do the write at the first timestamp in the batch. Since the batch cannot include any DDL operations, it should be safe to execute this write at an earlier timestamp after the batch completes.&lt;/p&gt;</comment>
                            <comment id="1746446" author="daniel.gottlieb@10gen.com" created="Fri, 8 Dec 2017 01:47:08 +0000"  >&lt;p&gt;For completeness, one edge case is out of scope for solving as recover to a timestamp is designed to solve this problem.&lt;/p&gt;

&lt;p&gt;I believe secondaries applying operations in parallel can result in the following sequence. Consider two operations, one at Timestamp 1000 and the other at Timestamp 2000 that both require setting &lt;tt&gt;multikey&lt;/tt&gt; to &lt;tt&gt;true&lt;/tt&gt;:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt; TS: 1000                                         TS: 2000&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;Insert A                                         Insert B&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                                                 Set Multikey to true&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;                                                 Commit&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;In-memory observation that MultiKey does not need to be set&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;Commit&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Then suppose the secondary recovers to timestamp 1500 followed by rolling forward the oplog[1]. Assuming the &lt;tt&gt;multikey&lt;/tt&gt; write is only causally related to &lt;tt&gt;timestamp 2000&lt;/tt&gt;, the catalog may incorrectly believe &lt;tt&gt;multikey&lt;/tt&gt; to be &lt;tt&gt;false&lt;/tt&gt; despite &lt;tt&gt;Insert A&lt;/tt&gt; still existing. It is a goal of the recover to a stable timestamp is project to preserve this information. Specifically, it will save all &lt;tt&gt;multikey&lt;/tt&gt; true values (and their &lt;tt&gt;MultikeyPaths&lt;/tt&gt;) and restore those to indexes that still exist at recovery time. To not lose information in the face of a crash, that data can be made durable before recovering to the stable timestamp.&lt;/p&gt;

&lt;p&gt;[1] On second thought, this wouldn&apos;t be a problem today. Storage can only recover to a &quot;stable timestamp&quot; and secondaries only submit oplog batch boundaries as candidates for becoming stable. I believe this prevents the scenario from incorrectly losing this information. However, reading at a timestamp inside the batch could return a &lt;tt&gt;false&lt;/tt&gt; value despite still being able to observe &lt;tt&gt;write A&lt;/tt&gt;. I&apos;m not sure if those poses a problem for point in time reads on secondaries &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=milkie&quot; class=&quot;user-hover&quot; rel=&quot;milkie&quot;&gt;milkie&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1745816" author="james.wahlin@10gen.com" created="Thu, 7 Dec 2017 19:06:49 +0000"  >&lt;p&gt;As discussed, we write multikey path information to the database as part of the the MetaData, which is a timestamped write.&lt;/p&gt;</comment>
                            <comment id="1745723" author="milkie" created="Thu, 7 Dec 2017 18:13:20 +0000"  >&lt;p&gt;I don&apos;t think MultiKeyPaths is written to the database &amp;#8211; it&apos;s only populated in memory.&lt;/p&gt;</comment>
                            <comment id="1745717" author="james.wahlin@10gen.com" created="Thu, 7 Dec 2017 18:11:36 +0000"  >&lt;p&gt;Do we need to timestamp updates to &lt;a href=&quot;https://github.com/mongodb/mongo/blob/332ae576ef6e24080c0f8e9755f1574bbb90fdab/src/mongo/db/catalog/index_catalog_entry_impl.h#L222&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;MultikeyPaths&lt;/a&gt; as well or are they updated in a different manner?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="471360">SERVER-32284</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="419727">SERVER-30809</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                        <issuelink>
            <issuekey id="492019">SERVER-33106</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="505969">SERVER-33675</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="383656">SERVER-29213</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>6.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, 7 Dec 2017 18:11:36 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        6 years, 1 week, 5 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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>PM-842</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>
                            6 years, 1 week, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>daniel.gottlieb@mongodb.com</customfieldvalue>
            <customfieldvalue>milkie@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
            <customfieldvalue>james.wahlin@mongodb.com</customfieldvalue>
            <customfieldvalue>judah.schvimer@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htlsb3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|htdd6f:</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="2064">Repl 2018-01-15</customfieldvalue>
    <customfieldvalue id="2088">Repl 2018-01-29</customfieldvalue>
    <customfieldvalue id="2106">Repl 2018-02-12</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|htlef3:</customfieldvalue>

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