mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-15 05:21:57 +00:00
fix off by 1 error in key sharding
This commit is contained in:
parent
31e1808dd8
commit
46b389e8b3
2 changed files with 7 additions and 2 deletions
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue