From a15e663f4c15613924c43e8380da654cf79eeb5c Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 8 Nov 2023 08:05:03 -0500 Subject: [PATCH 1/8] require not applying read and write concern --- source/index-management/index-management.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/index-management/index-management.rst b/source/index-management/index-management.rst index b92753d879..2df8fbed64 100644 --- a/source/index-management/index-management.rst +++ b/source/index-management/index-management.rst @@ -899,6 +899,8 @@ Where are read concern and write concern? These commands internally proxy the search index management commands to a separate process that runs alongside an Atlas cluster. As such, read concern and write concern are not relevant for the search index management commands. +Drivers MUST NOT apply a read concern or write concern to the commands. Atlas search index management commands return an error if a ``readConcern`` or ``writeConcern`` field is present in the command. + Consistency with Existing APIs ------------------------------ @@ -1136,4 +1138,4 @@ Changelog :2023-05-10: Merge index enumeration and index management specs and get rid of references to legacy server versions. :2023-05-18: Add the search index management API. -:2023-07-27: Add search index management clarifications. \ No newline at end of file +:2023-07-27: Add search index management clarifications. From b2b4ba3b57024ef1722368a71c6224ef45dec9ff Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 8 Nov 2023 08:06:46 -0500 Subject: [PATCH 2/8] add prose test with non-default read/write concern --- source/index-management/tests/README.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/index-management/tests/README.rst b/source/index-management/tests/README.rst index 090cda4be5..4925f65c3d 100644 --- a/source/index-management/tests/README.rst +++ b/source/index-management/tests/README.rst @@ -198,3 +198,26 @@ Case 5: ``dropSearchIndex`` suppresses namespace not found errors #. Create a driver-side collection object for a randomly generated collection name. Do not create this collection on the server. #. Run a ``dropSearchIndex`` command and assert that no error is thrown. + +Case 6: Driver can successfully create and list search indexes with non-default readConcern and writeConcern +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``). +#. Apply a write concern ``WriteConcern(w=1)`` and a read concern with ``ReadConcern(level="local")`` to ``coll0``. +#. Create a new search index on ``coll0`` with the ``createSearchIndex`` helper. Use the following definition: + + .. code:: typescript + + { + name: 'test-search-index-case6', + definition: { + mappings: { dynamic: false } + } + } + +#. Assert that the command returns the name of the index: ``"test-search-index-case6"``. +#. Run ``coll0.listSearchIndexes()`` repeatedly every 5 seconds until the following condition is satisfied and store the value in a variable ``index``: + + - An index with the ``name`` of ``test-search-index-case6`` is present and the index has a field ``queryable`` with a value of ``true``. + +#. Assert that ``index`` has a property ``latestDefinition`` whose value is ``{ 'mappings': { 'dynamic': false } }`` From 79fc889a6d452b1b44e74d8b34c45c92b8ae3588 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 8 Nov 2023 08:07:14 -0500 Subject: [PATCH 3/8] unit test each search index management command --- .../searchIndexIgnoresReadWriteConcern.json | 252 ++++++++++++++++++ .../searchIndexIgnoresReadWriteConcern.yml | 142 ++++++++++ 2 files changed, 394 insertions(+) create mode 100644 source/index-management/tests/searchIndexIgnoresReadWriteConcern.json create mode 100644 source/index-management/tests/searchIndexIgnoresReadWriteConcern.yml diff --git a/source/index-management/tests/searchIndexIgnoresReadWriteConcern.json b/source/index-management/tests/searchIndexIgnoresReadWriteConcern.json new file mode 100644 index 0000000000..5d36c7ccf3 --- /dev/null +++ b/source/index-management/tests/searchIndexIgnoresReadWriteConcern.json @@ -0,0 +1,252 @@ +{ + "description": "search index operations ignore read and write concern", + "schemaVersion": "1.4", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "uriOptions": { + "readConcernLevel": "local", + "w": 1 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "database0" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "collection0" + } + } + ], + "runOnRequirements": [ + { + "minServerVersion": "7.0.0", + "topologies": [ + "replicaset", + "load-balanced", + "sharded" + ], + "serverless": "forbid" + } + ], + "tests": [ + { + "description": "createSearchIndex ignores read and write concern", + "operations": [ + { + "name": "createSearchIndex", + "object": "collection0", + "arguments": { + "model": { + "definition": { + "mappings": { + "dynamic": true + } + } + } + }, + "expectError": { + "isError": true, + "errorContains": "Search index commands are only supported with Atlas" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "createSearchIndexes": "collection0", + "indexes": [ + { + "definition": { + "mappings": { + "dynamic": true + } + } + } + ], + "$db": "database0", + "writeConcern": { + "$$exists": false + }, + "readConcern": { + "$$exists": false + } + } + } + } + ] + } + ] + }, + { + "description": "createSearchIndex ignores read and write concern", + "operations": [ + { + "name": "createSearchIndexes", + "object": "collection0", + "arguments": { + "models": [] + }, + "expectError": { + "isError": true, + "errorContains": "Search index commands are only supported with Atlas" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "createSearchIndexes": "collection0", + "indexes": [], + "$db": "database0", + "writeConcern": { + "$$exists": false + }, + "readConcern": { + "$$exists": false + } + } + } + } + ] + } + ] + }, + { + "description": "dropSearchIndex ignores read and write concern", + "operations": [ + { + "name": "dropSearchIndex", + "object": "collection0", + "arguments": { + "name": "test index" + }, + "expectError": { + "isError": true, + "errorContains": "Search index commands are only supported with Atlas" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "dropSearchIndex": "collection0", + "name": "test index", + "$db": "database0", + "writeConcern": { + "$$exists": false + }, + "readConcern": { + "$$exists": false + } + } + } + } + ] + } + ] + }, + { + "description": "listSearchIndexes ignores read and write concern", + "operations": [ + { + "name": "listSearchIndexes", + "object": "collection0", + "expectError": { + "isError": true, + "errorContains": "Search index commands are only supported with Atlas" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "collection0", + "pipeline": [ + { + "$listSearchIndexes": {} + } + ], + "writeConcern": { + "$$exists": false + }, + "readConcern": { + "$$exists": false + } + } + } + } + ] + } + ] + }, + { + "description": "updateSearchIndex ignores the read and write concern", + "operations": [ + { + "name": "updateSearchIndex", + "object": "collection0", + "arguments": { + "name": "test index", + "definition": {} + }, + "expectError": { + "isError": true, + "errorContains": "Search index commands are only supported with Atlas" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "updateSearchIndex": "collection0", + "name": "test index", + "definition": {}, + "$db": "database0", + "writeConcern": { + "$$exists": false + }, + "readConcern": { + "$$exists": false + } + } + } + } + ] + } + ] + } + ] +} diff --git a/source/index-management/tests/searchIndexIgnoresReadWriteConcern.yml b/source/index-management/tests/searchIndexIgnoresReadWriteConcern.yml new file mode 100644 index 0000000000..8a1495b29e --- /dev/null +++ b/source/index-management/tests/searchIndexIgnoresReadWriteConcern.yml @@ -0,0 +1,142 @@ +description: "search index operations ignore read and write concern" +schemaVersion: "1.4" +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + # Set a non-default read and write concern. + uriOptions: + readConcernLevel: local + w: 1 + observeEvents: + - commandStartedEvent + - database: + id: &database0 database0 + client: *client0 + databaseName: *database0 + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: *collection0 + +runOnRequirements: + - minServerVersion: "7.0.0" + topologies: [ replicaset, load-balanced, sharded ] + serverless: forbid + +tests: + - description: "createSearchIndex ignores read and write concern" + operations: + - name: createSearchIndex + object: *collection0 + arguments: + model: { definition: &definition { mappings: { dynamic: true } } } + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + isError: true + errorContains: Search index commands are only supported with Atlas + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + createSearchIndexes: *collection0 + indexes: [ { definition: *definition } ] + $db: *database0 + # Expect no writeConcern or readConcern to be sent. + writeConcern: { $$exists: false } + readConcern: { $$exists: false } + + - description: "createSearchIndex ignores read and write concern" + operations: + - name: createSearchIndexes + object: *collection0 + arguments: + models: [] + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + isError: true + errorContains: Search index commands are only supported with Atlas + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + createSearchIndexes: *collection0 + indexes: [] + $db: *database0 + # Expect no writeConcern or readConcern to be sent. + writeConcern: { $$exists: false } + readConcern: { $$exists: false } + + - description: "dropSearchIndex ignores read and write concern" + operations: + - name: dropSearchIndex + object: *collection0 + arguments: + name: &indexName 'test index' + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + isError: true + errorContains: Search index commands are only supported with Atlas + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + dropSearchIndex: *collection0 + name: *indexName + $db: *database0 + # Expect no writeConcern or readConcern to be sent. + writeConcern: { $$exists: false } + readConcern: { $$exists: false } + + - description: "listSearchIndexes ignores read and write concern" + operations: + - name: listSearchIndexes + object: *collection0 + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + isError: true + errorContains: Search index commands are only supported with Atlas + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + aggregate: *collection0 + pipeline: + - $listSearchIndexes: {} + # Expect no writeConcern or readConcern to be sent. + writeConcern: { $$exists: false } + readConcern: { $$exists: false } + + - description: "updateSearchIndex ignores the read and write concern" + operations: + - name: updateSearchIndex + object: *collection0 + arguments: + name: &indexName 'test index' + definition: &definition {} + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + isError: true + errorContains: Search index commands are only supported with Atlas + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + updateSearchIndex: *collection0 + name: *indexName + definition: *definition + $db: *database0 + # Expect no writeConcern or readConcern to be sent. + writeConcern: { $$exists: false } + readConcern: { $$exists: false } + From 67aab69c3293a0bf2bf03e48908877fff67b4b09 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Wed, 8 Nov 2023 08:26:26 -0500 Subject: [PATCH 4/8] update changelog --- source/index-management/index-management.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/index-management/index-management.rst b/source/index-management/index-management.rst index 2df8fbed64..08d58c4799 100644 --- a/source/index-management/index-management.rst +++ b/source/index-management/index-management.rst @@ -1139,3 +1139,5 @@ Changelog to legacy server versions. :2023-05-18: Add the search index management API. :2023-07-27: Add search index management clarifications. +:2023-11-08: Clarify that ``readConcern`` and ``writeConcern`` must not be + applied to search index managment commands. From c32ec27babd9b8cc6e444be4a77bf81be7267374 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 11 Dec 2023 13:22:04 -0500 Subject: [PATCH 5/8] Add empty line. Remove double spaces. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérôme Tamarelle --- source/index-management/index-management.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/index-management/index-management.rst b/source/index-management/index-management.rst index 08d58c4799..0701b4c409 100644 --- a/source/index-management/index-management.rst +++ b/source/index-management/index-management.rst @@ -1138,6 +1138,7 @@ Changelog :2023-05-10: Merge index enumeration and index management specs and get rid of references to legacy server versions. :2023-05-18: Add the search index management API. -:2023-07-27: Add search index management clarifications. +:2023-07-27: Add search index management clarifications. :2023-11-08: Clarify that ``readConcern`` and ``writeConcern`` must not be applied to search index managment commands. + From 038d468ca2c1747e5f3f08df499da7f170b770da Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 11 Dec 2023 13:23:24 -0500 Subject: [PATCH 6/8] Remove double spaces --- source/index-management/index-management.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/index-management/index-management.rst b/source/index-management/index-management.rst index 0701b4c409..fbf19d5471 100644 --- a/source/index-management/index-management.rst +++ b/source/index-management/index-management.rst @@ -1137,7 +1137,7 @@ Changelog :2022-10-05: Remove spec front matter and reformat changelog. :2023-05-10: Merge index enumeration and index management specs and get rid of references to legacy server versions. -:2023-05-18: Add the search index management API. +:2023-05-18: Add the search index management API. :2023-07-27: Add search index management clarifications. :2023-11-08: Clarify that ``readConcern`` and ``writeConcern`` must not be applied to search index managment commands. From 2a98a6535f93852467c48fea9b4febd7c8c0eaeb Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 11 Dec 2023 13:25:28 -0500 Subject: [PATCH 7/8] fix sphinx warning: "Title underline too short" --- .../command-logging-and-monitoring.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/command-logging-and-monitoring/command-logging-and-monitoring.rst b/source/command-logging-and-monitoring/command-logging-and-monitoring.rst index 78f4b21226..dafbe9028d 100644 --- a/source/command-logging-and-monitoring/command-logging-and-monitoring.rst +++ b/source/command-logging-and-monitoring/command-logging-and-monitoring.rst @@ -80,7 +80,7 @@ Unacknowledged/Acknowledged Writes A non-default write concern MUST be included in the published command. The default write concern is not required to be included. Succeeded or Failed -^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^ Commands that executed on the server and return a status of ``{ ok: 1.0 }`` are considered successful commands and MUST generate a ``CommandSucceededEvent`` and "command succeeded" log message. From 5198c04a8776bf10c0cdbaff646ea7d163df5bc5 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Tue, 12 Dec 2023 11:51:50 -0500 Subject: [PATCH 8/8] use "majority" in prose test Aggregate with $listSearchIndexes accepts a `local` read concern. Use `majority` to ensure test fails if driver incorrectly applies read concern. --- source/index-management/tests/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/index-management/tests/README.rst b/source/index-management/tests/README.rst index 4925f65c3d..2840d98836 100644 --- a/source/index-management/tests/README.rst +++ b/source/index-management/tests/README.rst @@ -203,7 +203,7 @@ Case 6: Driver can successfully create and list search indexes with non-default ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #. Create a collection with the "create" command using a randomly generated name (referred to as ``coll0``). -#. Apply a write concern ``WriteConcern(w=1)`` and a read concern with ``ReadConcern(level="local")`` to ``coll0``. +#. Apply a write concern ``WriteConcern(w=1)`` and a read concern with ``ReadConcern(level="majority")`` to ``coll0``. #. Create a new search index on ``coll0`` with the ``createSearchIndex`` helper. Use the following definition: .. code:: typescript