Merge pull request #10171 from fuweid/follow-up-10158
core/metadata: failfast on content.Commit
This commit is contained in:
commit
6c72ad9565
@ -574,12 +574,17 @@ func (nw *namespacedWriter) Commit(ctx context.Context, size int64, expected dig
|
|||||||
|
|
||||||
var innerErr error
|
var innerErr error
|
||||||
|
|
||||||
// We pre-sync the in-flight writes to the disk. This avoids the [subsequent fp.Sync() call]
|
// We pre-sync the in-flight writes to the disk. This avoids the
|
||||||
// (https://github.com/containerd/containerd/blob/c4c3c6ea568ce0cfbcf754863abadeea37d77c8f/plugins/content/local/writer.go#L95)
|
// subsequent fp.Sync() call[1] from taking too long (10s+) while
|
||||||
// from taking too long (10s+) while holding the metadata database lock as in the following
|
// holding the metadata database lock as in the following `update`
|
||||||
// `update` transaction. We intentionally ignore any error on Sync() because it will be
|
// transaction.
|
||||||
// handled by the subsequent `fp.Sync` anyway.
|
//
|
||||||
nw.Sync()
|
// 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 {
|
if err := update(ctx, nw.db, func(tx *bolt.Tx) error {
|
||||||
dgst, err := nw.commit(ctx, tx, size, expected, opts...)
|
dgst, err := nw.commit(ctx, tx, size, expected, opts...)
|
||||||
|
Loading…
Reference in New Issue
Block a user