You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Edit: check my last comment below: #8955. Seems like the original issue can't be reproduced anymore verbatim. However, there seems to be some other variations that still show a similar cache invalidation behavior.
If I run that multiple times, I'll get a cached output as expected. Now, the moment that I add another execafter the last one, for some reason, the second to last exec gets re-executed and not computed from the cache.
i.e:
// Returns a container that echoes whatever string argument is providedfunc (m*Test) Test() *dagger.Container {
returndag.Container().From("alpine").
WithExec([]string{"sleep", "5"}).
WithExec([]string{"sleep", "2"})
}
if I run this, the sleep 5 exec will get re-executed.
// Returns a container that echoes whatever string argument is providedfunc (m*Second) Foo(context*dagger.Directory) *dagger.Container {
returndag.Container().From("alpine:latest").
WithMountedDirectory("/src", context).
WithExec([]string{"sleep", "5"})
}
// Returns lines that match a pattern in the files of the provided Directoryfunc (m*Second) Bar(context*dagger.Directory) *dagger.Container {
returnm.Foo(context).WithExec([]string{"sleep", "2"})
}
If you run dagger call foo --context . stdout and then dagger call bar --context . stdout, you'll notice that the sleep 5 will get re-executed. There's two catches which are also very odd:
If you remove the withMountedDirectory, caching works as expected
If you add another step below sleep 5 and run the same test as above, you'll notice that when calling bar, sleep 5 will be cached now, but the last step of the foo function won't.
Good call, that's definitely worth making sure of.
That said, there's still something else going on - the above shouldn't be going through the slow content cache. We should be able to look this up in the fast definition cache, so it seems likely that we're somehow generating subtly different buildkit operations between runs (and if we are, then why aren't we getting the same results)?
Introduced in #8818 I think - when we stopped "freezing" blobs of the local source. The dagql IDs are all correct with the MakeDirectoryContentHashed function, but, this doesn't change the LLB. The session: prefix is magical - and is essentially breaking cache here.
The solution will be part of our dagop work - when we port the code out of buildkit and into dagop, we can upload the entire directory, then snapshot it into buildkit, to get a consistent hash.
Activity
marcosnils commentedon Jan 28, 2025
👋 I can't seem to repro the above issue anymore. However, there's a new variation of this issue which manifested after a user reported a cache invalidation confusion here: https://discord.com/channels/707636530424053791/1120503349599543376/1333424111799763039
Here's the new code to reproduce:
If you run
dagger call foo --context . stdoutand thendagger call bar --context . stdout, you'll notice that thesleep 5will get re-executed. There's two catches which are also very odd:withMountedDirectory, caching works as expectedsleep 5and run the same test as above, you'll notice that when callingbar,sleep 5will be cached now, but the last step of thefoofunction won't.Something 🐟 is happening here.
helderco commentedon Jan 28, 2025
This seems related to:
WithMountedDirectory/WithMountedFiledoes not use content-based cache inwithExec#6421jedevc commentedon Jan 28, 2025
Good call, that's definitely worth making sure of.
That said, there's still something else going on - the above shouldn't be going through the slow content cache. We should be able to look this up in the fast definition cache, so it seems likely that we're somehow generating subtly different buildkit operations between runs (and if we are, then why aren't we getting the same results)?
jedevc commentedon Jul 3, 2025
Okay, the issue is here:
dagger/engine/sources/local/source.go
Line 152 in 84dc5b3
Introduced in #8818 I think - when we stopped "freezing" blobs of the local source. The dagql IDs are all correct with the
MakeDirectoryContentHashedfunction, but, this doesn't change the LLB. Thesession:prefix is magical - and is essentially breaking cache here.The solution will be part of our dagop work - when we port the code out of buildkit and into dagop, we can upload the entire directory, then snapshot it into buildkit, to get a consistent hash.
jedevc commentedon Jul 3, 2025
test: TestWithMountedDirectoryCaching
test: TestWithMountedDirectoryCaching
test: TestWithMountedDirectoryCaching
test: TestWithMountedDirectoryCaching
test: TestWithMountedDirectoryCaching
test: TestWithMountedDirectoryCaching (#11800)
sipsma commentedon Mar 1, 2026
#11856 has the fix