<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:02: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>[SERVER-22988] MongoDB Concurrency Lock Failed for Multithread Insert/Update</title>
                <link>https://jira.mongodb.org/browse/SERVER-22988</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I did some test on MongoDB from java multithread program to check how MongoDB ensure concurrent access on document. My sample program ensure that only one copy will exists on collection. it inserts a document if it not exists in collection otherwise it updates document frequency. After several tests i found that some documents exists with same value. &lt;/p&gt;

&lt;p&gt;Mongo DB Collection&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;   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;{ _id: ObjectId, doc: String, doc_freq: Integer, created_at: Date }&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;Index:&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;   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;db.doc.ensureIndex({doc:1});&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;Here &quot;doc&quot; field is used for searching and if anything found then &quot;doc_freq&quot; is updated. If nothing is found then new document will be inserted.I have inserted 100000 entries which has same doc value and used 200 thread. And found that more than one entries found on collection with same doc value. I have used Java MongoDB Driver Version: 3.0.4 and **MongoDB Version:3.2.1 on OS Yosemite and Wire Tiger engine. Please find my test code from this url &lt;a href=&quot;https://talha13@bitbucket.org/talha13/duplicatetest.git&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://talha13@bitbucket.org/talha13/duplicatetest.git&lt;/a&gt; . To reproduce this issue please run several times and make sure before each run doc collection are clear.&lt;/p&gt;</description>
                <environment></environment>
        <key id="270451">SERVER-22988</key>
            <summary>MongoDB Concurrency Lock Failed for Multithread Insert/Update</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="3">Duplicate</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="talha">Mahbubur Rub Talha</reporter>
                        <labels>
                    </labels>
                <created>Mon, 7 Mar 2016 17:09:06 +0000</created>
                <updated>Thu, 10 Mar 2016 20:18:12 +0000</updated>
                            <resolved>Thu, 10 Mar 2016 20:18:12 +0000</resolved>
                                    <version>3.2.1</version>
                                                    <component>Concurrency</component>
                    <component>WiredTiger</component>
                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="1199576" author="ramon.fernandez" created="Thu, 10 Mar 2016 20:17:45 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=talha13%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;talha13@gmail.com&quot;&gt;talha13@gmail.com&lt;/a&gt;, modifying the current behavior is being discussed in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14322&quot; title=&quot;Retry on predicate unique index violations of update + upsert -&amp;gt; insert when possible&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14322&quot;&gt;&lt;del&gt;SERVER-14322&lt;/del&gt;&lt;/a&gt;, but so far there&apos;s no consensus on what the server should do.&lt;/p&gt;

&lt;p&gt;In cases where the server can describe a serial order over updates to the index region / index / index entry being modified  it could declare a winner. Determining when such a serialization actually exists or could exist requires further study.&lt;/p&gt;

&lt;p&gt;Feel free to add your voice to &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14322&quot; title=&quot;Retry on predicate unique index violations of update + upsert -&amp;gt; insert when possible&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14322&quot;&gt;&lt;del&gt;SERVER-14322&lt;/del&gt;&lt;/a&gt; an watch it for updates.&lt;/p&gt;

&lt;p&gt;Regards,&lt;br/&gt;
Ram&#243;n.&lt;/p&gt;</comment>
                            <comment id="1195249" author="talha" created="Mon, 7 Mar 2016 17:41:19 +0000"  >&lt;p&gt;Yes, i bypass this issue by creating Unique Index. But i&apos;m not happy with this solution. I think MongoDB should handle this issue.&lt;/p&gt;</comment>
                            <comment id="1195234" author="scotthernandez" created="Mon, 7 Mar 2016 17:32:43 +0000"  >&lt;p&gt;This looks like a duplicate of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-20380&quot; title=&quot;Upsert is not atomic when inserting&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-20380&quot;&gt;&lt;del&gt;SERVER-20380&lt;/del&gt;&lt;/a&gt;, and is explained in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-14322&quot; title=&quot;Retry on predicate unique index violations of update + upsert -&amp;gt; insert when possible&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-14322&quot;&gt;&lt;del&gt;SERVER-14322&lt;/del&gt;&lt;/a&gt; better.&lt;/p&gt;

&lt;p&gt;In short, you need a unique index if you want to ensure that the update + insert parts of your update do not produce duplicates (see the &lt;a href=&quot;https://docs.mongodb.org/manual/reference/method/db.collection.update/#use-unique-indexes&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;docs&lt;/a&gt; and your use of &lt;a href=&quot;https://bitbucket.org/talha13/duplicatetest/src/7da27ec37fb5809053f6ee91bdda6db759b65cbc/src/duplicatetest/theadpool/DocWorker.java?at=master&amp;amp;fileviewer=file-view-default#DocWorker.java-51&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;upsert:true&lt;/a&gt;) &lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="143209">SERVER-14322</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>3.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Mon, 7 Mar 2016 17:32:43 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        7 years, 48 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>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            7 years, 48 weeks, 6 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>talha</customfieldvalue>
            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>
            <customfieldvalue>scotthernandez</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrkeev:</customfieldvalue>

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

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