[GH-ISSUE #5389] [Issue]: Stale storage lock prevents recreated Docker container from starting #2985

Closed
opened 2026-10-21 05:58:36 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @NeoKazuya on GitHub (Aug 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5389

Originally assigned to: @SpicyMarinara on GitHub.

Summary

While Marinara is running, it creates /app/data/storage/.writer-lease to stop two processes from writing to the same data folder at once. If a Docker container stops before Marinara removes that lock, a replacement container can have a different hostname while reusing the same internal process number (PID). The current lock check then cannot confirm that the old container is gone, so the replacement refuses to start.

Expected behavior

When the old container is gone and Marinara can safely verify that, a replacement container should start without requiring manual lock removal. It should still refuse to start if another process or container may actually be using the same data folder.

Actual behavior

The old lock recorded PID 14 and the hostname of the previous container. The recreated container received a new hostname but also ran as PID 14. Because PID 14 was already running again inside the replacement, the current lock check could not confirm that the previous container was gone. Every startup attempt failed with StorageWriterLeaseError until the stale lock was removed manually.

Steps to reproduce

  1. Run Marinara in Docker with a persistent folder mounted at /app/data.
  2. Stop the container without allowing shutdown cleanup to finish, such as by force-stopping it while Marinara is active.
  3. Recreate and start the container with the same mounted data folder.
  4. If the replacement reuses the recorded internal PID, observe repeated StorageWriterLeaseError failures even though the old container no longer exists.

Environment

  • Marinara Engine version: reproduced on staging at source revision 57e29c8b63c4fb19bbffe027ef299966e8b6752c; originally observed at 9a810f64edb131c21735616f8fdce5265440af39
  • Install type: Docker with a host folder mounted at /app/data
  • OS + version: TrueNAS SCALE 25.04.2.6 on Linux/amd64
  • Browser or app shell: Not applicable; server bootstrap fails before the app starts

Logs, screenshots, or video

Current container: PID 14, hostname e0c30d54b5ba

StorageWriterLeaseError: Another Marinara Engine process (PID 14, host 6a161f10dc25) may be using /app/data/storage. Close it before retrying. If it no longer exists, verify every process is stopped and remove only /app/data/storage/.writer-lease.

The old and replacement containers had different hostnames but both used PID 14. The replacement repeatedly exited during server bootstrap.

The same failure was reproduced on current staging with a disposable Docker volume. The old and replacement containers had different hostnames but both used PID 13. The replacement exited with code 1 and left the old lock unchanged.

After recovery, the replacement container remained running with restart count 0, listened on 0.0.0.0:7860, and created a new lock containing PID 14 and its current hostname e0c30d54b5ba.

Additional context

The storage lock added in #5014 requires manual recovery when Marinara cannot verify that the previous process has stopped. Recreating the container triggered that fallback, so .writer-lease had to be removed manually.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @NeoKazuya on GitHub (Aug 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5389 Originally assigned to: @SpicyMarinara on GitHub. ## Summary While Marinara is running, it creates `/app/data/storage/.writer-lease` to stop two processes from writing to the same data folder at once. If a Docker container stops before Marinara removes that lock, a replacement container can have a different hostname while reusing the same internal process number (PID). The current lock check then cannot confirm that the old container is gone, so the replacement refuses to start. ## Expected behavior When the old container is gone and Marinara can safely verify that, a replacement container should start without requiring manual lock removal. It should still refuse to start if another process or container may actually be using the same data folder. ## Actual behavior The old lock recorded PID 14 and the hostname of the previous container. The recreated container received a new hostname but also ran as PID 14. Because PID 14 was already running again inside the replacement, the current lock check could not confirm that the previous container was gone. Every startup attempt failed with `StorageWriterLeaseError` until the stale lock was removed manually. ## Steps to reproduce 1. Run Marinara in Docker with a persistent folder mounted at `/app/data`. 2. Stop the container without allowing shutdown cleanup to finish, such as by force-stopping it while Marinara is active. 3. Recreate and start the container with the same mounted data folder. 4. If the replacement reuses the recorded internal PID, observe repeated `StorageWriterLeaseError` failures even though the old container no longer exists. ## Environment - Marinara Engine version: reproduced on `staging` at source revision `57e29c8b63c4fb19bbffe027ef299966e8b6752c`; originally observed at `9a810f64edb131c21735616f8fdce5265440af39` - Install type: Docker with a host folder mounted at `/app/data` - OS + version: TrueNAS SCALE 25.04.2.6 on Linux/amd64 - Browser or app shell: Not applicable; server bootstrap fails before the app starts ## Logs, screenshots, or video ```text Current container: PID 14, hostname e0c30d54b5ba StorageWriterLeaseError: Another Marinara Engine process (PID 14, host 6a161f10dc25) may be using /app/data/storage. Close it before retrying. If it no longer exists, verify every process is stopped and remove only /app/data/storage/.writer-lease. ``` The old and replacement containers had different hostnames but both used PID 14. The replacement repeatedly exited during server bootstrap. The same failure was reproduced on current `staging` with a disposable Docker volume. The old and replacement containers had different hostnames but both used PID 13. The replacement exited with code 1 and left the old lock unchanged. After recovery, the replacement container remained running with restart count 0, listened on `0.0.0.0:7860`, and created a new lock containing PID 14 and its current hostname `e0c30d54b5ba`. ## Additional context The storage lock added in #5014 requires manual recovery when Marinara cannot verify that the previous process has stopped. Recreating the container triggered that fallback, so `.writer-lease` had to be removed manually. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:58:36 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 22, 2026):

Thank you for the PR. <3

<!-- gh-comment-id:5380690530 --> @SpicyMarinara commented on GitHub (Aug 22, 2026): Thank you for the PR. <3
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2985
No description provided.