Skip to content

Commit 6c72ad9

Browse files
author
Maksym Pavlenko
authored
Merge pull request containerd#10171 from fuweid/follow-up-10158
core/metadata: failfast on content.Commit
2 parents 114ef75 + 99ad11a commit 6c72ad9

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

core/metadata/content.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,17 @@ func (nw *namespacedWriter) Commit(ctx context.Context, size int64, expected dig
574574

575575
var innerErr error
576576

577-
// We pre-sync the in-flight writes to the disk. This avoids the [subsequent fp.Sync() call]
578-
// (https://github.com/containerd/containerd/blob/c4c3c6ea568ce0cfbcf754863abadeea37d77c8f/plugins/content/local/writer.go#L95)
579-
// from taking too long (10s+) while holding the metadata database lock as in the following
580-
// `update` transaction. We intentionally ignore any error on Sync() because it will be
581-
// handled by the subsequent `fp.Sync` anyway.
582-
nw.Sync()
577+
// We pre-sync the in-flight writes to the disk. This avoids the
578+
// subsequent fp.Sync() call[1] from taking too long (10s+) while
579+
// holding the metadata database lock as in the following `update`
580+
// transaction.
581+
//
582+
// REF:
583+
// [1]: https://github.com/containerd/containerd/blob/c4c3c6ea568ce0cfbcf754863abadeea37d77c8f/plugins/content/local/writer.go#L95
584+
if err := nw.Sync(); err != nil {
585+
nw.Close()
586+
return fmt.Errorf("failed to perform sync: %w", err)
587+
}
583588

584589
if err := update(ctx, nw.db, func(tx *bolt.Tx) error {
585590
dgst, err := nw.commit(ctx, tx, size, expected, opts...)

0 commit comments

Comments
 (0)