Skip to content

[Bug] Unsloth Studio can enter a permanent SQLite mutex deadlock under concurrent database connection activity, leaving the backend process alive but completely unresponsive. #10022

Closed

Description

@Yash-g17

Environment

Where are you using Unsloth?

  • Unsloth web UI (unsloth studio)
  • Unsloth desktop application
  • Unsloth CLI
  • Python package or notebook
  • Colab or Kaggle

Operating system and version:

Ubuntu 24.04

GPU model(s) and accelerator backend:

NVIDIA CUDA

Versions:

  • Unsloth: 2026.8.22
  • Python: 3.13.12
  • SQLite: 3.51.1
  • Python sqlite3 module: 2.6.0
  • llama.cpp: running via Unsloth Studio; exact version not captured

What happened?

Steps to reproduce:

  1. Started Unsloth Studio web UI with unsloth studio -H 0.0.0.0 -p 8888.
  2. Loaded/used a GGUF model through the Studio UI:
    unsloth/Qwen3.8-27B-GGUF using Qwen3.8-27B-UD-IQ4_XS.gguf.
  3. After running the model, the Studio web UI became unresponsive. The Unsloth process remained alive and continued listening on port 8888.

Expected behavior:

Unsloth Studio should continue serving the web UI and HTTP requests normally while the model server is running.

Actual behavior:

The Unsloth Studio process remained alive and port 8888 remained in LISTEN state, but HTTP requests to the Studio server never returned.

For example:

curl --max-time 5 http://127.0.0.1:8888/

connected successfully but timed out with:

Operation timed out after 5002 milliseconds with 0 bytes received

The llama.cpp server used by Studio remained healthy throughout:

curl --max-time 5 http://127.0.0.1:55687/health

{"status":"ok"}

/v1/models also returned successfully.

The issue therefore appears to be isolated to the Unsloth Studio backend rather than the llama.cpp model server.

Root-cause evidence

A GDB inspection of the live Unsloth process revealed a circular deadlock inside SQLite.

Thread 3765163:

pthread_mutex_lock
  -> sqlite3 unixClose
  -> sqlite3PagerClose
  -> sqlite3BtreeClose
  -> sqlite3LeaveMutexAndCloseZombie
  -> sqlite3Close
  -> Python sqlite3.Connection.close()

This thread owned SQLite mutex:

0x76ed15d6dfc8

and was waiting for:

0x76eb04c05b98

The owner of 0x76eb04c05b98 was thread 3778698.

Thread 3778698 had this stack:

pthread_mutex_lock
  -> sqlite3 unixLock
  -> sqlite3WalClose
  -> sqlite3PagerClose
  -> sqlite3BtreeClose
  -> sqlite3LeaveMutexAndCloseZombie
  -> sqlite3Close
  -> Python sqlite3.Connection.close()

and was waiting for:

0x76ed15d6dfc8

Therefore the observed lock cycle was:

Thread 3765163
  owns mutex A
  waits for mutex B

Thread 3778698
  owns mutex B
  waits for mutex A

Multiple additional Studio threads were simultaneously blocked attempting to open SQLite connections, including calls through:

pysqlite_connection_init
 -> openDatabase
 -> sqlite3BtreeOpen
 -> unixOpen
 -> findReusableFd

The SQLite database involved was:

~/.unsloth/studio/studio.db

It is configured for WAL mode.

The database itself does not appear to be corrupted:

PRAGMA journal_mode;
wal

PRAGMA integrity_check;
ok

Model and operation involved

Model:

unsloth/Qwen3.8-27B-GGUF

GGUF file:

Qwen3.8-27B-UD-IQ4_XS.gguf

llama.cpp command included:

--parallel 4
--flash-attn on
--no-context-shift
-c 125824
--fit on
--metrics
--kv-unified
--fit-ctx 125824
--jinja
--cache-type-k q4_0
--cache-type-v q4_0
--chat-template-kwargs {"enable_thinking": true, "preserve_thinking": true}

During the incident, the llama.cpp process remained healthy and /health continued returning HTTP 200.

Diagnostics and logs

Unsloth web UI

Relevant server log:

~/.unsloth/studio/logs/server/server-20260830-122027-pid3519800.log

The beginning of the log shows normal startup:

{"timestamp": "2026-08-30T06:50:27.279115Z", "level": "info", "event": "run_server startup begin api_only=False host=0.0.0.0 port=8888"}
Loading Unsloth Studio, please wait...
  - loading PyTorch, Unsloth and Transformers...
{"timestamp": "2026-08-30T06:50:28.336096Z", "level": "info", "event": "Imported FastAPI app in 991.9ms"}
  - Starting server...
{"timestamp": "2026-08-30T06:50:28.337302Z", "level": "info", "event": "Ensured Unsloth directories in 1074.9ms"}
{"timestamp": "2026-08-30T06:50:28.850630Z", "level": "info", "event": "run_server pre-uvicorn setup completed in 1588.2ms"}

No obvious ERROR, EXCEPTION, TRACEBACK, FATAL, OOM, or CUDA error was present in the relevant server log around the failure.

SQLite state

Database:
~/.unsloth/studio/studio.db

journal_mode:
wal

integrity_check:
ok

The process had the following database files open:

studio.db
studio.db
studio.db-wal

The Studio process held multiple open file descriptors to studio.db.

Additional context

The Studio process was:

PID 3764895

It remained alive but became effectively unresponsive.

The llama.cpp process was:

PID 3765435

and remained responsive on port 55687.

One llama.cpp-related pipe also showed activity corresponding to generation/slot handling:

slot release: id 3 | task 3494 | stop processing: n_tokens = 74401, truncated = 0

This suggests the incident occurred while Studio was handling an active generation, although I cannot establish from the available evidence that generation itself was the cause of the SQLite deadlock.

Suspected issue: concurrent SQLite connection open/close activity in Unsloth Studio resulted in a circular SQLite mutex deadlock, causing the Studio backend to remain alive but stop servicing HTTP requests.

Activity

  1. added
    feature request
    on Aug 30, 2026
  2. DjagbleyEmmanuel commented on Aug 31, 2026

    @DjagbleyEmmanuel

    Same here

  3. self-assigned this
    on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions