<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:15:47 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>[CDRIVER-2615] Do not allow a session to be used with an unacknowledged write concern</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-2615</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;Per the &lt;a href=&quot;https://github.com/mongodb/specifications/blob/master/source/sessions/driver-sessions.rst#when-using-unacknowledged-writes&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Driver Session spec&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Therefore drivers MUST NOT send a session ID with unacknowledged writes under any circumstances:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;For unacknowledged writes with an explicit session, drivers SHOULD raise an error. If a driver allows users to provide an explicit session with an unacknowledged write (e.g. for backwards compatibility), the driver MUST NOT send the session ID.&lt;/li&gt;
	&lt;li&gt;For unacknowledged writes without an explicit session, drivers SHOULD NOT use an implicit session. If a driver creates an implicit session for unacknowledged writes without an explicit session, the driver MUST NOT send the session ID.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Drivers MUST document the behavior of unacknowledged writes for both explicit and implicit sessions.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;While researching this in &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1163&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1163&quot;&gt;&lt;del&gt;PHPC-1163&lt;/del&gt;&lt;/a&gt;, I realized that libmongoc also does not enforce this. Using APM, we should test that &lt;tt&gt;lsid&lt;/tt&gt; fields are omitted from command documents for the following cases:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Executing a write operation or command with an explicit unacknowledged write concern&lt;/li&gt;
	&lt;li&gt;Executing a write operation or command with an inherited unacknowledged write concern&lt;/li&gt;
	&lt;li&gt;Executing a write operation or command with an explicit unacknowledged write concern and an explicit session&lt;/li&gt;
	&lt;li&gt;Executing a write operation or command with an inherited unacknowledged write concern and an explicit session&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The spec states that drivers &quot;SHOULD raise an error&quot; when explicit sessions are mixed with unacknowledged writes, but I noticed that &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/a87940261c2f4e13ec8e057d63e23a4cde0a5c1b/src/mongoc/mongoc-write-command.c#L490&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;_mongoc_write_opmsg()&lt;/tt&gt;&lt;/a&gt; silently omits the session in that case. That function is used for insert/update/delete and bulk writes, so I would propose we do the same for commands and findAndModify.&lt;/p&gt;

&lt;p&gt;There is already a &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/8f11ee6b9958656fe2a185332cbc21405fa271d1/tests/test-mongoc-client-session.c#L2172&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;test_unacknowledged()&lt;/tt&gt;&lt;/a&gt; case in the test suite, but it looks like the &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/8f11ee6b9958656fe2a185332cbc21405fa271d1/tests/test-mongoc-client-session.c#L843&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;APM callback doesn&apos;t assert anything for unacknowledged write concerns&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: users could technically add a &quot;writeConcern&quot; field to their command document without using the &quot;writeConcern&quot; option for &lt;tt&gt;command_with_opts()&lt;/tt&gt;, but I don&apos;t think we want to both inspecting that.&lt;/p&gt;</description>
                <environment></environment>
        <key id="529736">CDRIVER-2615</key>
            <summary>Do not allow a session to be used with an unacknowledged write concern</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="13201">Fixed</resolution>
                                        <assignee username="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="jmikola@mongodb.com">Jeremy Mikola</reporter>
                        <labels>
                    </labels>
                <created>Tue, 17 Apr 2018 21:23:51 +0000</created>
                <updated>Sat, 28 Oct 2023 11:29:55 +0000</updated>
                            <resolved>Wed, 23 May 2018 19:29:32 +0000</resolved>
                                    <version>1.9.0</version>
                                    <fixVersion>1.10.0</fixVersion>
                    <fixVersion>1.10.1</fixVersion>
                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1903748" author="xgen-internal-githook" created="Tue, 29 May 2018 18:58:04 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;ajdavis&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;email&apos;: &apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt; prohibit session and w=0 bulk write&lt;br/&gt;
Branch: r1.10&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/577018f9f66f2149e644528f42cbbb8c8ec96feb&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/577018f9f66f2149e644528f42cbbb8c8ec96feb&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1899982" author="xgen-internal-githook" created="Wed, 23 May 2018 19:46:51 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;username&apos;: &apos;ajdavis&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;email&apos;: &apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt; prohibit session and w=0 bulk write&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/21a66cb0dd202c9eabefc3ddea3a4aa51f573f1a&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/21a66cb0dd202c9eabefc3ddea3a4aa51f573f1a&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1898796" author="jesse" created="Tue, 22 May 2018 19:55:54 +0000"  >&lt;p&gt;We got the collection write functions like mongoc_collection_insert_one, but not mongoc_bulk_operation_execute.&lt;/p&gt;</comment>
                            <comment id="1885003" author="xgen-internal-githook" created="Mon, 7 May 2018 18:29:57 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jesse@mongodb.com&apos;, &apos;name&apos;: &apos;A. Jesse Jiryu Davis&apos;, &apos;username&apos;: &apos;ajdavis&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt; prohibit explicit session with w=0&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/93c7ec74450adc04924cfbeb9d7efaa848d30556&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/93c7ec74450adc04924cfbeb9d7efaa848d30556&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1884036" author="jesse" created="Sat, 5 May 2018 21:26:32 +0000"  >&lt;p&gt;Got it, thanks. &lt;/p&gt;</comment>
                            <comment id="1883997" author="jmikola@gmail.com" created="Sat, 5 May 2018 17:37:45 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jesse&quot; class=&quot;user-hover&quot; rel=&quot;jesse&quot;&gt;jesse&lt;/a&gt;: I believe the test in &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/887451f8a4dd08c2b308272dba7e4ed8b1788ced&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;887451f&lt;/a&gt; should already test that unacknowledged writes never include an lsid (implicit or explicit), but you will definitely need to add an error if users combine explicit sessions with unacknowledged writes.&lt;/p&gt;</comment>
                            <comment id="1883773" author="jesse" created="Sat, 5 May 2018 12:09:51 +0000"  >&lt;p&gt;Must still throw an error if an explicit session is used with an unacknowledged write, and verify that no implicit session is created with an unacknowledged write.&lt;/p&gt;</comment>
                            <comment id="1872957" author="xgen-internal-githook" created="Tue, 24 Apr 2018 17:47:41 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jmikola@gmail.com&apos;, &apos;username&apos;: &apos;jmikola&apos;, &apos;name&apos;: &apos;Jeremy Mikola&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1163&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1163&quot;&gt;&lt;del&gt;PHPC-1163&lt;/del&gt;&lt;/a&gt;: Prohibit session with unacknowledged write concern&lt;/p&gt;

&lt;p&gt;This adds checks to ensure that explicit sessions and unacknowledged write concerns (explicit or inherited) will not be mixed when executing bulk writes or commands. Additionally, we ensure that command execution does not create its own implicit session (per &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1152&quot; title=&quot;Aggregate may fail to use the same session for getMore commands&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1152&quot;&gt;&lt;del&gt;PHPC-1152&lt;/del&gt;&lt;/a&gt;) if the effective write concern is unacknowledged.&lt;/p&gt;

&lt;p&gt;Note: libmongoc still needs to ensure that it does not create implicit sessions for unacknowledged commands (&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt;).&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-php-driver/commit/cceeda84c128d08abc297e5fd9c9d8f5d7b07faa&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-php-driver/commit/cceeda84c128d08abc297e5fd9c9d8f5d7b07faa&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1872906" author="xgen-internal-githook" created="Tue, 24 Apr 2018 17:23:47 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jmikola@gmail.com&apos;, &apos;username&apos;: &apos;jmikola&apos;, &apos;name&apos;: &apos;Jeremy Mikola&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1163&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1163&quot;&gt;&lt;del&gt;PHPC-1163&lt;/del&gt;&lt;/a&gt;: Prohibit session with unacknowledged write concern&lt;/p&gt;

&lt;p&gt;This adds checks to ensure that explicit sessions and unacknowledged write concerns (explicit or inherited) will not be mixed when executing bulk writes or commands. Additionally, we ensure that command execution does not create its own implicit session (per &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1152&quot; title=&quot;Aggregate may fail to use the same session for getMore commands&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1152&quot;&gt;&lt;del&gt;PHPC-1152&lt;/del&gt;&lt;/a&gt;) if the effective write concern is unacknowledged.&lt;/p&gt;

&lt;p&gt;Note: libmongoc still needs to ensure that it does not create implicit sessions for unacknowledged commands (&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt;).&lt;br/&gt;
Branch: v1.4&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-php-driver/commit/cceeda84c128d08abc297e5fd9c9d8f5d7b07faa&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-php-driver/commit/cceeda84c128d08abc297e5fd9c9d8f5d7b07faa&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1871463" author="xgen-internal-githook" created="Mon, 23 Apr 2018 15:45:39 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jmikola@gmail.com&apos;, &apos;username&apos;: &apos;jmikola&apos;, &apos;name&apos;: &apos;Jeremy Mikola&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt; test that unacknowledged commands never include lsid&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/887451f8a4dd08c2b308272dba7e4ed8b1788ced&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/887451f8a4dd08c2b308272dba7e4ed8b1788ced&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1871462" author="xgen-internal-githook" created="Mon, 23 Apr 2018 15:45:37 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jmikola@gmail.com&apos;, &apos;username&apos;: &apos;jmikola&apos;, &apos;name&apos;: &apos;Jeremy Mikola&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt; omit explicit client session when WC is unacknowledged&lt;/p&gt;

&lt;p&gt;We omit the client session instead of raising an error for BC and&lt;br/&gt;
consistency with _mongoc_write_opmsg() for CRUD ops.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/92476ac1572c103fddbbc3566a5b21589685a3ea&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/92476ac1572c103fddbbc3566a5b21589685a3ea&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1871461" author="xgen-internal-githook" created="Mon, 23 Apr 2018 15:45:35 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jmikola@gmail.com&apos;, &apos;username&apos;: &apos;jmikola&apos;, &apos;name&apos;: &apos;Jeremy Mikola&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt; ensure parts.assembled.is_acknowledged is accurate&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/bae87f51cde4a128dd841055d92522f2c819a6b4&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/bae87f51cde4a128dd841055d92522f2c819a6b4&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1870591" author="jmikola@gmail.com" created="Fri, 20 Apr 2018 21:05:15 +0000"  >&lt;p&gt;&lt;a href=&quot;https://mongodbcr.appspot.com/198420001/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://mongodbcr.appspot.com/198420001/&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1870569" author="jmikola@gmail.com" created="Fri, 20 Apr 2018 20:46:07 +0000"  >&lt;p&gt;Some observations while implementing tests:&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;mongoccmdpartsassemble&quot;&gt;&lt;/a&gt;mongoc_cmd_parts_assemble&lt;/h4&gt;

&lt;p&gt;Command execution generally passes through &lt;tt&gt;mongoc_cmd_parts_assemble()&lt;/tt&gt;. While this function currently &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/86264e652dc648ab8c3522c39f4d9f3160b6d3b5/src/mongoc/mongoc-cmd.c#L745&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;avoids creating implicit sessions for unacknowledged write concerns&lt;/a&gt;, it has no such protection for explicit unacknowledged write concerns specified by the user (or inherited, as we&apos;ll see below). We can likely address this by adding some additional checks to &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/86264e652dc648ab8c3522c39f4d9f3160b6d3b5/src/mongoc/mongoc-cmd.c#L756&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;this condition&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;mongocclientcommandwithopts&quot;&gt;&lt;/a&gt;_mongoc_client_command_with_opts&lt;/h4&gt;

&lt;p&gt;&lt;tt&gt;_mongoc_client_command_with_opts()&lt;/tt&gt; is the root method for all of the &lt;tt&gt;command_with_opts&lt;/tt&gt; variants in the client and database classes. This function depends on &lt;tt&gt;mongoc_cmd_parts_append_opts()&lt;/tt&gt; to process user-specified options. Internally, &lt;tt&gt;mongoc_cmd_parts_append_opts()&lt;/tt&gt; updates &lt;tt&gt;parts-&amp;gt;assembled.is_acknowledged&lt;/tt&gt; whenever it encounters a write concern that would be applied to the command.&lt;/p&gt;

&lt;p&gt;When inheriting a write concern from the client or database object, &lt;tt&gt;_mongoc_client_command_with_opts()&lt;/tt&gt; &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/86264e652dc648ab8c3522c39f4d9f3160b6d3b5/src/mongoc/mongoc-client.c#L1814&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;manually appends to &lt;tt&gt;parts.extra&lt;/tt&gt;&lt;/a&gt;. This currently neglects to update &lt;tt&gt;parts-&amp;gt;assembled.is_acknowledged&lt;/tt&gt;, so we need to fix that.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;CRUDandbulkwrites&quot;&gt;&lt;/a&gt;CRUD and bulk writes&lt;/h4&gt;

&lt;p&gt;Best I can tell, all CRUD and bulk write methods route through &lt;tt&gt;_mongoc_write_command_execute()&lt;/tt&gt;. For anything involving sessions, control will need to pass through &lt;tt&gt;_mongoc_write_opmsg()&lt;/tt&gt;, which &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/86264e652dc648ab8c3522c39f4d9f3160b6d3b5/src/mongoc/mongoc-write-command.c#L492&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;already has logic to ignore explicit sessions for unacknowledged write concerns&lt;/a&gt;. &lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;mongoccollectionfindandmodifywithopts&quot;&gt;&lt;/a&gt;mongoc_collection_find_and_modify_with_opts&lt;/h4&gt;

&lt;p&gt;&lt;tt&gt;mongoc_collection_find_and_modify_with_opts()&lt;/tt&gt; has its own logic for inheriting the write concern, which dates back to &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/f7a07b80d865a7c460fbe2e4a5b88e1bb8462dea#diff-70a9be4e65f270168f8fe6744981365fR1954&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;f7a07b8&lt;/a&gt; in &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-824&quot; title=&quot;collection_find_and_modify() should apply the mongoc_collection_t write_concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-824&quot;&gt;&lt;del&gt;CDRIVER-824&lt;/del&gt;&lt;/a&gt;. Historically, &lt;tt&gt;mongoc_collection_find_and_modify_with_opts()&lt;/tt&gt; has only ever inherited an acknowledged write concern (it ignores an unacknowledged write concern on the collection).&lt;/p&gt;

&lt;p&gt;By my own testing, the server also seems to ignore an unacknowledged write concern if explicitly passed in the command. &lt;tt&gt;findAndModify&lt;/tt&gt; always returns a response. Consider:&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;   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;&amp;gt; db.runCommand({findAndModify:&quot;foo&quot;,update:{$inc:{x:1}},new:true,writeConcern:{w:0}});&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;{&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;	&quot;lastErrorObject&quot; : {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		&quot;n&quot; : 1,&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		&quot;updatedExisting&quot; : true&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;	},&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;	&quot;value&quot; : {&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		&quot;_id&quot; : ObjectId(&quot;5ada498db560305eb848924f&quot;),&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;		&quot;x&quot; : 3&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;	},&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;	&quot;ok&quot; : 1&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;}&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;In any event, if we want to be strict and still prohibit an lsid with an explicit unacknowledged write concern provided by the user, we&apos;re covered by &lt;tt&gt;mongoc_collection_find_and_modify_with_opts()&lt;/tt&gt; depending on &lt;tt&gt;mongoc_cmd_parts_append_opts()&lt;/tt&gt;, which in turn sets &lt;tt&gt;parts-&amp;gt;assembled.is_acknowledged&lt;/tt&gt;.&lt;/p&gt;

&lt;h4&gt;&lt;a name=&quot;mongoccursorruncommand&quot;&gt;&lt;/a&gt;_mongoc_cursor_run_command&lt;/h4&gt;

&lt;p&gt;This may be an edge case, but &lt;tt&gt;_mongoc_cursor_run_command()&lt;/tt&gt; &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/86264e652dc648ab8c3522c39f4d9f3160b6d3b5/src/mongoc/mongoc-cursor.c#L938&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;also has logic to append a write concern to &lt;tt&gt;parts.extra&lt;/tt&gt;&lt;/a&gt;. Since this bypasses &lt;tt&gt;mongoc_cmd_parts_append_opts()&lt;/tt&gt;, it&apos;s possible that &lt;tt&gt;parts-&amp;gt;assembled.is_acknowledged&lt;/tt&gt; may get out of sync. We should fix this to set &lt;tt&gt;parts-&amp;gt;assembled.is_acknowledged&lt;/tt&gt; according to the write concern being applied.&lt;/p&gt;

&lt;p&gt;Best I can tell, this code path is only relevant to &lt;tt&gt;mongoc_collection_command()&lt;/tt&gt;, &lt;tt&gt;mongoc_database_command()&lt;/tt&gt;, and &lt;tt&gt;mongoc_client_command()&lt;/tt&gt;. While these are old APIs (they return a cursor), none of these methods appear to be deprecated in the documentation.&lt;/p&gt;</comment>
                            <comment id="1869442" author="xgen-internal-githook" created="Thu, 19 Apr 2018 21:01:23 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jmikola@gmail.com&apos;, &apos;username&apos;: &apos;jmikola&apos;, &apos;name&apos;: &apos;Jeremy Mikola&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1163&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1163&quot;&gt;&lt;del&gt;PHPC-1163&lt;/del&gt;&lt;/a&gt;: Prohibit session with unacknowledged write concern&lt;/p&gt;

&lt;p&gt;This adds checks to ensure that explicit sessions and unacknowledged write concerns (explicit or inherited) will not be mixed when executing bulk writes or commands. Additionally, we ensure that command execution does not create its own implicit session (per &lt;a href=&quot;https://jira.mongodb.org/browse/PHPC-1152&quot; title=&quot;Aggregate may fail to use the same session for getMore commands&quot; class=&quot;issue-link&quot; data-issue-key=&quot;PHPC-1152&quot;&gt;&lt;del&gt;PHPC-1152&lt;/del&gt;&lt;/a&gt;) if the effective write concern is unacknowledged.&lt;/p&gt;

&lt;p&gt;Note: libmongoc still needs to ensure that it does not create implicit sessions for unacknowledged commands (&lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-2615&quot; title=&quot;Do not allow a session to be used with an unacknowledged write concern&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-2615&quot;&gt;&lt;del&gt;CDRIVER-2615&lt;/del&gt;&lt;/a&gt;).&lt;br/&gt;
Branch: 1.4-phpc-1163&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-php-driver/commit/393537d80fc3138977a42b4b703b8c859619c34d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-php-driver/commit/393537d80fc3138977a42b4b703b8c859619c34d&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1867208" author="jesse" created="Wed, 18 Apr 2018 02:43:48 +0000"  >&lt;p&gt;Thanks for the report. Right, if people call a function with &quot;command&quot; in the name and put the write concern in the command document, rather than in &quot;opts&quot; or some other sanctioned way of configuring it, we just pass the write concern to the server without any special treatment.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="500700">CXX-1518</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="500054">DRIVERS-456</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="500701">PHPC-1126</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="473898">CDRIVER-2432</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="529659">PHPC-1163</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="500054">DRIVERS-456</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <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|htmu67:</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>