[SERVER-27030] Improve the error message when issuing a legacy find/getMore on a view Created: 14/Nov/16  Updated: 19/Nov/16  Resolved: 16/Nov/16

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.4.0-rc3
Fix Version/s: 3.4.0-rc4

Type: Bug Priority: Major - P3
Reporter: Craig Wilson Assignee: James Wahlin
Resolution: Done Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by SERVER-27034 views_legacy.js should test OP_GET_MO... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query 2016-11-21
Participants:

 Description   

When performing a legacy find, getMore or killCursors on a view, users get the error message "Namespace <view> is a view, not a collection". For example, in the shell,

> db.getMongo().forceReadMode("legacy");
> db.view.find().toArray();
2016-11-14T18:52:32.559-0500 E QUERY    [main] Error: error: { "$err" : "Namespace test.view is a view, not a collection", "code" : 166 } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBQuery.prototype.next@src/mongo/shell/query.js:309:1
DBQuery.prototype.toArray@src/mongo/shell/query.js:338:16
@(shell):1:1

This is rather unhelpful from a user's standpoint. We should consider making this error more user-friendly and explicitly state that legacy find and getMore is not supported on a view.



 Comments   
Comment by Githook User [ 16/Nov/16 ]

Author:

{u'username': u'jameswahlin', u'name': u'James Wahlin', u'email': u'james.wahlin@10gen.com'}

Message: SERVER-27030 Improve error for legacy find/getMore on view
Branch: master
https://github.com/mongodb/mongo/commit/ed347a4f92a3388ab0f690502a81132577361623

Comment by James Wahlin [ 15/Nov/16 ]

Legacy OP_KILL_CURSORS will work against a cursor established on a view.

We store the underlying collection namespace in the cursor manager. As the legacy kill operation takes only a cursorId, it will map this ID correctly and kill the cursor.

For the kill cursors command we take a cursorId and the view namespace. This code path has logic to convert the view namespace to the underlying collection namespace so that the requested namespace matches that in the cursor manager.

Given the above no work is needed for killcursors. This ticket will improve the error message returned for legacy find and getMore.

Comment by J Rassi [ 15/Nov/16 ]

Note that users may get the false impression that they are able to use old drivers (without MongoDB 3.2 support) with views, since aggregation operations against views with these drivers will succeed as long as their results fit within a single batch (101 results or 16MB, by default). Once they run an aggregation operation where the results exceed a single batch, though (for example, when moving from testing to production), an error will be returned, since the driver will send an incompatible OP_GET_MORE request to fetch the remaining results.

Comment by Kyle Suarez [ 14/Nov/16 ]

Re-opening this issue to work it into a ticket that improves the error message when running a legacy find or getMore on a view.

Comment by Bernie Hackett [ 14/Nov/16 ]

I guess this means to interact with views a driver has to have explicit support for >= MongoDB 3.2?

Comment by Kyle Suarez [ 14/Nov/16 ]

This behavior is intended. Per an off-ticket conversation with craiggwilson, the Find/GetMore/KillCursors Drivers Spec mentions that

The CRUD API MUST be implemented using the find, getMore and optionally killCursors commands if the isMaster command returns maxWireVersion >= 4.

So, spec-compliant drivers shouldn't be issuing OP_GETMORE for CRUD operations on a version of MongoDB that supports read-only views. I'm therefore closing this ticket as Won't Fix.

Generated at Thu Feb 08 04:13:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.