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

feat(core): add fallback cache for db cache #27841

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AgentEnder
Copy link
Member

Current Behavior

Expected Behavior

Related Issue(s)

Fixes #

Copy link

vercel bot commented Sep 9, 2024

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

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Sep 17, 2024 7:38pm

Comment on lines 78 to 85
const error = [
`Invalid Cache Directory for Task "${task.id}"`,
`The local cache artifact in "${cacheDir}" was found in ${cacheDir}.`,
`When using the database cache, cache artifacts are stored in a database within ${workspaceDataDirectory}.`,
``,
`If you believe this is a mistake, running \`nx reset\` will clear the cache and allow it to be repopulated.`,
`Alternatively, setting NX_REJECT_UNKNOWN_LOCAL_CACHE to false will bypass this check.`,
``,
Copy link
Member Author

Choose a reason for hiding this comment

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

@FrozenPandaz this is the spot we should tune the error message a bit.

@AgentEnder AgentEnder force-pushed the feat/shared-local-db branch 5 times, most recently from 1c9f6ca to 09b66a4 Compare September 13, 2024 21:57
"{}.db",
match db_name {
Some(name) => name,
None => machine_id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Call the get_machine_id() in here

let db_path = cache_dir_buf.join(format!("{}.db", machine_id));
let db_path = cache_dir_buf.join(format!(
"{}.db",
match db_name {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can be more idiomatic

db_name.unwrap_or_else(|| get_machine_id())

if (cacheDir !== defaultCacheDir) {
this.fallbackDbCache = new NxCache(
workspaceRoot,
process.env.NX_SHARED_CACHE_DIRECTORY,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be cacheDir

// hit issues. If we detect this, we can create a fallback db cache in the
// custom directory, and check if the entries are there when the main db
// cache misses.
if (cacheDir !== defaultCacheDir) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should implement some kind of "cache reflects fs state"

@FrozenPandaz FrozenPandaz added the PR status: do not merge This will block a PR from being merged until this tag is removed. label Sep 16, 2024
@FrozenPandaz FrozenPandaz marked this pull request as ready for review September 16, 2024 21:23
@FrozenPandaz FrozenPandaz requested review from a team as code owners September 16, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR status: do not merge This will block a PR from being merged until this tag is removed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants