[GH-ISSUE #6010] [Issue]: Stale writer lease sometimes prevents server restart #3329

Closed
opened 2026-10-21 06:02:02 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @SpicyMarinara on GitHub (Sep 9, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6010

Originally assigned to: @SpicyMarinara on GitHub.

Summary

On the latest staging build, Marinara Engine occasionally retains a storage writer lease after the server is stopped, preventing the next server startup. The issue is rare and appears after stopping via Ctrl-C in Termux or the in-engine Restart Server button.

Expected behavior

When Marinara Engine shuts down or restarts, it should release the storage writer lease, or automatically reclaim it when the previous process is no longer running, so the server can start without requiring a device reboot.

Actual behavior

The server sometimes fails to start with a StorageWriterLeaseError stating that another Marinara Engine process is using the storage directory. The lease remains uncleared until the phone is fully restarted; after reboot, Marinara Engine successfully detects and reclaims the stale lease.

Steps to reproduce

  1. Run Marinara Engine on Android through Termux.
  2. Stop the server with Ctrl-C in Termux or use the in-engine Restart Server button.
  3. Start or restart the server again.
  4. When the issue occurs, startup fails with a StorageWriterLeaseError for the storage directory.
  5. Fully restart the phone and start Marinara Engine again; the stale lease is then reclaimed.

Environment

  • Marinara Engine version: 2.4.5+712621d43205
  • Install type: termux
  • OS + version: Android 15; server running on Android / Termux kernel 5.10.209-android12-9-o-g63fb7a145195 (arm64)
  • Browser or app shell: Mozilla/5.0 (Android 15; Mobile; rv:155.0) Gecko/155.0 Firefox/155.0

Logs, screenshots, or video

Server exited with status 1 during bootstrap: StorageWriterLeaseError: Another Marinara Engine process (PID 10036, host localhost) may be using /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage. The error referenced storage/.writer-lease and occurred in FileTableStore.acquireWriterLease during server initialization. After a phone reboot, the server logged: {"previousPid":10036,"path":"/data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease","staleReason":"boot","hostProof":"termux-home","msg":"[file-storage] Reclaimed the writer lease after detecting that the previous owner belonged to an earlier boot."}

Additional context

Observed rarely on the latest staging build and not deterministically reproducible. Support diagnostics reported the previous session as "unknown - another server instance is using this data directory" and recorded six sessions that ended without shutdown. The diagnostic also recorded a prior client chunk/render error, but its relationship to the lease issue is not established.

Discord thread: ME writer lease lock error still occurs rarely
Discord thread link: https://discord.com/channels/1417099416812392641/1547334668846891008
Requested by: Kuc0 (kuc0, Discord ID 108988150629531648)

Discord thread transcript (4 messages)
[2026-09-09T19:55:33.141Z] DSBwizzard: Marinara Engine diagnostics
Version: 2.4.5
Build: 2.4.5+712621d43205
Commit: 712621d43205
Server OS: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64)
Server memory: heap 85.2 / 1120 MiB; RSS 125.9 MiB
Background wake lock: acquired
Last detected freeze: none detected
Previous session: unknown - another server instance is using this data directory
Sessions ended without shutdown: 6 recorded
Client OS: Android 15
Browser / app shell: Mozilla/5.0 (Android 15; Mobile; rv:155.0) Gecko/155.0 Firefox/155.0
Client runtime: {"build":"2.4.5+712621d43205","page":"mtuiv0r6-oxyxv0q0","persistence":"local","navigation":"reload","standalone":false,"view":[664,0,664,0],"events":[{"at":1788974853799,"page":"mtuc1i9k-fbnmld0l","build":"2.4.5+1cf7c57cec0c","kind":"hidden","view":[664,0,664,0]},{"at":1788983420682,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"page-start","view":[664,0,664,0]},{"at":1788983420811,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"page-show","view":[664,0,664,0]},{"at":1788983429374,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"hidden","view":[664,0,664,0]},{"at":1788983430823,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"chunk-error","error":"TypeError","view":[664,0,664,0]},{"at":1788983430826,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"reload-requested","reason":"chunk-recovery","view":[664,0,664,0]},{"at":1788983431047,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"render-error","error":"TypeError","asset":"RightPanel-BIq-DdpS.js:2:2765","view":[664,0,664,0]},{"at":1788983431350,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"page-hide","view":[664,0,664,0]},{"at":1788983955222,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"page-start","view":[664,0,664,0]},{"at":1788983955311,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"promise-error","error":"Unknown","view":[664,0,664,0]},{"at":1788983955317,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"page-hide","view":[664,0,664,0]},{"at":1788983955317,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"hidden","view":[664,0,664,0]},{"at":1788983963538,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"page-start","view":[664,0,664,0]},{"at":1788983963606,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"page-show","view":[664,0,664,0]},{"at":1788983980713,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"hidden","view":[664,0,664,0]},{"at":1788983986922,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"visible","view":[664,0,664,0]}]}
GPU: Adreno (TM) 650, or similar
Active connection: Gemini Pro Latest
Connection provider: custom
LLM model: models/gemini-pro-latest
Mari last acted on: none recorded this session

----------

On latest staging I still occasionally see the following lease lock error which requires my to fully restart my phone to clear. It's rare, but overall seemingly randomly after shutting off ME ( Ctrl-C in Termux, or in-engine 'Restart Server' button).

Log attached below.
[Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547334668846891008]

[2026-09-09T19:55:33.688Z] Professor Mari [bot]: Howdy!

Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.**

**Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab:

`Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.`

If your report is about any of the **Agents**, please provide **the Agent's version** which you can grab from here:

`Agents -> Download Agents -> Installed Agents -> Selected Agent -> Installed Version`

Thank you, this will help tremendously.

This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case.

Cheers!
[Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547334671140921376]

[2026-09-09T19:55:58.400Z] DSBwizzard: {"level":50,"time":1788983505521,"pid":11655,"hostname":"localhost","err":{"type":"StorageWriterLeaseError","message":"Another Marinara Engine process (PID 10036, host localhost) may be using /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage. Close it before retrying. If it no longer exists, verify every process is stopped and remove only /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease.","stack":"StorageWriterLeaseError: Another Marinara Engine process (PID 10036, host localhost) may be using /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage. Close it before retrying. If it no longer exists, verify every process is stopped and remove only /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease.\n    at FileTableStore.acquireWriterLease (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/file-backed-store.js:1729:15)\n    at FileTableStore.initialize (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/file-backed-store.js:1814:16)\n    at createFileNativeDB (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/file-backed-store.js:3946:15)\n    at createStorage (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/connection.js:7:20)\n    at getDB (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/connection.js:17:17)\n    at buildApp (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/app.js:103:20)\n    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n    at async main (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/index.js:48:15)","name":"StorageWriterLeaseError"},"msg":"[startup] Unhandled error during server bootstrap"}       [ERROR] Marinara Engine server exited with status 1.
[Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547334774790684683]

[2026-09-09T19:58:56.440Z] DSBwizzard: ----

Upon phone restart I see ME successfully locate and clear a less lock, so... Not sure why it fails to do so sometimes as described above. :Shrug: 

{"level":40,"time":1788983881209,"pid":12566,"hostname":"localhost","previousPid":10036,"path":"/data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease","staleReason":"boot","hostProof":"termux-home","msg":"[file-storage] Reclaimed the writer lease after detecting that the previous owner belonged to an earlier boot."}
[Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547335521544441957]

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 @SpicyMarinara on GitHub (Sep 9, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6010 Originally assigned to: @SpicyMarinara on GitHub. ## Summary On the latest staging build, Marinara Engine occasionally retains a storage writer lease after the server is stopped, preventing the next server startup. The issue is rare and appears after stopping via Ctrl-C in Termux or the in-engine Restart Server button. ## Expected behavior When Marinara Engine shuts down or restarts, it should release the storage writer lease, or automatically reclaim it when the previous process is no longer running, so the server can start without requiring a device reboot. ## Actual behavior The server sometimes fails to start with a StorageWriterLeaseError stating that another Marinara Engine process is using the storage directory. The lease remains uncleared until the phone is fully restarted; after reboot, Marinara Engine successfully detects and reclaims the stale lease. ## Steps to reproduce 1. Run Marinara Engine on Android through Termux. 2. Stop the server with Ctrl-C in Termux or use the in-engine Restart Server button. 3. Start or restart the server again. 4. When the issue occurs, startup fails with a StorageWriterLeaseError for the storage directory. 5. Fully restart the phone and start Marinara Engine again; the stale lease is then reclaimed. ## Environment - Marinara Engine version: 2.4.5+712621d43205 - Install type: termux - OS + version: Android 15; server running on Android / Termux kernel 5.10.209-android12-9-o-g63fb7a145195 (arm64) - Browser or app shell: Mozilla/5.0 (Android 15; Mobile; rv:155.0) Gecko/155.0 Firefox/155.0 ## Logs, screenshots, or video Server exited with status 1 during bootstrap: StorageWriterLeaseError: Another Marinara Engine process (PID 10036, host localhost) may be using /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage. The error referenced storage/.writer-lease and occurred in FileTableStore.acquireWriterLease during server initialization. After a phone reboot, the server logged: {"previousPid":10036,"path":"/data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease","staleReason":"boot","hostProof":"termux-home","msg":"[file-storage] Reclaimed the writer lease after detecting that the previous owner belonged to an earlier boot."} ## Additional context Observed rarely on the latest staging build and not deterministically reproducible. Support diagnostics reported the previous session as "unknown - another server instance is using this data directory" and recorded six sessions that ended without shutdown. The diagnostic also recorded a prior client chunk/render error, but its relationship to the lease issue is not established. Discord thread: ME writer lease lock error still occurs rarely Discord thread link: https://discord.com/channels/1417099416812392641/1547334668846891008 Requested by: Kuc0 (kuc0, Discord ID 108988150629531648) <details> <summary>Discord thread transcript (4 messages)</summary> ```text [2026-09-09T19:55:33.141Z] DSBwizzard: Marinara Engine diagnostics Version: 2.4.5 Build: 2.4.5+712621d43205 Commit: 712621d43205 Server OS: Android / Termux 5.10.209-android12-9-o-g63fb7a145195 (arm64) Server memory: heap 85.2 / 1120 MiB; RSS 125.9 MiB Background wake lock: acquired Last detected freeze: none detected Previous session: unknown - another server instance is using this data directory Sessions ended without shutdown: 6 recorded Client OS: Android 15 Browser / app shell: Mozilla/5.0 (Android 15; Mobile; rv:155.0) Gecko/155.0 Firefox/155.0 Client runtime: {"build":"2.4.5+712621d43205","page":"mtuiv0r6-oxyxv0q0","persistence":"local","navigation":"reload","standalone":false,"view":[664,0,664,0],"events":[{"at":1788974853799,"page":"mtuc1i9k-fbnmld0l","build":"2.4.5+1cf7c57cec0c","kind":"hidden","view":[664,0,664,0]},{"at":1788983420682,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"page-start","view":[664,0,664,0]},{"at":1788983420811,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"page-show","view":[664,0,664,0]},{"at":1788983429374,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"hidden","view":[664,0,664,0]},{"at":1788983430823,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"chunk-error","error":"TypeError","view":[664,0,664,0]},{"at":1788983430826,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"reload-requested","reason":"chunk-recovery","view":[664,0,664,0]},{"at":1788983431047,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"render-error","error":"TypeError","asset":"RightPanel-BIq-DdpS.js:2:2765","view":[664,0,664,0]},{"at":1788983431350,"page":"mtuijdvu-bc10i6to","build":"2.4.5+1cf7c57cec0c","kind":"page-hide","view":[664,0,664,0]},{"at":1788983955222,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"page-start","view":[664,0,664,0]},{"at":1788983955311,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"promise-error","error":"Unknown","view":[664,0,664,0]},{"at":1788983955317,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"page-hide","view":[664,0,664,0]},{"at":1788983955317,"page":"mtuiuuc6-72zcdmu7","build":"2.4.5+1cf7c57cec0c","kind":"hidden","view":[664,0,664,0]},{"at":1788983963538,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"page-start","view":[664,0,664,0]},{"at":1788983963606,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"page-show","view":[664,0,664,0]},{"at":1788983980713,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"hidden","view":[664,0,664,0]},{"at":1788983986922,"page":"mtuiv0r6-oxyxv0q0","build":"2.4.5+712621d43205","kind":"visible","view":[664,0,664,0]}]} GPU: Adreno (TM) 650, or similar Active connection: Gemini Pro Latest Connection provider: custom LLM model: models/gemini-pro-latest Mari last acted on: none recorded this session ---------- On latest staging I still occasionally see the following lease lock error which requires my to fully restart my phone to clear. It's rare, but overall seemingly randomly after shutting off ME ( Ctrl-C in Termux, or in-engine 'Restart Server' button). Log attached below. [Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547334668846891008] [2026-09-09T19:55:33.688Z] Professor Mari [bot]: Howdy! Thank you for submitting a new bug report/feature request, your support means a lot. A member of the team will look into it as soon as possible, and if they find it valid, they will open a GitHub Issue out of it. You can check whether it was addressed on the staging build of Marinara Engine. **Do not ping any of the developers, this will not speed up the process.** **Please include a Support Diagnostic in the post if you haven't done it yet.** Otherwise, ignore this step. To grab it, go to the Marinara Engine tab: `Settings -> Advanced -> Support Diagnostics -> Copy Support Diagnostics.` If your report is about any of the **Agents**, please provide **the Agent's version** which you can grab from here: `Agents -> Download Agents -> Installed Agents -> Selected Agent -> Installed Version` Thank you, this will help tremendously. This is an automated message, but if you reply to it, I will do my best to assist you using my LLM-powered brain. That said, it's best for a human to handle this case. Cheers! [Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547334671140921376] [2026-09-09T19:55:58.400Z] DSBwizzard: {"level":50,"time":1788983505521,"pid":11655,"hostname":"localhost","err":{"type":"StorageWriterLeaseError","message":"Another Marinara Engine process (PID 10036, host localhost) may be using /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage. Close it before retrying. If it no longer exists, verify every process is stopped and remove only /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease.","stack":"StorageWriterLeaseError: Another Marinara Engine process (PID 10036, host localhost) may be using /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage. Close it before retrying. If it no longer exists, verify every process is stopped and remove only /data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease.\n at FileTableStore.acquireWriterLease (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/file-backed-store.js:1729:15)\n at FileTableStore.initialize (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/file-backed-store.js:1814:16)\n at createFileNativeDB (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/file-backed-store.js:3946:15)\n at createStorage (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/connection.js:7:20)\n at getDB (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/db/connection.js:17:17)\n at buildApp (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/app.js:103:20)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async main (file:///data/data/com.termux/files/home/Marinara-Engine/packages/server/dist/index.js:48:15)","name":"StorageWriterLeaseError"},"msg":"[startup] Unhandled error during server bootstrap"} [ERROR] Marinara Engine server exited with status 1. [Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547334774790684683] [2026-09-09T19:58:56.440Z] DSBwizzard: ---- Upon phone restart I see ME successfully locate and clear a less lock, so... Not sure why it fails to do so sometimes as described above. :Shrug: {"level":40,"time":1788983881209,"pid":12566,"hostname":"localhost","previousPid":10036,"path":"/data/data/com.termux/files/home/Marinara-Engine/packages/server/data/storage/.writer-lease","staleReason":"boot","hostProof":"termux-home","msg":"[file-storage] Reclaimed the writer lease after detecting that the previous owner belonged to an earlier boot."} [Discord message: https://discord.com/channels/1417099416812392641/1547334668846891008/1547335521544441957] ``` </details> ## 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 06:02:02 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 9, 2026):

@SpicyMarinara is handling this report in draft PR #6011. Implementation and regression checks are in progress.

<!-- gh-comment-id:5608445965 --> @SpicyMarinara commented on GitHub (Sep 9, 2026): @SpicyMarinara is handling this report in draft PR #6011. Implementation and regression checks are in progress.
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#3329
No description provided.