From b35079f911b15f563ac6cf3d733d12cf3ae3d0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 19 Oct 2022 05:37:40 +0200 Subject: [PATCH 1/2] Fix locking in CreateContainer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't immediately unlock the layer store after locking it. Luckily it only matters for additional stores. Signed-off-by: Miloslav Trmač --- store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store.go b/store.go index 656b9b4e47..ad3ca2734f 100644 --- a/store.go +++ b/store.go @@ -1445,7 +1445,7 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat if err := store.startReading(); err != nil { return nil, err } - store.stopReading() + defer store.stopReading() } if err := istore.startWriting(); err != nil { return nil, err From 5c6186fe81dd19e39be66155c5fb9c52961a4a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 19 Oct 2022 06:35:44 +0200 Subject: [PATCH 2/2] Fix {layerStore,imageStore}.startWriting() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a bad bug: we wouldn't reload state from disk at all in writers. Signed-off-by: Miloslav Trmač --- images.go | 2 +- layers.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images.go b/images.go index 2a84b7e2cb..5f3640a18e 100644 --- a/images.go +++ b/images.go @@ -221,7 +221,7 @@ func (r *imageStore) startWritingWithReload(canReload bool) error { // startWriting makes sure the store is fresh, and locks it for writing. // If this succeeds, the caller MUST call stopWriting(). func (r *imageStore) startWriting() error { - return r.startWritingWithReload(false) + return r.startWritingWithReload(true) } // stopWriting releases locks obtained by startWriting. diff --git a/layers.go b/layers.go index 9eececccc1..f291fcddbd 100644 --- a/layers.go +++ b/layers.go @@ -343,7 +343,7 @@ func (r *layerStore) startWritingWithReload(canReload bool) error { // startWriting makes sure the store is fresh, and locks it for writing. // If this succeeds, the caller MUST call stopWriting(). func (r *layerStore) startWriting() error { - return r.startWritingWithReload(false) + return r.startWritingWithReload(true) } // stopWriting releases locks obtained by startWriting.