26 — NamespaceNotFound

queryconfiguration

The target collection or namespace does not exist

What is happening?

NamespaceNotFound is returned when an operation targets a collection or database that does not exist. MongoDB normally creates collections implicitly on first write, so this error typically appears with operations that require the collection to already exist, such as creating an index on a non-existent collection or running certain administrative commands.

Common causes

  1. Running a command against a collection that was dropped
  2. Typo in the collection or database name
  3. Attempting to create an index before the collection exists
  4. Application code referencing a collection name that differs from the actual collection
  5. The collection exists in a different database

Diagnostic Steps

Related Issues

SERVER-136637Closed
Tolerate collection drop races in CheckMultikeyConsistencyInBackground hook
## Description `CheckMultikeyConsistencyInBackground` failed in BF-46711 (`disagg_concurrency_replication_high_yielding`): the workload under test intentionally drops and re-creates its pool collections, and one such drop raced the hook's doc-sampling read. In `assertWildcardMultikeyConsistent` (`jstests/hooks/run_check_multikey_consistency.js:144`), the `findOne({}, {_id: 0})` used to sample a document only tolerated `NamespaceNotFound`. A drop that lands \*while the read is running\* kills t
SERVER-139350In Code Review
Search index commands on mongos ignore {ok: 0} replies from the primary shard when resolving the target namespace
In search_index_process_router.cpp, fetchCollectionUUIDAndResolveView and resolveViewHelper only check the transport status of the listCollections and _shardsvrResolveView replies, not the command status. As a result, a failed listCollections surfaces as a "wrong type for field" error instead of the shard's error, and a failed _shardsvrResolveView makes a view look like a missing collection (NamespaceNotFound). We should check both replies with AsyncRequestsSender::Response::getEffectiveStat
SERVER-134745Closed
Sharded local change-stream updateLookup fails getMore with NamespaceNotFound when the database was dropped, instead of a null fullDocument
h3. Summary On a sharded cluster, a cluster-wide change stream with {{fullDocument: "updateLookup"}} aborts a {{getMore}} with {{NamespaceNotFound}} (26) when an {{update}}/{{replace}} event's database has been dropped before the stream reads that event: The expected result is a null {{fullDocument}}. This is explicitly the intended behavior per SERVER-129059's own acceptance criteria, which state: "keep {{NamespaceNotFound}} and {{CollectionUUIDMismatch}} mapping to a null fullDocument". T
NODE-6517Closed
dropIndexes swallows all errors to and returns false
h3. Use Case As a... driver user I want... important errors to be surfaced from dropIndexes So that... I am alerted if something unexpected happens while using this API [https://github.com/mongodb/specifications/blob/master/source/index-management/index-management.md#namespacenotfound-errors] h3. User Experience * What is the desired/expected outcome for the user once this ticket is implemented? ** If the operation succeeds, resolve true. If the operation fails due to name space not
SERVER-138607Closed
Ensure FSM tests using renameCollection handle non-idempotency after failover
*Issue* renameCollection is not idempotent, so if it is retried after a failover (stepdown/kill/retry), the retry can fail with a NamespaceNotFound error. So rename tests must either: * Be excluded from stepdown suites, or * Gracefully accept the NamespaceNotFound.   Some of our tests in jstests/concurrency do not follow this pattern (rather are only incidentally excluded for other reasons), so when new suites are added they start failing. Some failures have been recently uncover