Skip to content

Commit 39615c3

Browse files
chore(backend): Prioritize permission sync jobs for new accounts & repos (#856)
* s * changelog * reduce polling interval
1 parent c59cdba commit 39615c3

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Fixed issue where the branch filter in the repos detail page would not return any results. [#851](https://github.com/sourcebot-dev/sourcebot/pull/851)
1515
- Fixed issue where 5xx http errors would not be retried. [#855](https://github.com/sourcebot-dev/sourcebot/pull/855)
1616

17+
### Changed
18+
- Changed the queuing behaviour for permission syncing to prioritize newly created accounts & repos. [#856](https://github.com/sourcebot-dev/sourcebot/pull/856)
19+
1720
## [4.10.25] - 2026-02-04
1821

1922
### Fixed

packages/backend/src/ee/accountPermissionSyncer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const logger = createLogger(LOG_TAG);
2222
const createJobLogger = (jobId: string) => createLogger(`${LOG_TAG}:job:${jobId}`);
2323

2424
const QUEUE_NAME = 'accountPermissionSyncQueue';
25+
const POLLING_INTERVAL_MS = 1000;
2526

2627
type AccountPermissionSyncJob = {
2728
jobId: string;
@@ -103,7 +104,7 @@ export class AccountPermissionSyncer {
103104
});
104105

105106
await this.schedulePermissionSync(accounts);
106-
}, 1000 * 5);
107+
}, POLLING_INTERVAL_MS);
107108
}
108109

109110
public async dispose() {
@@ -122,6 +123,9 @@ export class AccountPermissionSyncer {
122123
data: accounts.map(account => ({
123124
accountId: account.id,
124125
})),
126+
include: {
127+
account: true,
128+
}
125129
});
126130

127131
await this.queue.addBulk(jobs.map((job) => ({
@@ -132,6 +136,8 @@ export class AccountPermissionSyncer {
132136
opts: {
133137
removeOnComplete: env.REDIS_REMOVE_ON_COMPLETE,
134138
removeOnFail: env.REDIS_REMOVE_ON_FAIL,
139+
// Priority 1 (high) for never-synced, Priority 2 (normal) for re-sync
140+
priority: job.account.permissionSyncedAt === null ? 1 : 2,
135141
}
136142
})))
137143
}

packages/backend/src/ee/repoPermissionSyncer.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ type RepoPermissionSyncJob = {
1515
}
1616

1717
const QUEUE_NAME = 'repoPermissionSyncQueue';
18-
18+
const POLLING_INTERVAL_MS = 1000;
1919
const LOG_TAG = 'repo-permission-syncer';
20+
2021
const logger = createLogger(LOG_TAG);
2122
const createJobLogger = (jobId: string) => createLogger(`${LOG_TAG}:job:${jobId}`);
2223

@@ -107,7 +108,7 @@ export class RepoPermissionSyncer {
107108
});
108109

109110
await this.schedulePermissionSync(repos);
110-
}, 1000 * 5);
111+
}, POLLING_INTERVAL_MS);
111112
}
112113

113114
public async dispose() {
@@ -126,6 +127,9 @@ export class RepoPermissionSyncer {
126127
data: repos.map(repo => ({
127128
repoId: repo.id,
128129
})),
130+
include: {
131+
repo: true,
132+
}
129133
});
130134

131135
await this.queue.addBulk(jobs.map((job) => ({
@@ -136,6 +140,8 @@ export class RepoPermissionSyncer {
136140
opts: {
137141
removeOnComplete: env.REDIS_REMOVE_ON_COMPLETE,
138142
removeOnFail: env.REDIS_REMOVE_ON_FAIL,
143+
// Priority 1 (high) for never-synced, Priority 2 (normal) for re-sync
144+
priority: job.repo.permissionSyncedAt === null ? 1 : 2,
139145
}
140146
})))
141147
}

0 commit comments

Comments
 (0)