{"record":{"id":"5157aa110ef7596a","repo":"xai-org/x-algorithm","slug":"maximum-pending-requests-reached","errorCode":null,"errorMessage":"maximum pending requests reached","messagePattern":"maximum pending requests reached","errorType":"exception","errorClass":"RegexThrottledFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/scala/com/twitter/botmaker/runtime/RegexOptions.scala","lineNumber":65,"sourceCode":"    .expireAfterAccess(config.cacheExpirationMillis, TimeUnit.MILLISECONDS)\n    .build(new CacheLoader[Pair[String, Integer], Try[Pattern]]() {\n      override def load(key: Pair[String, Integer]): Try[Pattern] = {\n        cacheMissesCounter.incr()\n        Try {\n          Pattern.compile(key.getFirst, key.getSecond)\n        }\n      }\n    })\n\n  private[this] val regexCache = RegexCache.of(config.timeoutMilis.toInt, patterns)\n\n  private def apply[T](call: => T): T = {\n\n    requestsCounter.incr()\n\n    if (pendingRequests.get >= config.maximumPendingRequests) {\n      skippedRequestsCounter.incr()\n      throw RegexThrottledFailure(\"maximum pending requests reached\")\n    }\n\n    val startTime = runtime.clock.nowMillis\n\n    try {\n      pendingRequests.incrementAndGet\n      call\n    } catch {\n      case t: RegexTimeoutException =>\n        runtime.logger.warning(\"RegexTimeout\", t.toString)\n        timeoutRequestsCounter.incr()\n        throw t\n      case t: Throwable =>\n        runtime.logger.warning(\"RegexError\", t.toString)\n        errorRequestsCounter.incr()\n        throw t\n    } finally {\n      pendingRequests.decrementAndGet","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/scala/com/twitter/botmaker/runtime/RegexOptions.scala#L47-L83","documentation":"RegexThrottledFailure thrown by RegexOptions.apply as admission control: when the number of in-flight regex requests (pendingRequests) is already at config.maximumPendingRequests, new calls are rejected immediately rather than queued.","triggerScenarios":"Concurrency of concurrent regex feature evaluations reaching maximumPendingRequests — e.g. a traffic spike, a slow downstream regex service raising latency (requests linger), or maximumPendingRequests configured too low.","commonSituations":"Peak traffic with tight throttle limits; downstream regex matcher latency regression causing pending count to accumulate; replaying heavy traffic during incident response.","solutions":["If throttling is expected under load, callers should shed load / back off and retry — this is by design","Investigate why pending requests are high (downstream latency) before raising limits","Increase maximumPendingRequests in RegexConfigs if the service has headroom","Add rate limiting upstream so requests fail fast before hitting this guard"],"exampleFix":"# before\nmaximum_pending_requests: 10\n# after (only if capacity allows)\nmaximum_pending_requests: 100","handlingStrategy":"retry","validationCode":"// pre-call: check gauge of pendingRequests vs maximumPendingRequests and shed load early","typeGuard":null,"tryCatchPattern":"try regexOptions.apply(call)\ncatch { case e: RegexThrottledFailure => backoff and retry with jitter; drop if repeated }","preventionTips":["Add upstream rate limiting matched to maximumPendingRequests","Alert on pendingRequests approaching the limit","Size maximumPendingRequests from latency x target QPS"],"tags":["throttling","backpressure","scala","rate-limit"],"backgroundTag":"request-throttled","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}