This repository was archived by the owner on May 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
add flags_id nullable field to new Flake model #484
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
shared/django_apps/test_analytics/migrations/0002_flake_flags_id.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Generated by Django 4.2.16 on 2025-01-20 17:38 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
| """ | ||
| BEGIN; | ||
| -- | ||
| -- Add field flags_id to flake | ||
| -- | ||
| ALTER TABLE "test_analytics_flake" ADD COLUMN "flags_id" bytea NULL; | ||
| COMMIT; | ||
| """ | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("test_analytics", "0001_initial"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="flake", | ||
| name="flags_id", | ||
| field=models.BinaryField(null=True), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
BinaryField. What kind of data do you plan to put there? Also noticing now thattest_idis also aBinaryField. Will these hold (non-base16-encoded) hash values?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.
yes, they're both has values. I think i can probably indicate it somehow with some sort of max length in the binary field but the test_id is meant to be 16 bytes and the flags_id is meant to be 8 bytes. they're both generated using mmh3 and they don't have any particular encoding hence: BinaryField. In BQ they're defined as BYTES fields
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.
we have a normal index on
repo_idandtest_id, but are you planning on having any kind of uniqueness constraint based on the test_id or the flags_id?it should be fine if both are still also dependent on the repo_id.
just thinking of that as I recently read https://orlp.net/blog/breaking-hash-functions/ which is a very well written post about how to trivially cause collisions of mmh3 and similar non cryptographic hash functions.
it would be really bad if one customer could mess with another customers data based on such trivially breakable hash values.
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.
i think the uniqueness constraint should be on (repoid, test_id, flags_id) so that will isolate test_id collisions to a single customer. The mistake I made with the Test model previously is that the primary key was the test_id, which was all around a bad idea.
At least this strategy of isolating unique (test_id, flags_id) combinations to the repo means that one customer can't mess with another, however this still leaves an opening for open source repos (or any repo that doesn't protect its uploads) to be polluted. I'm not sure how to fix that problem.