From a493fab603ef565f7683bcaf495c21c7a1dcec6e Mon Sep 17 00:00:00 2001 From: Erik Sipsma Date: Sun, 10 Apr 2022 19:58:55 -0700 Subject: [PATCH] cache: set all merge+diff refs non-mutable on load. This fixes merge+diff refs from v0.10.{0,1} that weren't set as committed. Signed-off-by: Erik Sipsma --- cache/manager.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cache/manager.go b/cache/manager.go index 0b51cef231f3..7d11d3b46f6b 100644 --- a/cache/manager.go +++ b/cache/manager.go @@ -458,6 +458,13 @@ func (cm *cacheManager) getRecord(ctx context.Context, id string, opts ...RefOpt cacheMetadata: md, } + // TODO:(sipsma) this is kludge to deal with a bug in v0.10.{0,1} where + // merge and diff refs didn't have committed set to true: + // https://github.com/moby/buildkit/issues/2740 + if kind := rec.kind(); kind == Merge || kind == Diff { + rec.mutable = false + } + // the record was deleted but we crashed before data on disk was removed if md.getDeleted() { if err := rec.remove(ctx, true); err != nil {