remove dry run (#19820)

GitOrigin-RevId: b92e08da6654cdd37314f7c52a6946cc7ec8983a
This commit is contained in:
Liangjun Song 2024-08-07 11:21:10 +02:00 committed by Copybot
parent 901d79dd55
commit 2133dde8bf
2 changed files with 8 additions and 25 deletions

View file

@ -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 {

View file

@ -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')