Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HJ-319 Add DBCache model and table #5613

Merged
merged 6 commits into from
Dec 18, 2024
Merged

HJ-319 Add DBCache model and table #5613

merged 6 commits into from
Dec 18, 2024

Conversation

erosselli
Copy link
Contributor

@erosselli erosselli commented Dec 17, 2024

Implements part of HJ-319

Description Of Changes

Adds a DBCache model and table to be used for persistent caching. The table has the namespace and cache_key columns that uniquely determine a row, and the column cache_value is used for storing an arbitrary value. For now we'll only use this for the list privacy experiences endpoint, but in the future it should be easy to add other things as well.

Code Changes

  • Create DBCache model and its corresponding migration
    • We index both over namespace (since we may want to implement a "clear all entries for a namespace") and over the (namespace, cache_key) pair (for lookups)

Steps to Confirm

  1. list any manual steps for reviewers to confirm the changes

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
  • Followup issues:
    • Followup issues created (include link)
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

Copy link

vercel bot commented Dec 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2024 1:38pm

Copy link

cypress bot commented Dec 17, 2024

fides    Run #11551

Run Properties:  status check passed Passed #11551  •  git commit 614d892fae ℹ️: Merge 1c41a11b5d6f95ec0778a28e8f5c7d485bdf05f3 into 70272d1b1ff9a4c1fc0474ebe9b4...
Project fides
Branch Review refs/pull/5613/merge
Run status status check passed Passed #11551
Run duration 00m 50s
Commit git commit 614d892fae ℹ️: Merge 1c41a11b5d6f95ec0778a28e8f5c7d485bdf05f3 into 70272d1b1ff9a4c1fc0474ebe9b4...
Committer erosselli
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.17%. Comparing base (70272d1) to head (1c41a11).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5613      +/-   ##
==========================================
+ Coverage   87.15%   87.17%   +0.01%     
==========================================
  Files         387      388       +1     
  Lines       23900    23931      +31     
  Branches     2585     2586       +1     
==========================================
+ Hits        20830    20861      +31     
  Misses       2512     2512              
  Partials      558      558              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

this looks solid to me! just a nit on the sqlalchemy representation of the composite index 👍

edit: just a note to keep an eye on the downrev in your migration, i know there's at least one other in-flight PR that touches migrations

namespace = Column(
String, nullable=False, index=True
) # Add a namespace since the same cache key could technically be used for different contexts
cache_key = Column(String, nullable=False, index=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm - i'm not sure how much it matters, but i think for a composite index (which this is, right?) it's generally specified a bit differently?

and we have some examples in our code base, e.g. here

Copy link
Contributor Author

@erosselli erosselli Dec 18, 2024

Choose a reason for hiding this comment

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

ah I forgot to specify the composite index on the model definition, I just added it in the migration 🤦‍♀️ I'll add it.

I did add index=True just to namespace thinking of queries like "Let's remove all entries for a namespace" , that don't have a specific cache_key but maybe the composite index still works for those kinds of queries? I'm a bit rusty on the specifics of composite indexes 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

heh, i'm not really an expert either. from my general understanding, i don't think the composite index would work well specifically for that use case - but i haven't validated that assumption at all.

i was aware of your intention with the two indexes there, and i didn't really question it - so i'd say it's fine to keep that in place! 👍

String, nullable=False, index=True
) # Add a namespace since the same cache key could technically be used for different contexts
cache_key = Column(String, nullable=False, index=True)
cache_value = Column(BYTEA, nullable=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

ok, i hope this works well and i wasn't silly to suggest a byte column :)

@adamsachs adamsachs mentioned this pull request Dec 17, 2024
13 tasks
@erosselli erosselli merged commit ebbd5d8 into main Dec 18, 2024
39 checks passed
@erosselli erosselli deleted the HJ-319 branch December 18, 2024 14:12
Copy link

cypress bot commented Dec 18, 2024

fides    Run #11553

Run Properties:  status check passed Passed #11553  •  git commit ebbd5d8851: HJ-319 Add DBCache model and table (#5613)
Project fides
Branch Review main
Run status status check passed Passed #11553
Run duration 00m 47s
Commit git commit ebbd5d8851: HJ-319 Add DBCache model and table (#5613)
Committer erosselli
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

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