mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
fix off by 1 error in key sharding
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user