This repository was archived by the owner on Nov 19, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 19, 2026. It is now read-only.
Panic: attempted to update last-writer in lockfile without the write lock #1324
Copy link
Copy link
Closed
Description
For some reason, I had an incomplete layer (according to the log file) and the nearest Podman's PlayKube command led to panic in the storage module. A cropped part of the stack trace (see full in the attach):
Sep 07 06:24:54 host podman[468]: time="2022-09-07T06:24:54Z" level=warning msg="Found incomplete layer "b229cb7be9f40343b5938e9ea4c58cbe9245da1ebbda2bd0e1b4600b56036080", deleting it"
Sep 07 06:24:54 host podman[468]: time="2022-09-07T06:24:54Z" level=warning msg="Recovering from API service endpoint handler panic: attempted to update last-writer in lockfile without the write lock, goroutine 43 [running]:
github.com/containers/podman/v4/pkg/api/server.panicHandler.func1.1.1
github.com/containers/podman/v4/pkg/api/server/handler_panic.go:22 +0x78
panic
runtime/panic.go:1038 +0x23c
github.com/containers/storage/pkg/lockfile.(*lockfile).Touch
github.com/containers/[email protected]/pkg/lockfile/lockfile_unix.go:247 +0x198
github.com/containers/storage.(*layerStore).Touch
github.com/containers/[email protected]/layers.go:1897 +0x28
github.com/containers/storage.(*layerStore).saveLayers
github.com/containers/[email protected]/layers.go:498 +0x1d4
github.com/containers/storage.(*layerStore).Load
github.com/containers/[email protected]/layers.go:422 +0x534
github.com/containers/storage.(*store).newLayerStore
github.com/containers/[email protected]/layers.go:559 +0x39c
github.com/containers/storage.(*store).LayerStore
github.com/containers/[email protected]/store.go:913 +0x398
github.com/containers/storage.(*store).layersByMappedDigest
github.com/containers/[email protected]/store.go:3030 +0x40
github.com/containers/storage.(*store).LayersByUncompressedDigest
github.com/containers/[email protected]/store.go:3072 +0xf8
github.com/containers/image/v5/storage.(*storageImageSource).getBlobAndLayerID
github.com/containers/image/[email protected]/storage/storage_image.go:202 +0x70
github.com/containers/image/v5/storage.(*storageImageSource).GetBlob
github.com/containers/image/[email protected]/storage/storage_image.go:163 +0x98
github.com/containers/image/v5/internal/image.(*manifestOCI1).ConfigBlob
github.com/containers/image/[email protected]/internal/image/oci.go:66 +0x148
github.com/containers/image/v5/internal/image.(*manifestOCI1).OCIConfig
github.com/containers/image/[email protected]/internal/image/oci.go:92 +0xa8
github.com/containers/podman/v4/libpod.(*storageService).CreateContainerStorage
github.com/containers/podman/v4/libpod/storage.go:92 +0x1e4
github.com/containers/podman/v4/libpod.(*Container).setupStorage
github.com/containers/podman/v4/libpod/container_internal.go:506 +0x6e4
github.com/containers/podman/v4/libpod.(*Runtime).setupContainer
github.com/containers/podman/v4/libpod/runtime_ctr.go:424 +0x1178
github.com/containers/podman/v4/libpod.(*Runtime).newContainer
github.com/containers/podman/v4/libpod/runtime_ctr.go:236 +0x184
github.com/containers/podman/v4/libpod.(*Runtime).NewContainer
github.com/containers/podman/v4/libpod/runtime_ctr.go:52 +0xf8
github.com/containers/podman/v4/pkg/specgen/generate.ExecuteCreate
github.com/containers/podman/v4/pkg/specgen/generate/container_create.go:239 +0x5c
github.com/containers/podman/v4/pkg/specgen/generate.MakePod
github.com/containers/podman/v4/pkg/specgen/generate/pod_create.go:66 +0x4c0
github.com/containers/podman/v4/pkg/domain/infra/abi.(*ContainerEngine).playKubePod
github.com/containers/podman/v4/pkg/domain/infra/abi/play.go:464 +0x1820
github.com/containers/podman/v4/pkg/domain/infra/abi.(*ContainerEngine).PlayKube
github.com/containers/podman/v4/pkg/domain/infra/abi/play.go:174 +0x12ec
github.com/containers/podman/v4/pkg/api/handlers/libpod.PlayKube
Full log with panic: podman-panic.log
It seems like the wrong condition - layers.go#L397 because Locked function may return true even if the lock is owned by other thread. So the lock may be released at any time after the Locked function returns true. Probably we should acquire reader lock in newLayerStore.
Metadata
Metadata
Assignees
Labels
No labels
Activity
rhatdan commentedon Sep 7, 2022
@nalind @giuseppe @vrothberg PTAL
nalind commentedon Sep 7, 2022
We need to be taking either a read lock or a write lock before calling the new layer store's
Load()method innewLayerStore(). At that pointLocked()will return the correct value, as it would if we calledLoadLocked()instead.Fix accessing to layer without lock
Fix accessing to layer without lock
tyler92 commentedon Sep 16, 2022
I created a PR but can't do a good enough check.
Fix accessing to layer without lock
Fix accessing to layer without lock
mtrmac commentedon Oct 14, 2022
I’m missing something about what has happened here. Looking at the backtrace, there are two goroutines waiting for
graphLock:and that’s fine.
But there also two goroutines holding
graphLock:and
Does anyone know what is going on here?
(I don’t fully understand the operation of
graphLock, but for now I’m focusing on that one simple mystery.)mtrmac commentedon Oct 14, 2022
But
Locked()had to returntrueeven without owning the lock, otherwise we couldn’t get to thesaveLayerscode path. AFAICS that’s another problem, #1388 .Fix accessing to layer without lock
Fix accessing to layer without lock
Fix accessing to layer without lock