Skip to content

feat(backend): sync git commit metadata into commits tables (#2079) - #2118

Open
felipebergamin wants to merge 10 commits into
kernelci:mainfrom
profusion:feat/2079/sync-commit-metadata
Open

felipebergamin wants to merge 10 commits into
kernelci:mainfrom
profusion:feat/2079/sync-commit-metadata

Conversation

@felipebergamin

@felipebergamin felipebergamin commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

TL;DR

Fill commits / commit_parents from git objects, not KCIDB. A persistent bare mirror at GIT_MIRROR_DIR fetches allowlisted trees; a second cron ingests the tip delta from that mirror (ancestor closure, not DISTINCT checkouts.git_commit_hash). Does not write checkouts.git_commit_message.

Closes #2109. Part of #2079. Schema #2089 and parse helper #2090 are still on this branch if they have not merged yet.

How to review

Read in this order:

  1. docs/sync-commits.md — decisions (filter probe, kernel.org full packs, no googlesource remap, pack rollback vs keep-on-FAILED).
  2. backend/kernelCI_app/helpers/gitCommit.py — parse + one-shot SHA fetch ([#2079] Fetch commit metadata via SHA-only partial clone on tmpfs #2090).
  3. backend/kernelCI_app/helpers/commitSync.py — mirror fetch + ingest.
  4. sync_commit_mirror.py / sync_commit_ingest.py — two crons (0 4 fetch, 0 10 ingest).
  5. Tests: commitSync_test.py, gitCommit_test.py.

Skip unless you care about ops: compose git-mirror volume, .env*.example, measure_git_mirror.py.

Behavior that changed since the first PR description

  • Two commands, not sync_commits + flags: sync_commit_mirror and sync_commit_ingest.
  • Servers without fetch=filter (git.kernel.org) still fetch; --filter=tree:0 only when advertised. No URL remap.
  • HTTP/1.1 + large postBuffer; keep completed packs on transport FAILED and retry once; kill the git process group on timeout.
  • Ingest watermark: rev-list --remotes with ^sha on stdin. --not --stdin does not exclude tips (that bug re-listed ~1.9M commits every run).
  • --fill-gaps stays on ingest (one-shot SHA, no ancestry).

Risk / rollout

  • First populate: ~6–8 GiB mirror, ~1.9M commits to ingest once. Later runs should be near-zero without a new fetch.
  • Do not run mirror and ingest on the same GIT_MIRROR_DIR at the same time.
  • Recreate the git-mirror volume if an old unfiltered pack slipped in during early runs.
  • Migration 0021 is additive; no checkout column rewrite.

Test plan

  • poetry run pytest kernelCI_app/tests/unitTests/helpers/commitSync_test.py kernelCI_app/tests/unitTests/helpers/gitCommit_test.py
  • manage.py sync_commit_mirror --dry-run then manage.py sync_commit_ingest --dry-run
  • Second ingest without a new fetch logs 0 new commits (known_tips > 0)
  • One failed remote does not abort the rest
  • Skipped intermediate commit between two checkouts still lands with first-parent ord=0

@felipebergamin
felipebergamin force-pushed the feat/2079/sync-commit-metadata branch from 2185f8e to 93ed169 Compare September 18, 2026 19:04
@felipebergamin
felipebergamin marked this pull request as ready for review September 21, 2026 19:28
* Add `Commits` model: unique `git_commit_hash`, nullable author/committer/subject/message/`fetched_from_url`
* Add `CommitParents` model: FKs to `commits.id`, `ord` with 0 = first parent, unique `(commit_id, ord)`
* Add migration `0021_commits_and_commit_parents` (`commits`, `commit_parents` tables and indexes)
* Join from `checkouts.git_commit_hash` without new checkout columns

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Dump commits and commit_parents in full so git ancestry survives restore.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
…ci#2089)

Keep commits rows narrow: unique git name/email in commit_identity, subject plus UTF-8 body in commit_message as bytea. update_db dumps and restores the new tables and still accepts a flat legacy commits CSV.
@felipebergamin
felipebergamin force-pushed the feat/2079/sync-commit-metadata branch from 93ed169 to 85dcd65 Compare September 23, 2026 20:19
@@ -0,0 +1,59 @@
---

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.

maybe we shoudl keep those skill related files only on the dedicated PR.

parser.add_argument(
"--dry-run",
action="store_true",
help="Parse as requested, write nothing to the database or tips file.",

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.

the dry run still updates with fetch (so it is not totally dry), even if we are not writing to database, might be something worth pointing.

for metadata in metadatas
]
Commits.objects.bulk_create(
rows, ignore_conflicts=True, batch_size=UPSERT_BATCH_SIZE

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.

we are ignoring on conflicts here, we should opt to either update on conflict or change the upsert name.

Add a SHA-only helper for commit author/parents so later sync can reuse parsing without duplicating git format handling.

Signed-off-by: Felipe Bergamin <felipebergamin@profusion.mobi>
- Move fetch timeout and max pack size to Django settings
  (GIT_FETCH_TIMEOUT_SECONDS, GIT_FETCH_MAX_PACK_BYTES)
- Document URL preference tiers and why the git CLI is used
- Reuse author/committer constants in tests
…nelci#2079)

Fetch allowlisted trees into GIT_MIRROR_DIR and ingest the tip delta into commits / commit_parents (not checkout hashes). Probe filter support, keep kernel.org packs, split mirror vs ingest crons, and exclude stored tips with ^sha on rev-list stdin.

Signed-off-by: Felipe Bergamin <felipebergamin@profusion.mobi>
Commit objects are immutable, so existing hashes stay as stored. Dry-run help now says the mirror fetch still updates the repo on disk, while ingest does not fetch.
Author and committer now live on commit_identity, and subject and message on commit_message.
@felipebergamin
felipebergamin force-pushed the feat/2079/sync-commit-metadata branch from 80974f5 to 07d64ab Compare September 25, 2026 21:01
Nested identity and message stores pushed commit_store over the complexity limit.

This branch has not been deployed

No deployments
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.

[#2079] Sync mirrored trees into commits

2 participants