{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreidpbonbeiizadeef2vrx56qxsqbisxftpy3tfj2b5yzeccouj4coa",
"uri": "at://did:plc:pvz7ox4x2ehjiezsahttqyyz/app.bsky.feed.post/3mhdbyxokbkt2"
},
"path": "/viewtopic.php?p=450089#p450089",
"publishedAt": "2026-03-18T10:18:19.000Z",
"site": "https://forum.luanti.org",
"tags": [
"MatyasP"
],
"textContent": "> > 2026-03-17 17:18:17: ERROR[Main]: Failed to set SQLite3 synchronous mode: database is locked\n>\n> It looks like you have the world open already in singleplayer or another server instance. I get a similar one when using world downloading and running a server at the same time on the same computer. If there's nothing obviously running, try searching for crashed/zombie processes that have it open.\n\nThank you! It has more causes (synchronous SQLite, large -wal etc.)\n\nProblem solved.\nPart of this message (bellow this) created by AI (Google Gemini that helps me with it step by step) and checked and repaired by human.\n\n##\n\nPost-Mortem: Luanti Server Crash & SQLite Database Lock\n\n**Root Cause**\nThe server experienced a fatal crash triggered by a Lua runtime error in a mod (railbuilder), which attempted to index a nil value during a global step. This occurred during high I/O activity (multiple users building tracks).\n\nThe situation was exacerbated by a misconfiguration in minetest.conf: sqlite_synchronous = 1 (NORMAL). On a server with a large 10GB database and heavy mods like AdvTrains, this caused an I/O bottleneck. When the crash happened, the SQLite checkpoint failed, leaving a massive 8.5GB -wal file and locking the database.\n\n**Symptoms**\n\n 1. Database is locked: The server failed to restart because the previous process didn't release the file lock, and the massive WAL file prevented a quick recovery.\n 2. Map Corruption/Ghost Blocks: Attempting to force-start by deleting journal files led to temporary synchronization issues between the old map.sqlite and the uncommitted data.\n 3. Extended \"Starting\" state: Pterodactyl panel stayed yellow for minutes as SQLite struggled to replay the oversized WAL log.\n\n**Resolution**\n\n 1. Manual Checkpoint: Downloaded the 10GB map.sqlite and 8.5GB map.sqlite-wal to a local high-performance machine (i7-13700).\n 2. Database Integration: Executed PRAGMA wal_checkpoint(TRUNCATE); via SQLite3 CLI to force-merge the logs into the main DB.\n 3. Optimization: Performed VACUUM; to defragment the 10M+ rows and fix indexing issues.\n 4. Code Fix: Patched railbuilder_ui.lua with a nil-check for player positions to prevent the specific crash from recurring.\n 5. Config Tuning: Set sqlite_synchronous = 0` and adjusted map_save_interval to 20s to prevent future I/O deadlocks on SATA SSD storage.\n\nStatus: Server fully recovered with zero data loss.\n\n\n\n\n\n\n\nStatistics: Posted by MatyasP — Wed Mar 18, 2026 10:18\n\n* * *",
"title": "Problems • Re: Server crashed for problem about DB",
"updatedAt": "2026-03-18T10:18:19.000Z"
}