From 93a2a796998030b6b5035f353f6d3b95f266f0d1 Mon Sep 17 00:00:00 2001 From: Alexander Chan Date: Fri, 4 May 2018 12:36:59 -0700 Subject: [PATCH] bf: remove mongo cursor limit removed the mongo cursor hard coded limit as that introduced undesired behavior with small max-keys --- lib/algos/list/delimiter.js | 5 +---- lib/storage/metadata/mongoclient/readStream.js | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/algos/list/delimiter.js b/lib/algos/list/delimiter.js index 9dee791cd..39b0fdf36 100644 --- a/lib/algos/list/delimiter.js +++ b/lib/algos/list/delimiter.js @@ -1,9 +1,7 @@ 'use strict'; // eslint-disable-line strict const Extension = require('./Extension').default; -const { checkLimit, inc, FILTER_END, FILTER_ACCEPT, FILTER_SKIP } = - require('./tools'); -const MAX_KEYS_HARDLIMIT = 10000; +const { inc, FILTER_END, FILTER_ACCEPT, FILTER_SKIP } = require('./tools'); /** * Find the next delimiter in the path @@ -64,7 +62,6 @@ class Delimiter extends Extension { this.prefix = parameters.prefix; this.marker = parameters.marker; this.maxKeys = parameters.maxKeys || 1000; - this.maxKeys = checkLimit(this.maxKeys, MAX_KEYS_HARDLIMIT); this.alphabeticalOrder = typeof parameters.alphabeticalOrder !== 'undefined' ? parameters.alphabeticalOrder : true; diff --git a/lib/storage/metadata/mongoclient/readStream.js b/lib/storage/metadata/mongoclient/readStream.js index 9699d1486..8f5e7fd92 100644 --- a/lib/storage/metadata/mongoclient/readStream.js +++ b/lib/storage/metadata/mongoclient/readStream.js @@ -1,6 +1,5 @@ const Readable = require('stream').Readable; const MongoUtils = require('./utils'); -const MAX_KEYS_HARDLIMIT = 10000; class MongoReadStream extends Readable { constructor(c, options, searchOptions) { @@ -67,7 +66,9 @@ class MongoReadStream extends Readable { this._cursor = c.find(query).sort({ _id: options.reverse ? -1 : 1, }); - this._cursor = this._cursor.limit(MAX_KEYS_HARDLIMIT); + if (options.limit && options.limit !== -1) { + this._cursor = this._cursor.limit(options.limit); + } this._options = options; this._destroyed = false; this.on('end', this._cleanup.bind(this));