<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:12:24 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-26526] make TaskExecutor::cancel return whether the task was successfully canceled</title>
                <link>https://jira.mongodb.org/browse/SERVER-26526</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;In at least one case (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-26524&quot; title=&quot;check if addShardHandle present in ShardingCatalogManagerImpl::_handleAddShardTaskResponse before continuing&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-26524&quot;&gt;&lt;del&gt;SERVER-26524&lt;/del&gt;&lt;/a&gt;), we had to add a brittle workaround because canceling a task does not guarantee that CallbackCanceled is delivered to the callback (if the task completes before cancel() is called, the actual response will be delivered instead).&lt;/p&gt;

&lt;p&gt;I see how it&apos;s difficult to directly return whether CallbackCanceled will be delivered since the task is canceled by post()&apos;ing to the asio::io_service::strand:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/thread_pool_task_executor.cpp#L360&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/thread_pool_task_executor.cpp#L360&lt;/a&gt; -&amp;gt;&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/network_interface_asio.cpp#L427&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/network_interface_asio.cpp#L427&lt;/a&gt; -&amp;gt;&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/network_interface_asio_operation.cpp#L114-L122&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/r3.4.0-rc0/src/mongo/executor/network_interface_asio_operation.cpp#L114-L122&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;but perhaps a blocking version of TaskExecutor::cancel (or a flag that indicates whether it should block) could be added?&lt;/p&gt;</description>
                <environment></environment>
        <key id="322138">SERVER-26526</key>
            <summary>make TaskExecutor::cancel return whether the task was successfully canceled</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="9">Done</resolution>
                                        <assignee username="mira.carey@mongodb.com">Mira Carey</assignee>
                                    <reporter username="esha.maharishi@mongodb.com">Esha Maharishi</reporter>
                        <labels>
                    </labels>
                <created>Fri, 7 Oct 2016 20:00:48 +0000</created>
                <updated>Mon, 8 Jan 2024 15:22:58 +0000</updated>
                            <resolved>Mon, 31 Oct 2016 16:46:27 +0000</resolved>
                                    <version>3.4.0-rc0</version>
                                                    <component>Networking</component>
                                        <votes>0</votes>
                                    <watches>7</watches>
                                                                                                                <comments>
                            <comment id="1418983" author="jason.carey" created="Wed, 26 Oct 2016 22:41:49 +0000"  >&lt;p&gt;That&apos;s reasonable.  I think that, for 3.6, we&apos;re likely to take another stab at the TaskExecutor API to make events more like futures (so you could pull things like cancellation out of waiting on them).  But for now, go ahead and use the wait to fill in a RemoteCommandResponse.&lt;/p&gt;</comment>
                            <comment id="1418884" author="esha.maharishi@10gen.com" created="Wed, 26 Oct 2016 21:19:48 +0000"  >&lt;p&gt;That&apos;s fine; is there any way after waiting on the callback, to check if CallbackCanceled was delivered?&lt;/p&gt;

&lt;p&gt;One way I&apos;ve seen this done is to create a RemoteCommandResponse variable before scheduling the task, capture that variable into the callback, and assign the RemoteCommandCallbackArgs.response to it within the callback.&lt;/p&gt;

&lt;p&gt;Then after waiting for the callback, we can examine that captured variable.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo/blob/r3.4.0-rc1/src/mongo/s/client/shard_remote.cpp#L203-L220&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/blob/r3.4.0-rc1/src/mongo/s/client/shard_remote.cpp#L203-L220&lt;/a&gt;&lt;br/&gt;
(Here, we check for ExceededTimeLimit, but we could also check for CallbackCanceled).&lt;/p&gt;

&lt;p&gt;Does this seem like a good general pattern? (It&apos;s not the way I wrote the workaround in &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-26524&quot; title=&quot;check if addShardHandle present in ShardingCatalogManagerImpl::_handleAddShardTaskResponse before continuing&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-26524&quot;&gt;&lt;del&gt;SERVER-26524&lt;/del&gt;&lt;/a&gt;, but it could be changed to be written that way).&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mira.carey%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;mira.carey@mongodb.com&quot;&gt;mira.carey@mongodb.com&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1418870" author="jason.carey" created="Wed, 26 Oct 2016 21:08:47 +0000"  >&lt;p&gt;A synchronous cancel() implies fully blocking on the operation until it&apos;s completely resolved.  Given that some cancelers won&apos;t want to block, we already have to design our callback functions to handle cancellation.  Which means we&apos;re going to have to deal with the cancel in two places, ensure handling code doesn&apos;t race and deal with the ambiguity of where it lives (synchronous canceler is on thread, async callback isn&apos;t).&lt;/p&gt;

&lt;p&gt;I&apos;m leaning Andy&apos;s way.  Make your callback handle the cancellation and wait on the callback.  The alternative (making your callback only sometime run) is going to cause you more headache than time saved.&lt;/p&gt;</comment>
                            <comment id="1404339" author="esha.maharishi@10gen.com" created="Mon, 10 Oct 2016 17:21:31 +0000"  >&lt;p&gt;Although, even if can&apos;t be done in a non-blocking way, it&apos;s maybe less complicated and more easily testable to have TaskExecutor::cancel() return whether it succeeded... than make every person who codes a callback manage concurrent access to a variable or data structure for this purpose?&lt;/p&gt;</comment>
                            <comment id="1404333" author="esha.maharishi@10gen.com" created="Mon, 10 Oct 2016 17:19:12 +0000"  >&lt;p&gt;That&apos;s a good point; I guess if there was a non-blocking way for TaskExecutor::cancel() to return whether CallbackCanceled would be set on the callback or if it was too late, that would be preferable. Maybe this could be done by checking what stage/state the task was in?&lt;/p&gt;

&lt;p&gt;If it can&apos;t be done in a non-blocking way, waiting on the callback is equivalent.&lt;/p&gt;</comment>
                            <comment id="1404314" author="schwerin" created="Mon, 10 Oct 2016 17:08:55 +0000"  >&lt;p&gt;Why not just wait on the callback handle, if you&apos;re willing to block, and have the callback&apos;s own behavior signal canceledness to the observer, eg by setting a flag?&lt;/p&gt;</comment>
                            <comment id="1403306" author="esha.maharishi@10gen.com" created="Fri, 7 Oct 2016 20:02:40 +0000"  >&lt;p&gt;We could also consider doing this as part of PM-642.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="322126">SERVER-26524</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>7.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_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>Mon, 10 Oct 2016 17:08:55 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        7 years, 16 weeks 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>
                            7 years, 16 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>schwerin@mongodb.com</customfieldvalue>
            <customfieldvalue>esha.maharishi@mongodb.com</customfieldvalue>
            <customfieldvalue>mira.carey@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrjtwv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hsqmtj:</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="1347">Platforms 2016-10-31</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|hs2sev:</customfieldvalue>

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