mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
remove transaction for job creation
This commit is contained in:
parent
26a7555f53
commit
bad7757a62
2 changed files with 37 additions and 35 deletions
|
|
@ -110,8 +110,10 @@ export class RepoPermissionSyncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async schedulePermissionSync(repos: Repo[]) {
|
private async schedulePermissionSync(repos: Repo[]) {
|
||||||
await this.db.$transaction(async (tx) => {
|
// @note: we don't perform this in a transaction because
|
||||||
const jobs = await tx.repoPermissionSyncJob.createManyAndReturn({
|
// we want to avoid the situation where a job is created and run
|
||||||
|
// prior to the transaction being committed.
|
||||||
|
const jobs = await this.db.repoPermissionSyncJob.createManyAndReturn({
|
||||||
data: repos.map(repo => ({
|
data: repos.map(repo => ({
|
||||||
repoId: repo.id,
|
repoId: repo.id,
|
||||||
})),
|
})),
|
||||||
|
|
@ -127,7 +129,6 @@ export class RepoPermissionSyncer {
|
||||||
removeOnFail: env.REDIS_REMOVE_ON_FAIL,
|
removeOnFail: env.REDIS_REMOVE_ON_FAIL,
|
||||||
}
|
}
|
||||||
})))
|
})))
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runJob(job: Job<RepoPermissionSyncJob>) {
|
private async runJob(job: Job<RepoPermissionSyncJob>) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { Redis } from "ioredis";
|
||||||
import { PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES } from "../constants.js";
|
import { PERMISSION_SYNC_SUPPORTED_CODE_HOST_TYPES } from "../constants.js";
|
||||||
import { env } from "../env.js";
|
import { env } from "../env.js";
|
||||||
import { createOctokitFromToken, getReposForAuthenticatedUser } from "../github.js";
|
import { createOctokitFromToken, getReposForAuthenticatedUser } from "../github.js";
|
||||||
import { createGitLabFromOAuthToken, createGitLabFromPersonalAccessToken, getProjectsForAuthenticatedUser } from "../gitlab.js";
|
import { createGitLabFromOAuthToken, getProjectsForAuthenticatedUser } from "../gitlab.js";
|
||||||
import { hasEntitlement } from "@sourcebot/shared";
|
import { hasEntitlement } from "@sourcebot/shared";
|
||||||
import { Settings } from "../types.js";
|
import { Settings } from "../types.js";
|
||||||
|
|
||||||
|
|
@ -113,8 +113,10 @@ export class UserPermissionSyncer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async schedulePermissionSync(users: User[]) {
|
private async schedulePermissionSync(users: User[]) {
|
||||||
await this.db.$transaction(async (tx) => {
|
// @note: we don't perform this in a transaction because
|
||||||
const jobs = await tx.userPermissionSyncJob.createManyAndReturn({
|
// we want to avoid the situation where a job is created and run
|
||||||
|
// prior to the transaction being committed.
|
||||||
|
const jobs = await this.db.userPermissionSyncJob.createManyAndReturn({
|
||||||
data: users.map(user => ({
|
data: users.map(user => ({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
})),
|
})),
|
||||||
|
|
@ -130,7 +132,6 @@ export class UserPermissionSyncer {
|
||||||
removeOnFail: env.REDIS_REMOVE_ON_FAIL,
|
removeOnFail: env.REDIS_REMOVE_ON_FAIL,
|
||||||
}
|
}
|
||||||
})))
|
})))
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runJob(job: Job<UserPermissionSyncJob>) {
|
private async runJob(job: Job<UserPermissionSyncJob>) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue