-
Notifications
You must be signed in to change notification settings - Fork 732
fix: prevent concurrent processing for automotivelinux repos [CM-1103] #4015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,14 +125,30 @@ async def acquire_repository(query: str, params: tuple = None) -> Repository | N | |
| async def acquire_recurrent_repo() -> Repository | None: | ||
| """Acquire a regular (non-onboarding) repository, that were not processed in the last x hours (REPOSITORY_UPDATE_INTERVAL_HOURS)""" | ||
| recurrent_repo_sql_query = f""" | ||
| WITH selected_repo AS ( | ||
| -- Rate-limit guard: Gerrit (automotivelinux) aggressively rate-limits concurrent connections. | ||
| -- This CTE checks if any automotivelinux repo is already being processed, | ||
| -- so we skip picking another one from the same host until the current one finishes. | ||
| WITH automotivelinux_processing AS ( | ||
| SELECT 1 | ||
| FROM git."repositoryProcessing" rp2 | ||
| JOIN public.repositories r2 ON r2.id = rp2."repositoryId" | ||
| WHERE rp2.state = 'processing' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded state string bypasses parameterized query patternLow Severity The Reviewed by Cursor Bugbot for commit db07fb6. Configure here. |
||
| AND rp2."lockedAt" IS NOT NULL | ||
| AND r2.url LIKE '%gerrit.automotivelinux.org%' | ||
| LIMIT 1 | ||
|
Comment on lines
+135
to
+138
|
||
| ), | ||
| selected_repo AS ( | ||
| SELECT r.id | ||
| FROM public.repositories r | ||
| JOIN git."repositoryProcessing" rp ON rp."repositoryId" = r.id | ||
| WHERE NOT (rp.state = ANY($2)) | ||
| AND rp."lockedAt" IS NULL | ||
| AND r."deletedAt" IS NULL | ||
| AND rp."lastProcessedAt" < NOW() - INTERVAL '1 hour' * $3 | ||
| AND NOT ( | ||
| r.url LIKE '%gerrit.automotivelinux.org%' | ||
| AND EXISTS (SELECT 1 FROM automotivelinux_processing) | ||
|
Comment on lines
+149
to
+150
|
||
| ) | ||
|
Comment on lines
+148
to
+151
|
||
| ORDER BY rp.priority ASC, rp."lastProcessedAt" ASC | ||
| LIMIT 1 | ||
| FOR UPDATE OF rp SKIP LOCKED | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description/title suggests preventing concurrent processing for automotivelinux repos in general, but this safeguard only applies to the recurrent acquisition path. Automotivelinux repos can still be acquired concurrently via
acquire_onboarding_repo(pending) andacquire_pending_reonboard_repo(pending_reonboard). If the intent is truly “only one at a time”, the same host-level guard should be applied across all acquisition queries (or centralized inacquire_repo_for_processing).