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

cache: better cache system #4951

Merged
merged 6 commits into from
Dec 20, 2024
Merged

cache: better cache system #4951

merged 6 commits into from
Dec 20, 2024

Conversation

uael
Copy link
Collaborator

@uael uael commented Dec 18, 2024

Important

Enhances cache system with validation logic and thread-local caching for testing, adding a validate() method and modifying import logic.

  • Validation:
    • Add validate() method to fs::Bundle trait in cache.rs for data integrity.
    • Implement validate() in ScriptData, Option<T>, and (A, B) to check non-empty code and valid data.
  • Import Logic:
    • Modify import_or_insert_with() in fs module to use validate(), logging a warning if validation fails.
    • Update get_or_insert_async() in FsBackedCache to check validation before returning data.
  • Misc:
    • Add threadlocal_cache feature to Cargo.toml for testing.
    • Update backend-test.yml to include threadlocal_cache in test features.

This description was created by Ellipsis for 682337e. It will automatically update as commits are pushed.

@uael uael requested a review from rubenfiszel as a code owner December 18, 2024 17:39
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 95737d8 in 1 minute and 40 seconds

More details
  • Looked at 60 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_8ZpzV2rxHNZSksy3


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

backend/windmill-common/src/cache.rs Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Dec 18, 2024

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 682337e
Status: ✅  Deploy successful!
Preview URL: https://625619c6.windmill.pages.dev
Branch Preview URL: https://uael-cache-validate.windmill.pages.dev

View logs

@uael uael force-pushed the uael/cache_validate branch from 95737d8 to 0146432 Compare December 19, 2024 15:08
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 0146432 in 1 minute and 5 seconds

More details
  • Looked at 1163 lines of code in 7 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. backend/windmill-common/src/cache.rs:148
  • Draft comment:
    When the threadlocal_cache feature is enabled, the cache key should include the ThreadId. Consider modifying the key creation to:
        let key = if cfg!(feature = "threadlocal_cache") { (std::thread::current().id(), key.clone()) } else { key };
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. backend/windmill-common/src/cache.rs:317
  • Draft comment:
    Consider adding more context to the error messages in unwrap_or_error to improve debugging. For example, include the database query or the expected data format.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The unwrap_or_error function is used to handle errors when fetching data from the database. However, it does not provide detailed error messages, which can make debugging difficult. Adding more context to the error messages would improve the debugging experience.

Workflow ID: wflow_HAqFtiAKJTWuKjKP


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@uael uael requested a review from HugoCasa December 19, 2024 15:24
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on a9976c5 in 41 seconds

More details
  • Looked at 230 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. backend/windmill-common/src/cache.rs:7
  • Draft comment:
    Update the comment to reflect the feature name change from threadlocal_cache to scoped_cache. This change should be applied throughout the file where applicable.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. backend/windmill-common/src/cache.rs:623
  • Draft comment:
    Update the comment to reflect the feature name change from threadlocal_cache to scoped_cache. This change should be applied throughout the file where applicable.
  • Reason this comment was not posted:
    Marked as duplicate.
3. backend/windmill-common/src/cache.rs:896
  • Draft comment:
    Update the comment to reflect the feature name change from threadlocal_cache to scoped_cache. This change should be applied throughout the file where applicable.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_DVdpvRcsNNd5pkvW


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on f61ea26 in 1 minute and 0 seconds

More details
  • Looked at 201 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_XrVYxyRPfJ6YJLHZ


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@uael uael changed the title cache: do not trust the filesystem cache: better cache system Dec 20, 2024
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 2977334 in 45 seconds

More details
  • Looked at 63 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/windmill-common/src/cache.rs:524
  • Draft comment:
    Consider adding a validation step before returning the data to ensure data integrity as described in the PR.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The code already has several validation steps: 1) It uses unwrap_or_error to validate the database result exists 2) The SQL query uses type annotations to validate types 3) The RawScript struct enforces data structure. Adding more validation would be redundant. The comment is vague and doesn't specify what validation is missing.
    I could be missing some edge cases or data integrity concerns that aren't obvious from just this code. The PR description might provide more context about specific validation needs.
    Even if there are edge cases, the comment is too vague to be actionable. If there are specific validation concerns, they should be clearly stated with concrete examples.
    Delete the comment since it is vague, not clearly actionable, and the code already has reasonable validation through type checking and error handling.

Workflow ID: wflow_8ZbYeTsmQ8JK27xe


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 494e71d in 39 seconds

More details
  • Looked at 78 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/.sqlx/query-0bf123446bebbc357c58a53a9319f4954dbf3225e91cbe999e5b264c1a747664.json:1
  • Draft comment:
    This file appears to be a generated SQLx query description and should not be included in the repository. Consider adding it to .gitignore.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    SQLx query files are actually meant to be committed to version control - they're not generated artifacts that should be ignored. They contain important type information that SQLx uses for compile-time query checking. The comment is suggesting incorrect practice that would break SQLx's compile-time checking feature.
    Maybe there are cases where teams prefer to regenerate these files during build time instead of committing them?
    While possible, the standard practice with SQLx is to commit these files as they provide compile-time guarantees. Regenerating at build time would defeat this purpose and is not the intended usage.
    The comment should be deleted as it suggests incorrect practice that would break SQLx's compile-time checking feature.

Workflow ID: wflow_q8MDdWz6vVs9RAjA


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on 682337e in 26 seconds

More details
  • Looked at 75 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. backend/windmill-common/src/cache.rs:55
  • Draft comment:
    Using tempfile for temporary directories is a good choice. Ensure all usages of mktemp are replaced and tested.
  • Reason this comment was not posted:
    Confidence changes required: 20%
    The tempfile crate is used to replace mktemp for creating temporary directories. This change is consistent with the PR description and should work as expected since tempfile is a well-known crate for handling temporary files and directories in Rust.

Workflow ID: wflow_wFbdYWzTqwT72sC3


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@rubenfiszel rubenfiszel merged commit 83d24cb into main Dec 20, 2024
7 checks passed
@rubenfiszel rubenfiszel deleted the uael/cache_validate branch December 20, 2024 10:19
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants