diff --git a/CHANGELOG.md b/CHANGELOG.md index f1f9e7679..04978e179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Added `maxAccountPermissionSyncJobConcurrency` and `maxRepoPermissionSyncJobConcurrency` settings to configure concurrency for permission sync jobs (default: 8). [#840](https://github.com/sourcebot-dev/sourcebot/pull/840) + ## [4.10.21] - 2026-02-02 ### Added diff --git a/docs/docs/configuration/config-file.mdx b/docs/docs/configuration/config-file.mdx index 9985e4578..b447a5abf 100644 --- a/docs/docs/configuration/config-file.mdx +++ b/docs/docs/configuration/config-file.mdx @@ -52,6 +52,8 @@ The following are settings that can be provided in your config file to modify So | `enablePublicAccess` **(deprecated)** | boolean | false | — | Use the `FORCE_ENABLE_ANONYMOUS_ACCESS` environment variable instead. | | `experiment_repoDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the repo permission syncer should run. | | `experiment_userDrivenPermissionSyncIntervalMs` | number | 24 hours | 1 | Interval at which the user permission syncer should run. | +| `maxAccountPermissionSyncJobConcurrency` | number | 8 | 1 | Concurrent account permission sync jobs. | +| `maxRepoPermissionSyncJobConcurrency` | number | 8 | 1 | Concurrent repo permission sync jobs. | # Tokens diff --git a/docs/snippets/schemas/v3/index.schema.mdx b/docs/snippets/schemas/v3/index.schema.mdx index f3da7ed42..eaa5c2039 100644 --- a/docs/snippets/schemas/v3/index.schema.mdx +++ b/docs/snippets/schemas/v3/index.schema.mdx @@ -79,6 +79,16 @@ "type": "number", "description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.", "minimum": 1 + }, + "maxAccountPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of account permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 + }, + "maxRepoPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of repo permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 } }, "additionalProperties": false @@ -215,6 +225,16 @@ "type": "number", "description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.", "minimum": 1 + }, + "maxAccountPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of account permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 + }, + "maxRepoPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of repo permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 } }, "additionalProperties": false diff --git a/packages/backend/src/ee/accountPermissionSyncer.ts b/packages/backend/src/ee/accountPermissionSyncer.ts index 60e27a178..805cc1756 100644 --- a/packages/backend/src/ee/accountPermissionSyncer.ts +++ b/packages/backend/src/ee/accountPermissionSyncer.ts @@ -42,7 +42,7 @@ export class AccountPermissionSyncer { }); this.worker = new Worker(QUEUE_NAME, this.runJob.bind(this), { connection: redis, - concurrency: 1, + concurrency: this.settings.maxAccountPermissionSyncJobConcurrency, }); this.worker.on('completed', this.onJobCompleted.bind(this)); this.worker.on('failed', this.onJobFailed.bind(this)); diff --git a/packages/backend/src/ee/repoPermissionSyncer.ts b/packages/backend/src/ee/repoPermissionSyncer.ts index eb9edc67c..ea0c9f3e8 100644 --- a/packages/backend/src/ee/repoPermissionSyncer.ts +++ b/packages/backend/src/ee/repoPermissionSyncer.ts @@ -35,7 +35,7 @@ export class RepoPermissionSyncer { }); this.worker = new Worker(QUEUE_NAME, this.runJob.bind(this), { connection: redis, - concurrency: 1, + concurrency: this.settings.maxRepoPermissionSyncJobConcurrency, }); this.worker.on('completed', this.onJobCompleted.bind(this)); this.worker.on('failed', this.onJobFailed.bind(this)); diff --git a/packages/schemas/src/v3/index.schema.ts b/packages/schemas/src/v3/index.schema.ts index f5676ac3f..b16f398db 100644 --- a/packages/schemas/src/v3/index.schema.ts +++ b/packages/schemas/src/v3/index.schema.ts @@ -78,6 +78,16 @@ const schema = { "type": "number", "description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.", "minimum": 1 + }, + "maxAccountPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of account permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 + }, + "maxRepoPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of repo permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 } }, "additionalProperties": false @@ -214,6 +224,16 @@ const schema = { "type": "number", "description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.", "minimum": 1 + }, + "maxAccountPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of account permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 + }, + "maxRepoPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of repo permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 } }, "additionalProperties": false diff --git a/packages/schemas/src/v3/index.type.ts b/packages/schemas/src/v3/index.type.ts index f0e487c4d..a3342dd18 100644 --- a/packages/schemas/src/v3/index.type.ts +++ b/packages/schemas/src/v3/index.type.ts @@ -129,6 +129,14 @@ export interface Settings { * The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours. */ experiment_userDrivenPermissionSyncIntervalMs?: number; + /** + * The number of account permission sync jobs to run concurrently. Defaults to 8. + */ + maxAccountPermissionSyncJobConcurrency?: number; + /** + * The number of repo permission sync jobs to run concurrently. Defaults to 8. + */ + maxRepoPermissionSyncJobConcurrency?: number; } /** * Search context diff --git a/packages/shared/src/constants.ts b/packages/shared/src/constants.ts index 42e1aa694..e1c6463c9 100644 --- a/packages/shared/src/constants.ts +++ b/packages/shared/src/constants.ts @@ -29,4 +29,6 @@ export const DEFAULT_CONFIG_SETTINGS: ConfigSettings = { enablePublicAccess: false, // deprected, use FORCE_ENABLE_ANONYMOUS_ACCESS instead experiment_repoDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours experiment_userDrivenPermissionSyncIntervalMs: 1000 * 60 * 60 * 24, // 24 hours + maxAccountPermissionSyncJobConcurrency: 8, + maxRepoPermissionSyncJobConcurrency: 8, } diff --git a/schemas/v3/index.json b/schemas/v3/index.json index 10048a347..714cf7cbf 100644 --- a/schemas/v3/index.json +++ b/schemas/v3/index.json @@ -77,6 +77,16 @@ "type": "number", "description": "The interval (in milliseconds) at which the user permission syncer should run. Defaults to 24 hours.", "minimum": 1 + }, + "maxAccountPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of account permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 + }, + "maxRepoPermissionSyncJobConcurrency": { + "type": "number", + "description": "The number of repo permission sync jobs to run concurrently. Defaults to 8.", + "minimum": 1 } }, "additionalProperties": false