Skip to content

Commit f50df46

Browse files
joanagmaiaclaude
andauthored
fix: gitlab fixes (CM-1298) (#4272)
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e534bb0 commit f50df46

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

backend/src/services/integrationService.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ export default class IntegrationService {
315315
async destroyAll(ids) {
316316
const toRemoveRepo = new Set<string>()
317317
let segmentId
318+
// Collect GitLab webhook info before opening the transaction so external HTTP calls
319+
// don't hold the DB connection idle long enough to trigger a connection timeout.
320+
const gitlabWebhookRemovals: Array<{ token: string; projectIds: number[]; hookIds: number[] }> =
321+
[]
322+
318323
const transaction = await SequelizeRepository.createTransaction(this.options)
319324

320325
try {
@@ -446,11 +451,11 @@ export default class IntegrationService {
446451
}
447452

448453
if (integration.platform === PlatformType.GITLAB && integration.settings.webhooks) {
449-
await removeGitlabWebhooks(
450-
integration.token,
451-
integration.settings.webhooks.map((hook) => hook.projectId),
452-
integration.settings.webhooks.map((hook) => hook.hookId),
453-
)
454+
gitlabWebhookRemovals.push({
455+
token: integration.token,
456+
projectIds: integration.settings.webhooks.map((hook) => hook.projectId),
457+
hookIds: integration.settings.webhooks.map((hook) => hook.hookId),
458+
})
454459
}
455460

456461
if (integration.platform === PlatformType.GIT) {
@@ -495,6 +500,14 @@ export default class IntegrationService {
495500
await SequelizeRepository.rollbackTransaction(transaction)
496501
throw error
497502
}
503+
504+
// Remove GitLab webhooks after the transaction commits — these are external HTTP calls
505+
// and must not hold a DB connection open.
506+
await Promise.all(
507+
gitlabWebhookRemovals.map(({ token, projectIds, hookIds }) =>
508+
removeGitlabWebhooks(token, projectIds, hookIds),
509+
),
510+
)
498511
}
499512

500513
async findById(id) {

services/libs/tinybird/pipes/pull_request_analysis_baseline_merge_MV.pipe

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ SQL >
115115
argMin(
116116
updatedAt,
117117
if(
118-
type IN ('pull_request-reviewed', 'merge_request-review-changes-requested')
118+
type IN (
119+
'pull_request-reviewed',
120+
'merge_request-review-changes-requested',
121+
'merge_request-review-approved'
122+
)
119123
OR (
120124
type = 'patchset_approval-created'
121125
AND splitByChar('-', sourceParentId)[1] = prSourceId
@@ -126,7 +130,11 @@ SQL >
126130
) AS reviewedUpdatedAt,
127131
min(
128132
if(
129-
type IN ('pull_request-reviewed', 'merge_request-review-changes-requested')
133+
type IN (
134+
'pull_request-reviewed',
135+
'merge_request-review-changes-requested',
136+
'merge_request-review-approved'
137+
)
130138
OR (
131139
type = 'patchset_approval-created'
132140
AND splitByChar('-', sourceParentId)[1] = prSourceId

services/libs/tinybird/pipes/pull_request_analysis_initial_snapshot.pipe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ SQL >
9898
and (
9999
type = 'pull_request-reviewed'
100100
OR type = 'merge_request-review-changes-requested'
101+
OR type = 'merge_request-review-approved'
101102
OR type = 'patchset_approval-created'
102103
)
103104
{% if defined(bucket_id) %}

0 commit comments

Comments
 (0)