core/metadata: failfast on content.Commit
Close: #10158 Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
2ec82c4703
commit
99ad11a00a
@ -574,12 +574,17 @@ func (nw *namespacedWriter) Commit(ctx context.Context, size int64, expected dig
|
||||
|
||||
var innerErr error
|
||||
|
||||
// We pre-sync the in-flight writes to the disk. This avoids the [subsequent fp.Sync() call]
|
||||
// (https://github.com/containerd/containerd/blob/c4c3c6ea568ce0cfbcf754863abadeea37d77c8f/plugins/content/local/writer.go#L95)
|
||||
// from taking too long (10s+) while holding the metadata database lock as in the following
|
||||
// `update` transaction. We intentionally ignore any error on Sync() because it will be
|
||||
// handled by the subsequent `fp.Sync` anyway.
|
||||
nw.Sync()
|
||||
// We pre-sync the in-flight writes to the disk. This avoids the
|
||||
// subsequent fp.Sync() call[1] from taking too long (10s+) while
|
||||
// holding the metadata database lock as in the following `update`
|
||||
// transaction.
|
||||
//
|
||||
// REF:
|
||||
// [1]: https://github.com/containerd/containerd/blob/c4c3c6ea568ce0cfbcf754863abadeea37d77c8f/plugins/content/local/writer.go#L95
|
||||
if err := nw.Sync(); err != nil {
|
||||
nw.Close()
|
||||
return fmt.Errorf("failed to perform sync: %w", err)
|
||||
}
|
||||
|
||||
if err := update(ctx, nw.db, func(tx *bolt.Tx) error {
|
||||
dgst, err := nw.commit(ctx, tx, size, expected, opts...)
|
||||
|
Loading…
Reference in New Issue
Block a user