Skip to content

persist metadata to skip remote reads on restart in DB mode - #2229

Open
wswsmao wants to merge 1 commit into
containerd:mainfrom
wswsmao:db
Open

persist metadata to skip remote reads on restart in DB mode#2229
wswsmao wants to merge 1 commit into
containerd:mainfrom
wswsmao:db

Conversation

@wswsmao

@wswsmao wswsmao commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Fix: #2228

test case:

nerdctl pull --snapshotter stargz ghcr.io/stargz-containers/ubuntu:24.04-zstdchunked
nerdctl pull --snapshotter stargz ghcr.io/stargz-containers/python:3.13-zstdchunked

ls /var/lib/containerd-stargz-grpc/snapshotter/snapshots/
1  2  3  4  5  6  7  8  9


before:
time systemctl restart stargz-snapshotter.service
real    0m14.576s
user    0m0.014s
sys     0m0.004s

after:
time systemctl restart stargz-snapshotter.service 

real    0m4.039s
user    0m0.008s
sys     0m0.009s

Signed-off-by: abushwang <abushwang@tencent.com>
@wswsmao

wswsmao commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

@ktock

Comment thread snapshot/snapshot.go
Comment on lines +442 to +459
keep := make(map[string]struct{})
if err := storage.WalkInfo(txCtx, func(ctx context.Context, info snapshots.Info) error {
if _, ok := info.Labels[remoteLabel]; !ok {
return nil
}
if dgst, ok := info.Labels[targetStargzLayerDigestLabel]; ok && dgst != "" {
keep[dgst] = struct{}{}
}
if dgst, ok := info.Labels[targetCRILayerDigestLabel]; ok && dgst != "" {
keep[dgst] = struct{}{}
}
return nil
}); err != nil {
log.G(ctx).WithError(err).Warn("failed to walk snapshots for metadata prune")
return
}

if err := p.PruneMetadata(ctx, keep); err != nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are the stargz layer digests explicitly passed to the PruneMetadata? Doesn't the db track only the stargz layers already?

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.

DB metadata mode causes slow restarts due to unnecessary remote footer/TOC reads

2 participants