diff --git a/services/real-time/app/js/DocumentUpdaterManager.js b/services/real-time/app/js/DocumentUpdaterManager.js index aacadd9391..0aa0d23466 100644 --- a/services/real-time/app/js/DocumentUpdaterManager.js +++ b/services/real-time/app/js/DocumentUpdaterManager.js @@ -89,7 +89,7 @@ const DocumentUpdaterManager = { }, _getPendingUpdateListKey() { - const shard = _.random(0, settings.pendingUpdateListShardCount) + const shard = _.random(0, settings.pendingUpdateListShardCount - 1) if (shard === 0) { return 'pending-updates-list' } else { diff --git a/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js b/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js index e3c108b824..2a5fdf530f 100644 --- a/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js +++ b/services/real-time/test/unit/js/DocumentUpdaterManagerTests.js @@ -407,16 +407,21 @@ describe('DocumentUpdaterManager', function () { this.keys = _.unique(keys) }) it('should return normal pending updates key', function () { - const key = this.DocumentUpdaterManager._getPendingUpdateListKey() _.contains(this.keys, 'pending-updates-list').should.equal(true) }) it('should return pending-updates-list-n keys', function () { _.contains(this.keys, 'pending-updates-list-1').should.equal(true) _.contains(this.keys, 'pending-updates-list-3').should.equal(true) + _.contains(this.keys, 'pending-updates-list-9').should.equal(true) }) + it('should not include pending-updates-list-0 key', function () { _.contains(this.keys, 'pending-updates-list-0').should.equal(false) }) + + it('should not include maximum as pendingUpdateListShardCount value', function () { + _.contains(this.keys, 'pending-updates-list-10').should.equal(false) + }) }) })