Skip to content

fix(gitlab): always re-collect MR commits regardless of MR updated_at… - #8959

Merged
klesh merged 4 commits into
apache:mainfrom
bujjibabukatta:fix/#8818
Aug 12, 2026
Merged

fix(gitlab): always re-collect MR commits regardless of MR updated_at…#8959
klesh merged 4 commits into
apache:mainfrom
bujjibabukatta:fix/#8818

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

When running incremental collection, GetMergeRequestsIterator filters merge requests using gitlabupdatedat > since.
When running incremental collection, GetMergeRequestsIterator filters merge requests using gitlab_updated_at > since. This works fine for notes and reviews — if the MR hasn't been touched, nothing new to collect. But for commits it's the wrong filter. Pushing new commits to a MR's source branch doesn't update gitlab_updated_at on the MR itself, so those MRs get skipped entirely and their new commits are never fetched. This is exactly why full refresh works but normal collect misses data.
The fix is to pass nil instead of apiCollector when calling GetMergeRequestsIterator in the commit collector. Passing nil skips the time filter so every MR is scanned for commits on each run, matching full refresh behaviour. The MR commits endpoint is lightweight so the performance impact is minimal. Notes and reviews collectors are unchanged — they still pass apiCollector and keep their incremental filtering, which is correct for those entities.

… to prevent missing commits in incremental runs
@bujjibabukatta

Copy link
Copy Markdown
Contributor Author

Hi @klesh could you please review and approve pull request?

@klesh

klesh commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Please fix the failed checks first.

@bujjibabukatta

Copy link
Copy Markdown
Contributor Author

Hi @klesh — I've fixed the build. 5c66376 corrects the if-brace syntax error in GetMergeRequestsIterator that was breaking lint, unit-test, and the e2e checks; it now compiles cleanly (go build ./plugins/gitlab/... passes locally) and I've merged latest main. The workflows are showing "awaiting approval" — could you approve the run so CI can execute, then re-review? Thanks!

@bujjibabukatta
bujjibabukatta force-pushed the fix/#8818 branch 2 times, most recently from 8bac968 to 5c66376 Compare August 11, 2026 09:08

@klesh klesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Thanks for your contribution.

@klesh
klesh merged commit b005e6f into apache:main Aug 12, 2026
10 checks passed
DoDiODev added a commit to DoDiODev/devlake that referenced this pull request Aug 12, 2026
…tal filter

apache#8959 changed `GetMergeRequestsIterator` to filter merge requests by
`GREATEST(gmr.gitlab_updated_at, COALESCE(gmr.commit_updated_at, gmr.gitlab_updated_at))`,
but `commit_updated_at` does not exist on `_tool_gitlab_merge_requests`:
there is neither a model field nor a migration script, and nothing ever
writes the value.

As a result every incremental "Collect MR Notes" run (the only caller that
passes a stateful collector; the MR commit collector passes nil) aborts with:

    Error 1054 (42S22): Unknown column 'gmr.commit_updated_at' in 'where clause'

This makes the intended behaviour actually work instead of reverting it:

* add `CommitUpdatedAt` to `GitlabMergeRequest` plus a migration script
* maintain the column in the MR commit extractor, setting it to the latest
  authored date of the MR's commits, so MRs that received new commits without
  their own `updated_at` being bumped (e.g. force-pushes) are picked up again
* the collector filter is unchanged and now resolves against a real column

Verified on MySQL 8 and PostgreSQL 14 (extractor UPDATE and the GREATEST
filter produce identical results on both).
klesh pushed a commit that referenced this pull request Aug 14, 2026
…tal filter (#9046)

#8959 changed `GetMergeRequestsIterator` to filter merge requests by
`GREATEST(gmr.gitlab_updated_at, COALESCE(gmr.commit_updated_at, gmr.gitlab_updated_at))`,
but `commit_updated_at` does not exist on `_tool_gitlab_merge_requests`:
there is neither a model field nor a migration script, and nothing ever
writes the value.

As a result every incremental "Collect MR Notes" run (the only caller that
passes a stateful collector; the MR commit collector passes nil) aborts with:

    Error 1054 (42S22): Unknown column 'gmr.commit_updated_at' in 'where clause'

This makes the intended behaviour actually work instead of reverting it:

* add `CommitUpdatedAt` to `GitlabMergeRequest` plus a migration script
* maintain the column in the MR commit extractor, setting it to the latest
  authored date of the MR's commits, so MRs that received new commits without
  their own `updated_at` being bumped (e.g. force-pushes) are picked up again
* the collector filter is unchanged and now resolves against a real column

Verified on MySQL 8 and PostgreSQL 14 (extractor UPDATE and the GREATEST
filter produce identical results on both).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants