Skip to content

feat/backfill db - #1986

Open
alanpeixinho wants to merge 12 commits into
kernelci:mainfrom
profusion:feat/backfill-db
Open

feat/backfill db#1986
alanpeixinho wants to merge 12 commits into
kernelci:mainfrom
profusion:feat/backfill-db

Conversation

@alanpeixinho

Copy link
Copy Markdown
Contributor

what it is

Includes a backfill labs command to update old data into using the lab foreign key for builds and tests tables.

How to test

  • Create a new local database, and apply migrations.
  • Insert data from a snapshot or running the ingester.
  • Manually remove lab information from some rows.
  • Run the backfill_lab_ids command with varying parameters.

@alanpeixinho
alanpeixinho marked this pull request as draft July 10, 2026 21:24
@alanpeixinho alanpeixinho changed the title feat/backfill db [WIP] feat/backfill db Jul 10, 2026
@alanpeixinho
alanpeixinho marked this pull request as ready for review July 15, 2026 16:36
@alanpeixinho alanpeixinho changed the title [WIP] feat/backfill db feat/backfill db Jul 15, 2026
@felipebergamin

Copy link
Copy Markdown
Member

@alanpeixinho I think this PR needs a rebase

Part of kernelci#1948

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Part of kernelci#1948

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
    * For analysis queries we are going for lab column information
      first, and coalescing to json misc information.
    *  All COALESCE expressions are marked with TODO comments for removal
      after the lab_id backfill is complete.

    Closes kernelci#1948

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Rename Builds/Tests FK field from lab to lab_id so lab is free for
annotated lab names without conflicting with the ORM relation.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Keep lab as the standard Django FK field and resolve build test lab names
via raw SQL, matching the hardware query pattern.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Enforce the lab FK db_constraint on builds and tests, drop the unused
lab_id from the build tests response, and fix the tree query lab TODO.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
  * process historical data to use the lab foreign key

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Leave lab_id NULL for shell/k8s* and misc.automatic_lab so backfill
matches ingest _real_lab and does not insert fake labs.

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>

@felipebergamin felipebergamin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❯ docker compose exec backend poetry run python3 manage.py backfill_lab_ids           
[2026-08-18 20:28:49] Collecting distinct lab names from JSONB...
[2026-08-18 20:28:50]   Found 16 distinct lab names
[2026-08-18 20:28:50] Inserting missing lab names into labs table...
[2026-08-18 20:28:50] Staging builds ids...
[2026-08-18 20:28:50] Builds to backfill: 3075
[2026-08-18 20:28:50]   builds: 3075/3075 (0.2s)
[2026-08-18 20:28:50] Staging tests ids...
[2026-08-18 20:28:51] Tests to backfill: 382421
[2026-08-18 20:28:55]   tests: 50000/382421 (3.9s)
[2026-08-18 20:28:58]   tests: 100000/382421 (7.3s)
[2026-08-18 20:29:02]   tests: 150000/382421 (10.9s)
[2026-08-18 20:29:05]   tests: 200000/382421 (14.7s)
[2026-08-18 20:29:09]   tests: 250000/382421 (18.6s)
[2026-08-18 20:29:14]   tests: 300000/382421 (23.0s)
[2026-08-18 20:29:18]   tests: 350000/382421 (26.8s)
[2026-08-18 20:29:21]   tests: 382421/382421 (29.7s)
[2026-08-18 20:29:21] Done.

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