When renaming a collection to a target that already exists (without specifying dropTarget) renameCollection will fail with the following:
- errmsg: "target namespace exists"
- code: 48
- codeName: "NamespaceExists"
This corresponds to a documented error code: NamespaceExists(48) (message: "target namespace exists").
On mongos, the command responds is more cryptic:
- errmsg: "Target collection %s exists but dropTarget is not set"
- code: 5807601
- codeName: "Location5807601"
This error code originates from checkShardedRenamePreconditions.
Is it intentional for these errors to be inconsistent?
Note: This was tested on 5.0.x, but I presume the inconsistency goes back to older server versions.