<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 05:29:44 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-53035] provide a way to ASSERT from a non-main thread in unit tests</title>
                <link>https://jira.mongodb.org/browse/SERVER-53035</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Investigating &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-51821&quot; title=&quot;Always join threads in SharedFuture tests &quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-51821&quot;&gt;&lt;del&gt;SERVER-51821&lt;/del&gt;&lt;/a&gt;, I found an ASSERT_EQ in a worker thread, which, if triggered, would crash the process with std::terminate. It is not valid to perform any kind of ASSERT from unit test thread other than the main thread.&lt;/p&gt;

&lt;p&gt;This cause of std::terminate is NOT ultimately the symptom of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-51821&quot; title=&quot;Always join threads in SharedFuture tests &quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-51821&quot;&gt;&lt;del&gt;SERVER-51821&lt;/del&gt;&lt;/a&gt;, in which the controlling thread simply stopped (via throw) and never executed the explicit .join of the worker threads at the bottom of the test. But investigation of &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-51821&quot; title=&quot;Always join threads in SharedFuture tests &quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-51821&quot;&gt;&lt;del&gt;SERVER-51821&lt;/del&gt;&lt;/a&gt; uncovered the ASSERT from non-main problem to be a very common weakness that exists in most of our concurrent unit tests.&lt;/p&gt;

&lt;p&gt;I propose that we identify ASSERTs that need to be fixed by changing ASSERT so that even if it passes, it will fail unless it is running on a safe thread.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1550234">SERVER-53035</key>
            <summary>provide a way to ASSERT from a non-main thread in unit tests</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="billy.donahue@mongodb.com">Billy Donahue</assignee>
                                    <reporter username="billy.donahue@mongodb.com">Billy Donahue</reporter>
                        <labels>
                    </labels>
                <created>Mon, 23 Nov 2020 20:25:54 +0000</created>
                <updated>Sun, 29 Oct 2023 22:00:06 +0000</updated>
                            <resolved>Tue, 24 Nov 2020 18:22:10 +0000</resolved>
                                                    <fixVersion>4.9.0</fixVersion>
                    <fixVersion>4.4.7</fixVersion>
                                    <component>Internal Code</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="3807521" author="xgen-internal-githook" created="Fri, 21 May 2021 23:03:14 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-53035&quot; title=&quot;provide a way to ASSERT from a non-main thread in unit tests&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-53035&quot;&gt;&lt;del&gt;SERVER-53035&lt;/del&gt;&lt;/a&gt; ThreadAssertionMonitor&lt;br/&gt;
Branch: v4.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/de32d95a395f60bbea3d9c6f39cc1285fac4a41b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/de32d95a395f60bbea3d9c6f39cc1285fac4a41b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3504065" author="billy.donahue" created="Tue, 24 Nov 2020 18:22:10 +0000"  >&lt;p&gt;Closing as we have the ASSERT transporting system in place,&lt;br/&gt;
as &lt;tt&gt;unittest::ThreadAssertMonitor&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;Further work would be to identify and fix all the unsafe ASSERTs. In some sense it might be ok to leave them alone, because if a worker thread leaks an ASSERT exception and brings down the whole unit test, we will not mistake that for a passing test. It&apos;s just that other tests won&apos;t get a chance to run, and the cause of failure won&apos;t be clear....&lt;/p&gt;

&lt;p&gt;It could be clear if the &lt;tt&gt;std::terminate&lt;/tt&gt; handler we install in unit tests knew how to catch &lt;tt&gt;unitttest::TestAssertionFailureException&lt;/tt&gt; to print it out on its way to &lt;tt&gt;std::abort&lt;/tt&gt;, but that exception type is deliberately hard to catch. But &lt;tt&gt;std::terminate&lt;/tt&gt; is special. We should add a hook for that.&lt;/p&gt;</comment>
                            <comment id="3503983" author="xgen-internal-githook" created="Tue, 24 Nov 2020 17:48:23 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Billy Donahue&apos;, &apos;email&apos;: &apos;billy.donahue@mongodb.com&apos;, &apos;username&apos;: &apos;BillyDonahue&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-53035&quot; title=&quot;provide a way to ASSERT from a non-main thread in unit tests&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-53035&quot;&gt;&lt;del&gt;SERVER-53035&lt;/del&gt;&lt;/a&gt; ThreadAssertionMonitor&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/5e82f974f44a822753ad0656692a1011a6611b3c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/5e82f974f44a822753ad0656692a1011a6611b3c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3503142" author="billy.donahue" created="Tue, 24 Nov 2020 03:08:47 +0000"  >&lt;p&gt;This PoC adds an invariant if ASSERT comparisons happen outside a TEST thread.&lt;br/&gt;
&lt;a href=&quot;https://github.com/BillyDonahue/mongo/commit/25d2315a95943019b9219dfa51861bf46bd88b9b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/BillyDonahue/mongo/commit/25d2315a95943019b9219dfa51861bf46bd88b9b&lt;/a&gt;&lt;br/&gt;
I&apos;ll be curious to see what it turns up.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://spruce.mongodb.com/version/5fbc796657e85a38e7937d4f/tasks&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://spruce.mongodb.com/version/5fbc796657e85a38e7937d4f/tasks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lot of tests failed. Several failed that were actually fine.&lt;br/&gt;
Many of the failures were false positives from tests using &lt;tt&gt;std::async&lt;/tt&gt; and &lt;tt&gt;std::future::get&lt;/tt&gt; in the main thread. &lt;tt&gt;std::future&lt;/tt&gt; transports exceptions to the .get() caller properly so these are not a problem even though they are technically ASSERT statements that are outside of the main thread.&lt;/p&gt;

&lt;p&gt;Several such tests are just using stdx::future to get more work done in parallel.&lt;br/&gt;
I believe several tests were parallelized this way a while back.&lt;/p&gt;

&lt;p&gt;For those tests, we can turn off the check entirely, or add a scope guard to mark the current thread ok at the top of the async lambdas.&lt;/p&gt;

&lt;p&gt;Example: testPermutation in src/mongo/db/storage/key_string_test.cpp &lt;/p&gt;

&lt;p&gt;Another go at it with better diagnostic reporting.&lt;br/&gt;
&lt;a href=&quot;https://spruce.mongodb.com/version/5fbd1fd4d1fe072958c0e9cc/tasks&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://spruce.mongodb.com/version/5fbd1fd4d1fe072958c0e9cc/tasks&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3502717" author="billy.donahue" created="Mon, 23 Nov 2020 20:33:00 +0000"  >&lt;p&gt;Code Review: &lt;a href=&quot;https://mongodbcr.appspot.com/720450002/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://mongodbcr.appspot.com/720450002/&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10420">
                    <name>Backports</name>
                                            <outwardlinks description="backported by">
                                                        </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="1523927">SERVER-51821</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1622927">SERVER-54531</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="1551148">SERVER-53065</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1550711">SERVER-53049</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>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18555" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname># of Sprints</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_12450" key="com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes">
                        <customfieldname>Backport Requested</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="18953"><![CDATA[v4.4]]></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>Tue, 24 Nov 2020 17:48:23 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        2 years, 37 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_17050" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Downstream Team Attention</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="16941"><![CDATA[Not Needed]]></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>
                            2 years, 37 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_16465" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Linked BF Score</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>28.0</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>billy.donahue@mongodb.com</customfieldvalue>
            <customfieldvalue>xgen-internal-githook</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hyirbr:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hy4qxr:</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="4272">Service arch 2020-11-30</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|hyidl3:</customfieldvalue>

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