Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
use only one queue and set concurrency to 5
Thiago Araujo da Silva59631f0da71c
diff --git a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-queue.ts b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-queue.tsindex 7f1ee314cb..eb3d0c07a3 100644--- a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-queue.ts+++ b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-queue.ts@@ -5,6 +5,8 @@ import { QueueName, TQueueServiceFactory } from "@app/queue";import { LogProvider } from "../audit-log-stream/audit-log-stream-enums";import { TAuditLogStreamOutboxServiceFactory } from "./audit-log-stream-outbox-service";+const OUTBOX_WORKER_CONCURRENCY = 5;+// Sweeper cadence. Runs every 5 min — comfortably tighter than the 10-minute// stale-claim threshold so a stuck worker is recovered within ~15 min worst case.const STALE_CLAIM_SWEEPER_CRON = "*/5 * * * *";@@ -29,16 +31,15 @@ export type TAuditLogStreamOutboxQueueDep = {>;};-// Boots one BullMQ worker per provider so a slow upstream (e.g. a wedged-// Splunk HEC) can't block deliveries to a healthy one (e.g. Datadog).export const auditLogStreamOutboxQueueFactory = ({queueService,cronJob,auditLogStreamOutboxService}: TAuditLogStreamOutboxQueueDep) => {- const registerWorker = <T extends QueueName>(queueName: T, provider: LogProvider) => {- queueService.start(queueName, async (job) => {- const { streamId, orgId } = job.data as { streamId: string; orgId: string };+ queueService.start(+ QueueName.AuditLogStreamOutbox,+ async (job) => {+ const { streamId, orgId, provider } = job.data as { streamId: string; orgId: string; provider: LogProvider };try {await auditLogStreamOutboxService.drainStream({ streamId, orgId, provider });} catch (error) {@@ -48,14 +49,9 @@ export const auditLogStreamOutboxQueueFactory = ({);throw error;}- });- };-- registerWorker(QueueName.AuditLogStreamAzure, LogProvider.Azure);- registerWorker(QueueName.AuditLogStreamCribl, LogProvider.Cribl);- registerWorker(QueueName.AuditLogStreamCustom, LogProvider.Custom);- registerWorker(QueueName.AuditLogStreamDatadog, LogProvider.Datadog);- registerWorker(QueueName.AuditLogStreamSplunk, LogProvider.Splunk);+ },+ { concurrency: OUTBOX_WORKER_CONCURRENCY }+ );const init = () => {cronJob.register({diff --git a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.tsindex 9296c38d89..c125d6e778 100644--- a/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts+++ b/backend/src/ee/services/audit-log-stream-outbox/audit-log-stream-outbox-service.ts@@ -54,14 +54,6 @@ export const DELIVERED_RETENTION_MS = 15 * 60_000;// without bound. Same cron prunes these alongside delivered rows.export const DLQ_RETENTION_MS = 12 * 60 * 60_000;-const PROVIDER_QUEUE_MAP: Record<LogProvider, QueueName> = {- [LogProvider.Azure]: QueueName.AuditLogStreamAzure,- [LogProvider.Cribl]: QueueName.AuditLogStreamCribl,- [LogProvider.Custom]: QueueName.AuditLogStreamCustom,- [LogProvider.Datadog]: QueueName.AuditLogStreamDatadog,- [LogProvider.Splunk]: QueueName.AuditLogStreamSplunk-};-const computeBackoffMs = (attemptsAfterIncrement: number): number => {const exponent = Math.min(attemptsAfterIncrement - 1, 10);const base = BACKOFF_BASE_MS * 2 ** exponent;@@ -93,24 +85,17 @@ export const auditLogStreamOutboxServiceFactory = ({queueService}: TAuditLogStreamOutboxServiceFactoryDep): TAuditLogStreamOutboxServiceFactory => {// Try to win the 5s SETNX debounce for a stream and, on win, enqueue a delayed- // flush job on the matching per-provider queue. Returning false means another- // writer already covered the window — there's nothing for the caller to do.+ // flush job on the shared outbox queue (provider is carried in the payload and read+ // back by the worker). Returning false means another writer already covered the+ // window — there's nothing for the caller to do.const debounceAndEnqueueFlush = async (streamId: string, orgId: string, provider: LogProvider): Promise<boolean> => {- const queueName = PROVIDER_QUEUE_MAP[provider];- if (!queueName) {- logger.warn(- `audit-log-stream-outbox: unknown provider, skipping flush enqueue [provider=${provider}] [streamId=${streamId}]`- );- return false;- }-const debounceKey = KeyStorePrefixes.AuditLogStreamFlushDebounce(streamId);const acquired = await keyStore.setItemWithExpiryNX(debounceKey, FLUSH_DEBOUNCE_SECONDS, "1");if (!acquired) return false;try {await queueService.queue(- queueName,+ QueueName.AuditLogStreamOutbox,QueueJobs.AuditLogStreamFlush,{ streamId, orgId, provider },{@@ -123,7 +108,7 @@ export const auditLogStreamOutboxServiceFactory = ({} catch (error) {logger.error(error,- `audit-log-stream-outbox: failed to enqueue flush job [provider=${provider}] [queue=${queueName}] [streamId=${streamId}] [orgId=${orgId}]`+ `audit-log-stream-outbox: failed to enqueue flush job [provider=${provider}] [streamId=${streamId}] [orgId=${orgId}]`);return false;}diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.tsindex 4315f4882b..4e603aeae3 100644--- a/backend/src/queue/queue-service.ts+++ b/backend/src/queue/queue-service.ts@@ -109,13 +109,7 @@ export enum QueueName {AppConnectionCredentialRotation = "app-connection-credential-rotation",AppConnectionCredentialRotationRotate = "app-connection-credential-rotation-rotate",AuditLogClickHouseBatch = "audit-log-clickhouse-batch",- // One queue per provider so a slow Splunk endpoint can't starve fast Datadog flushes (and vice versa).- // BullMQ disallows ':' in queue names, so use '-' as the separator.- AuditLogStreamAzure = "audit-stream-azure",- AuditLogStreamCribl = "audit-stream-cribl",- AuditLogStreamCustom = "audit-stream-custom",- AuditLogStreamDatadog = "audit-stream-datadog",- AuditLogStreamSplunk = "audit-stream-splunk",+ AuditLogStreamOutbox = "audit-log-stream-outbox",PamDiscoveryScan = "pam-discovery-scan",CaAutoRenewal = "ca-auto-renewal",ProjectHardDelete = "project-hard-delete",@@ -487,23 +481,7 @@ export type TQueueJobTypes = {name: QueueJobs.AuditLogClickHouseBatch;payload: undefined;};- [QueueName.AuditLogStreamAzure]: {- name: QueueJobs.AuditLogStreamFlush;- payload: TAuditLogStreamFlushJobData;- };- [QueueName.AuditLogStreamCribl]: {- name: QueueJobs.AuditLogStreamFlush;- payload: TAuditLogStreamFlushJobData;- };- [QueueName.AuditLogStreamCustom]: {- name: QueueJobs.AuditLogStreamFlush;- payload: TAuditLogStreamFlushJobData;- };- [QueueName.AuditLogStreamDatadog]: {- name: QueueJobs.AuditLogStreamFlush;- payload: TAuditLogStreamFlushJobData;- };- [QueueName.AuditLogStreamSplunk]: {+ [QueueName.AuditLogStreamOutbox]: {name: QueueJobs.AuditLogStreamFlush;payload: TAuditLogStreamFlushJobData;};