<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:08:01 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>[MONGOCRYPT-121] Properly handle duplicate key conflicts</title>
                <link>https://jira.mongodb.org/browse/MONGOCRYPT-121</link>
                <project id="17481" key="MONGOCRYPT">Libmongocrypt</project>
                    <description>&lt;p&gt;Came out of &lt;a href=&quot;https://jira.mongodb.org/browse/MONGOCRYPT-75&quot; title=&quot;libmongocrypt: Support keyaltname&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MONGOCRYPT-75&quot;&gt;&lt;del&gt;CDRIVER-3057&lt;/del&gt;&lt;/a&gt;. We should think carefully about handling conflicts of multiple keys with duplicate key alt names or keys sharing a UUID with different sets of key alt names.&lt;/p&gt;

&lt;p&gt;Copied from the code review:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In cases where two keys conflict (different sets of keyAltName), perhaps the&lt;br/&gt;
right thing to do is always favor the key document has the more recent&lt;br/&gt;
&quot;updateDate&quot;.&lt;/p&gt;

&lt;p&gt;Conflicts might not be that uncommon, if we&apos;re getting some keys from the cache.&lt;br/&gt;
Consider a user moving a key alt name from one document to another.&lt;/p&gt;

&lt;p&gt;Server first starts with:&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;The key cache contains&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;Then the user &quot;renames&quot; the entries:&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;The key broker gets two entries:&lt;br/&gt;
keyAltName=&quot;a&quot;&lt;br/&gt;
keyAltName=&quot;b&quot;&lt;/p&gt;

&lt;p&gt;The first entry is satisfied with a cached value:&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;And the second is satisfied with the conflicting:&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;So in that case we could deduplicate based on &quot;updateDate&quot;. That&apos;s not perfect,&lt;br/&gt;
as it&apos;s not guaranteed to be monotonically increasing, but it would probably&lt;br/&gt;
handle many common cases.&lt;/p&gt;

&lt;p&gt;I think we should leave this as follow-up work, under a ticket like &quot;Gracefully&lt;br/&gt;
handle all key inconsistencies&quot;&lt;/p&gt;

&lt;p&gt;This could involve:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;handle conflicting duplicate entries by favoring &quot;updateDate&quot;&lt;/li&gt;
	&lt;li&gt;failing that, invalidate any matching cache entries (i.e. mark as expired),&lt;br/&gt;
and try fetching again (maybe just once)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;If that sounds good to you, I can create a ticket.&lt;/p&gt;

&lt;p&gt;Edit: I think there&apos;s even more to consider. Requests for keys in the key broker&lt;br/&gt;
should stay satisfied after deduplication.&lt;/p&gt;

&lt;p&gt;Consider:&lt;br/&gt;
Key broker has two entries:&lt;br/&gt;
keyAltName=&quot;a&quot;&lt;br/&gt;
keyAltName=&quot;b&quot;&lt;/p&gt;

&lt;p&gt;First entry is satisfied with:&lt;/p&gt;
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { _id}&lt;/span&gt; &lt;/div&gt;

&lt;p&gt;Then, second entry is satisfied with&lt;br/&gt;
{_id: 2, keyAltNames: &lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;&amp;#93;&lt;/span&gt;, lastUpdated: 2 }&lt;/p&gt;

&lt;p&gt;When we deduplicate after the second entry, we&apos;d remove the first entry since&lt;br/&gt;
it&apos;s older and has a conflicting shared keyAltName. But the marking requested a&lt;br/&gt;
key using keyAltName=&quot;a&quot;. So removing that key broker entry would leave that&lt;br/&gt;
marking unsatisfied.&lt;/p&gt;

&lt;p&gt;Sooo... it might be a little more subtle. If one of the key broker entries would&lt;br/&gt;
be left unsatisfied after deduplication, perhaps refetch it, or don&apos;t&lt;br/&gt;
deduplicate?&lt;/p&gt;&lt;/blockquote&gt;</description>
                <environment></environment>
        <key id="764845">MONGOCRYPT-121</key>
            <summary>Properly handle duplicate key conflicts</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="kevin.albertson@mongodb.com">Kevin Albertson</assignee>
                                    <reporter username="kevin.albertson@mongodb.com">Kevin Albertson</reporter>
                        <labels>
                    </labels>
                <created>Sat, 11 May 2019 01:08:15 +0000</created>
                <updated>Sat, 28 Oct 2023 10:25:15 +0000</updated>
                            <resolved>Sat, 24 Aug 2019 18:12:43 +0000</resolved>
                                                    <fixVersion>1.0.0-beta5</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="2387287" author="xgen-internal-githook" created="Mon, 26 Aug 2019 20:45:55 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;kevinAlbs&apos;, &apos;email&apos;: &apos;kevin.albertson@mongodb.com&apos;, &apos;name&apos;: &apos;Kevin Albertson&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/MONGOCRYPT-121&quot; title=&quot;Properly handle duplicate key conflicts&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MONGOCRYPT-121&quot;&gt;&lt;del&gt;CDRIVER-3125&lt;/del&gt;&lt;/a&gt; fix for local keys&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/libmongocrypt/commit/7618e53eea8c82710ab519dd3118356de4925ca6&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/libmongocrypt/commit/7618e53eea8c82710ab519dd3118356de4925ca6&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2385404" author="xgen-internal-githook" created="Sat, 24 Aug 2019 18:12:30 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;kevinAlbs&apos;, &apos;email&apos;: &apos;kevin.albertson@mongodb.com&apos;, &apos;name&apos;: &apos;Kevin Albertson&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/MONGOCRYPT-121&quot; title=&quot;Properly handle duplicate key conflicts&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MONGOCRYPT-121&quot;&gt;&lt;del&gt;CDRIVER-3125&lt;/del&gt;&lt;/a&gt; handle duplicate keys&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Rewrite of the key broker.&lt;/li&gt;
	&lt;li&gt;Key broker now errors if driver returns conflicting keys for a single&lt;br/&gt;
entry. Key cache always overwrites older entries with newer entries.&lt;/li&gt;
	&lt;li&gt;Fix some key cache bugs (potential deadlock + key attribute comparison&lt;br/&gt;
bug)&lt;/li&gt;
	&lt;li&gt;Adds JSON tests of the cache&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/libmongocrypt/commit/b34546630ed774cdc59aca2791d2ae6aa0e3aa7c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/libmongocrypt/commit/b34546630ed774cdc59aca2791d2ae6aa0e3aa7c&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="2269175" author="kevin.albertson" created="Mon, 3 Jun 2019 17:42:28 +0000"  >&lt;p&gt;Some additional ideas that came out of &lt;a href=&quot;https://mongodbcr.appspot.com/449770001/diff/437600002/src/mongocrypt-key-broker.c#newcode63&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this review&lt;/a&gt; for &lt;a href=&quot;https://jira.mongodb.org/browse/MONGOCRYPT-39&quot; title=&quot;libmongocrypt: key + collinfo cache&quot; class=&quot;issue-link&quot; data-issue-key=&quot;MONGOCRYPT-39&quot;&gt;&lt;del&gt;CDRIVER-2951&lt;/del&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In an event that we have two keys with intersecting key alt names but different key ids, the simplest approach may be to flush the cache.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="889467">MONGOCRYPT-158</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                                        </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                            <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[5002K00000r5ZgmQAE]]]></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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|huobq7:</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>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>