diff options
author | James Wahlin <james.wahlin@10gen.com> | 2017-05-02 16:29:57 -0400 |
---|---|---|
committer | James Wahlin <james.wahlin@10gen.com> | 2017-05-03 18:09:02 -0400 |
commit | e04553dcfaddad370baf02a53fe37381792a4760 (patch) | |
tree | e1121deb14d0670a8641e12c2890ac9fb7ddc255 | |
parent | 74a3cb1bc1faee3d1aae2b207e41502fb5c98150 (diff) | |
download | mongo-e04553dcfaddad370baf02a53fe37381792a4760.tar.gz |
SERVER-29018 Reject mongos getMore on view after batchSize 0 find
-rw-r--r-- | jstests/sharding/views.js | 13 | ||||
-rw-r--r-- | src/mongo/s/query/cluster_find.cpp | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/jstests/sharding/views.js b/jstests/sharding/views.js index 75a8eeda258..b7bc4fd3d40 100644 --- a/jstests/sharding/views.js +++ b/jstests/sharding/views.js @@ -82,5 +82,18 @@ assert.commandFailedWithCode(db.adminCommand({getShardVersion: view.getFullName()}), ErrorCodes.NamespaceNotSharded); + // + // Confirm find with batchSize 0 followed by getMore fails. + // This fails on getMore rather than on find due to SERVER-27286. + // + result = assert.commandWorked(db.runCommand({find: 'view', batchSize: 0})); + assert.commandWorked(result); + + const cursor = new DBCommandCursor(db.getMongo(), result, 2); + assert.commandFailedWithCode(assert.throws(() => { + cursor.next(); + }), + ErrorCodes.OptionNotSupportedOnView); + st.stop(); })(); diff --git a/src/mongo/s/query/cluster_find.cpp b/src/mongo/s/query/cluster_find.cpp index aa3b0f286e4..ac7711c0720 100644 --- a/src/mongo/s/query/cluster_find.cpp +++ b/src/mongo/s/query/cluster_find.cpp @@ -405,6 +405,15 @@ StatusWith<CursorResponse> ClusterFind::runGetMore(OperationContext* opCtx, break; } + // Due to SERVER-27286, a find command with batchSize:0 may not establish cursors on the + // targeted shards. Since only the shards have knowledge of the view catalog, we may not + // discover that this is a query over a view until getMore time. In this case we simply + // error, since the getMore path cannot handle views. + if (next.getValue().getViewDefinition()) { + return {ErrorCodes::OptionNotSupportedOnView, + "A find with batchSize 0 followed by a getMore is not supported on views"}; + } + if (!FindCommon::haveSpaceForNext( *next.getValue().getResult(), batch.size(), bytesBuffered)) { pinnedCursor.getValue().queueResult(*next.getValue().getResult()); |