You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug][Bitbucket] Bitbucket ignores the updated_on filter on /pipelines, so every run appends all pipelines to the raw table and Extract Pipelines grows without bound #9430
I had searched in the issues and found no similar issues.
What happened
On a Bitbucket Cloud repo with ~22k pipelines, the blueprint run time grew from ~25 min to ~9 h over three weeks. "Extract Pipelines" accounts for 485 of the 536 minutes of the latest run.
Every incremental run of "Collect Pipelines" fetches all ~445 pages (~22k pipelines), not only the ones updated since the last run.
Each run appends them to _raw_bitbucket_api_pipelines. Raw rows are deleted only on a full sync, so the table now holds ~35 copies of every pipeline.
"Extract Pipelines" uses NewApiExtractor and re-reads every raw row on every run. Rows extracted per run went from 221k (50 min) to 767k (485 min).
Root cause:
pipeline_collector.go uses NewStatefulApiCollector with GetQueryCreatedAndUpdated, which adds q=updated_on>=<since>. Bitbucket Cloud's GET /2.0/repositories/{workspace}/{repo_slug}/pipelines/ ignores q: q=updated_on>=2099-01-01T00:00:00Z returns the full size, and an invalid q returns no error and the full size. The same q on /pullrequests returns 0. Atlassian's OpenAPI spec (https://api.bitbucket.org/swagger.json) lists no q parameter for list pipelines; created_on is listed but matches one exact timestamp only.
pipeline_extractor.go uses NewApiExtractor, which reads all raw rows for the params on every run.
Same class as #9421 (GitHub GraphQL) and #9305 (CircleCI, fixed in #9313).
What do you expect to happen
An incremental run should extract only the raw rows added since the previous run, and collection should not append a full copy of every pipeline each run, so run time stays flat.
Proposed fix:
Extractor: switch to NewStatefulApiExtractor, with the deployment/production patterns as SubtaskConfig so changing them triggers a full re-extract. PR to follow.
Collector (follow-up): Bitbucket honours sort=-created_on. Use NewStatefulApiCollectorForFinalizableEntity (stop paging at the last run's created_on, re-collect unfinished pipelines) so the raw table stops growing.
How to reproduce
Add a Bitbucket Cloud repo with a few thousand pipelines to a project with CI/CD enabled.
Run the blueprint several times without full sync.
select count(*), count(distinct convert_from(data,'UTF8')::jsonb->>'uuid') from _raw_bitbucket_api_pipelines grows by one full copy per run, and "Extract Pipelines" time grows with it.
Anything else
Every run. The three files involved are unchanged on main as of 652d7da.
Workaround: delete older raw copies, keeping the newest row per pipeline uuid, between runs:
DELETE FROM _raw_bitbucket_api_pipelines r
USING (SELECT id, row_number() OVER (PARTITION BY params, convert_from(data,'UTF8')::jsonb->>'uuid' ORDER BY id DESC) rn
FROM _raw_bitbucket_api_pipelines) d
WHERE r.id = d.id AND d.rn > 1;
Activity