<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:21:28 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-50011] Can a transaction used again after document save fails using that transaction?</title>
                <link>https://jira.mongodb.org/browse/SERVER-50011</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Let&apos;s imagine a situation like this.&lt;/p&gt;

&lt;p&gt;I need to generate 10 documents in the same collection. So I use a loop. The loop won&apos;t stop until 10 documents are saved. Even if a single iteration fails, loop continues until the total number of saved documents are 10. This works fine. Then I added transactions to scenario. Let&apos;s say transaction starts before the loop executes inside a try catch block. If any error occurs transaction fails except errors in the loop. Because they are ignore to complete the loop until 10 documents are saved. So the problem occurs when transaction is applied to a document when saving. If the loop runs without errors there won&apos;t be any problem. But I purposely add a duplicate record on iteration 5 by using a counter.&#160;&lt;/p&gt;

&lt;p&gt;What I expected was to complete the loop and commit the transaction ignoring the duplicate record as the loop however completes with 10 saved documents.&lt;/p&gt;

&lt;p&gt;But when a manual error is introduced using a duplicate record from iteration 6 a MongoDB error is thrown.&#160;&lt;font color=&quot;#FF0000&quot;&gt;&apos;MongoError: Transaction 1 has been aborted.\n&apos;&#160;&lt;/font&gt;So the loops runs infinite until I add a error counter and throw error out of the loop when error counter reaches a given count.&lt;/p&gt;

&lt;p&gt;So what is wrong in this situation. My guess is, as the document save fails in the iteration 5 due to the duplicate record, the transaction aborts at that point. So the transaction is not available for the iteration 6 as it is already aborted. I don&apos;t know weather this is the default behavior of MongoDB. Please verify and is there any way to go around this?&lt;/p&gt;



&lt;p&gt;I&apos;m using NodeJS and Mongoose. Function is attached as a text file. Thank you!&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</description>
                <environment></environment>
        <key id="1424300">SERVER-50011</key>
            <summary>Can a transaction used again after document save fails using that transaction?</summary>
                <type id="6" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14720&amp;avatarType=issuetype">Question</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="jonathan.streets@mongodb.com">Jonathan Streets</assignee>
                                    <reporter username="sajithneyo94@gmail.com">Sajith Neyomal</reporter>
                        <labels>
                    </labels>
                <created>Wed, 29 Jul 2020 20:48:24 +0000</created>
                <updated>Fri, 27 Oct 2023 13:52:46 +0000</updated>
                            <resolved>Fri, 31 Jul 2020 13:44:32 +0000</resolved>
                                                                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="3315496" author="jonathan.streets" created="Fri, 31 Jul 2020 13:43:59 +0000"  >&lt;p&gt;hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=sajithneyo94%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;sajithneyo94@gmail.com&quot;&gt;sajithneyo94@gmail.com&lt;/a&gt;,&lt;br/&gt;
 the transaction is working as expected, on&#160;&lt;a href=&quot;https://docs.mongodb.com/manual/core/transactions/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;the docs&lt;/a&gt; it says that transaction sessions are an &quot;all-or-nothing&quot; type operation. Once the insert fails, then the other inserts are rolled back and the transaction session is ended.&#160;If operations are expected to fail, or if the set of operations do not need to be atomic, then I think your original design is best, which has loops but no transaction session.&lt;br/&gt;
regards&lt;br/&gt;
Jon&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="271909" name="function.txt" size="3145" author="sajithneyo94@gmail.com" created="Wed, 29 Jul 2020 20:48:09 +0000"/>
                    </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_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Fri, 31 Jul 2020 13:43:59 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        3 years, 27 weeks, 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_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>
                            3 years, 27 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>jonathan.streets@mongodb.com</customfieldvalue>
            <customfieldvalue>sajithneyo94@gmail.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hxxcif:</customfieldvalue>

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

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