diff --git a/services/clsi/app/js/LockManager.js b/services/clsi/app/js/LockManager.js index 653691f7e8..a44810fe2e 100644 --- a/services/clsi/app/js/LockManager.js +++ b/services/clsi/app/js/LockManager.js @@ -10,7 +10,7 @@ const LOCK_TIMEOUT_MS = RequestParser.MAX_TIMEOUT * 1000 + 120000 const LOCKS = new Map() -function acquire(key, concurrencyLimitDryRun = true) { +function acquire(key) { const currentLock = LOCKS.get(key) if (currentLock != null) { if (currentLock.isExpired()) { @@ -21,14 +21,14 @@ function acquire(key, concurrencyLimitDryRun = true) { } } - checkConcurrencyLimit(concurrencyLimitDryRun) + checkConcurrencyLimit() const lock = new Lock(key) LOCKS.set(key, lock) return lock } -function checkConcurrencyLimit(dryRun) { +function checkConcurrencyLimit() { Metrics.gauge('concurrent_compile_requests', LOCKS.size) if (LOCKS.size <= Settings.compileConcurrencyLimit) { @@ -37,11 +37,9 @@ function checkConcurrencyLimit(dryRun) { Metrics.inc('exceeded-compilier-concurrency-limit') - if (!dryRun) { - throw new Errors.TooManyCompileRequestsError( - 'too many concurrent compile requests' - ) - } + throw new Errors.TooManyCompileRequestsError( + 'too many concurrent compile requests' + ) } class Lock { diff --git a/services/clsi/test/unit/js/LockManagerTests.js b/services/clsi/test/unit/js/LockManagerTests.js index 6048044912..cd0d34cd4a 100644 --- a/services/clsi/test/unit/js/LockManagerTests.js +++ b/services/clsi/test/unit/js/LockManagerTests.js @@ -75,24 +75,9 @@ describe('LockManager', function () { }) describe('concurrency limit', function () { - it('dry run', function () { - for (let i = 0; i <= this.Settings.compileConcurrencyLimit; i++) { - this.LockManager.acquire('test_key' + i) - } - this.Metrics.inc - .calledWith('exceeded-compilier-concurrency-limit') - .should.equal(false) - this.LockManager.acquire( - 'test_key_' + (this.Settings.compileConcurrencyLimit + 1) - ) - this.Metrics.inc - .calledWith('exceeded-compilier-concurrency-limit') - .should.equal(true) - }) - it('exceeding the limit', function () { for (let i = 0; i <= this.Settings.compileConcurrencyLimit; i++) { - this.LockManager.acquire('test_key' + i, false) + this.LockManager.acquire('test_key' + i) } this.Metrics.inc .calledWith('exceeded-compilier-concurrency-limit') @@ -111,7 +96,7 @@ describe('LockManager', function () { it('within the limit', function () { for (let i = 0; i <= this.Settings.compileConcurrencyLimit - 1; i++) { - this.LockManager.acquire('test_key' + i, false) + this.LockManager.acquire('test_key' + i) } this.Metrics.inc .calledWith('exceeded-compilier-concurrency-limit')