TabbyML / tabby

Self-hosted AI coding assistant
https://tabbyml.com
Other
21.85k stars 995 forks source link

Tabby server crashing with sqlite database is locked error. #2702

Closed Mizzlr closed 3 months ago

Mizzlr commented 3 months ago

Describe the bug A clear and concise description of what the bug is.

tabby-1 | The application panicked (crashed). tabby-1 | Message: Must be able to initialize db: while executing migrations: error returned from database: (code: 5) database is locked tabby-1 | tabby-1 | Caused by: tabby-1 | 0: error returned from database: (code: 5) database is locked tabby-1 | 1: (code: 5) database is locked tabby-1 | Location: /root/workspace/ee/tabby-webserver/src/webserver.rs:52 tabby-1 | tabby-1 | Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it. tabby-1 | Run with RUST_BACKTRACE=full to include source snippets. tabby-1 exited with code 0

Information about your version Please provide output of tabby --version docker.io/tabbyml/tabby:20240721 Information about your GPU Please provide output of nvidia-smi

$ nvidia-smi Mon Jul 22 02:50:36 2024
+---------------------------------------------------------------------------------------+ | NVIDIA-SMI 535.171.04 Driver Version: 535.171.04 CUDA Version: 12.2 | |-----------------------------------------+----------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 NVIDIA GeForce RTX 3060 Off | 00000000:01:00.0 Off | N/A | | 0% 38C P8 10W / 170W | 152MiB / 12288MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | 0 N/A N/A 1723 G /usr/lib/xorg/Xorg 90MiB | | 0 N/A N/A 2039 G /usr/bin/gnome-shell 56MiB | +---------------------------------------------------------------------------------------+

Additional context Add any other context about the problem here.

Mizzlr commented 3 months ago

Full backtrace here

2024-07-21T21:29:04.117303277Z Location: /root/workspace/ee/tabby-webserver/src/webserver.rs:52 2024-07-21T21:29:04.117306593Z 2024-07-21T21:29:04.117313676Z ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2024-07-21T21:29:04.117318184Z ⋮ 9 frames hidden ⋮
2024-07-21T21:29:04.117321681Z 10: tabby::serve::main::{{closure}}::h892c356c5a511506 2024-07-21T21:29:04.117324957Z at : 2024-07-21T21:29:04.117329916Z 11: tokio::runtime::park::CachedParkThread::block_on::h80bc56cca1075b1b 2024-07-21T21:29:04.117333182Z at : 2024-07-21T21:29:04.117338592Z 12: tabby::main::h641df09d0bc17fed 2024-07-21T21:29:04.117342219Z at : 2024-07-21T21:29:04.117345946Z 13: std::sys_common::backtrace::rust_begin_short_backtrace::h93a02c0a89e40aa1 2024-07-21T21:29:04.117364110Z at : 2024-07-21T21:29:04.117387343Z 14: std::rt::lang_start::{{closure}}::h9415544fb1587b8a 2024-07-21T21:29:04.117392062Z at : 2024-07-21T21:29:04.117410436Z 15: core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::h37600b1e5eea4ecd 2024-07-21T21:29:04.117443748Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284 2024-07-21T21:29:04.117459457Z 16: std::panicking::try::do_call::hb4bda49fa13a0c2b 2024-07-21T21:29:04.117466460Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552 2024-07-21T21:29:04.117483742Z 17: std::panicking::try::h8bbf75149211aaaa 2024-07-21T21:29:04.117497338Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516 2024-07-21T21:29:04.117503118Z 18: std::panic::catch_unwind::h8c78ec68ebea34cb 2024-07-21T21:29:04.117533986Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142 2024-07-21T21:29:04.117538514Z 19: std::rt::lang_start_internal::{{closure}}::hffdf44a19fd9e220 2024-07-21T21:29:04.117558712Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148 2024-07-21T21:29:04.117568280Z 20: std::panicking::try::do_call::hcb3194972c74716d 2024-07-21T21:29:04.117572898Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552 2024-07-21T21:29:04.117580753Z 21: std::panicking::try::hcdc6892c5f0dba4c 2024-07-21T21:29:04.117594048Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516 2024-07-21T21:29:04.117612382Z 22: std::panic::catch_unwind::h4910beb4573f4776 2024-07-21T21:29:04.117625206Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142 2024-07-21T21:29:04.117639202Z 23: std::rt::lang_start_internal::h6939038e2873596b 2024-07-21T21:29:04.117653108Z at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148 2024-07-21T21:29:04.117660041Z 24: main 2024-07-21T21:29:04.117675359Z at : 2024-07-21T21:29:04.117691549Z 25: libc_start_main 2024-07-21T21:29:04.117700386Z at : 2024-07-21T21:29:04.117714752Z 26: _start 2024-07-21T21:29:04.117728708Z at : 2024-07-21T21:29:04.117732886Z 2024-07-21T21:29:04.117736503Z Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. ⠸ 5.788 s Starting... 2024-07-21T21:29:16.843989121Z The application panicked (crashed). 2024-07-21T21:29:16.844009018Z Message: Must be able to initialize db: while executing migrations: error returned from database: (code: 5) database is locked 2024-07-21T21:29:16.844011983Z 2024-07-21T21:29:16.844014007Z Caused by: 2024-07-21T21:29:16.844016041Z 0: error returned from database: (code: 5) database is locked 2024-07-21T21:29:16.844018165Z 1: (code: 5) database is locked 2024-07-21T21:29:16.844020529Z 2024-07-21T21:29:16.844022473Z Stack backtrace: 2024-07-21T21:29:16.844025178Z 0: anyhow::error::<impl core::convert::From for anyhow::Error>::from 2024-07-21T21:29:16.844027332Z 1: tabby_db::DbConn::new::{{closure}} 2024-07-21T21:29:16.844029326Z 2: tabby::serve::main::{{closure}} 2024-07-21T21:29:16.844031490Z 3: tokio::runtime::park::CachedParkThread::block_on 2024-07-21T21:29:16.844033934Z 4: tabby::main 2024-07-21T21:29:16.844035888Z 5: std::sys_common::backtrace::rust_begin_short_backtrace 2024-07-21T21:29:16.844037872Z 6: std::rt::lang_start::{{closure}} 2024-07-21T21:29:16.844039835Z 7: core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once 2024-07-21T21:29:16.844042139Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:284:13 2024-07-21T21:29:16.844044223Z 8: std::panicking::try::do_call 2024-07-21T21:29:16.844046427Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40 2024-07-21T21:29:16.844048742Z 9: std::panicking::try 2024-07-21T21:29:16.844050745Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19 2024-07-21T21:29:16.844052950Z 10: std::panic::catch_unwind 2024-07-21T21:29:16.844055053Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14 2024-07-21T21:29:16.844057258Z 11: std::rt::lang_start_internal::{{closure}} 2024-07-21T21:29:16.844072797Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:48 2024-07-21T21:29:16.844074951Z 12: std::panicking::try::do_call 2024-07-21T21:29:16.844077054Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40 2024-07-21T21:29:16.844079068Z 13: std::panicking::try 2024-07-21T21:29:16.844080952Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19 2024-07-21T21:29:16.844082965Z 14: std::panic::catch_unwind 2024-07-21T21:29:16.844084849Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14 2024-07-21T21:29:16.844086803Z 15: std::rt::lang_start_internal 2024-07-21T21:29:16.844088736Z at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/rt.rs:148:20 2024-07-21T21:29:16.844090880Z 16: main 2024-07-21T21:29:16.844093014Z 17: 2024-07-21T21:29:16.844095078Z 18: libc_start_main 2024-07-21T21:29:16.844097002Z 19: _start 2024-07-21T21:29:16.844098965Z Location: /root/workspace/ee/tabby-webserver/src/webserver.rs:52

Mizzlr commented 3 months ago

Here is the docker compose

  tabby:
    restart: always
    image: tabbyml/tabby:20240721
    pull_policy: always
    # https://tabby.tabbyml.com/docs/models/
    command: serve --model DeepseekCoder-6.7B --device cuda
    volumes:
      - /mnt/disk1/tabby:/data
    ports:
      - 8008:8080
    environment:
      - RUST_BACKTRACE=full
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities:
                - gpu

And here is the tabby folder

/mnt/disk1/tabby
├── ee
│   ├── db.sqlite
│   └── db.sqlite-journal
└── models
    └── TabbyML
        ├── DeepseekCoder-6.7B
        │   ├── ggml
        │   │   └── model.gguf
        │   └── tabby.json
        ├── models.json
        └── Nomic-Embed-Text
            ├── ggml
            │   └── model.gguf
            └── tabby.json

7 directories, 7 files

It was working until I decide to upgrade the tabby version to latest (from yesterday). I tried deleting the tabby db files and also tabby folder completely to start fresh. Still the same issue.

wsxiaoys commented 3 months ago

Hi - it seems that your setup have multiple progress accessing the same ~/.tabby/, could you confirm?

Mizzlr commented 3 months ago

I am running tabby server inside docker container of different host and using tabby from pycharm on a different host. This setup was working for me. I could not find any ~/.tabby/ folder on any of my hosts.

host1 --> host2 pycharm with tabby plugin --> tabby server inside docker container no ~/.tabby --> no ~/.tabby

Mizzlr commented 3 months ago

Hi @wsxiaoys Fixed it after adding init: true to docker compose. This is to run docker with proper init process wrapping tabby. In my case, there were zombie processes generated by tabby that were interfering with init process.

Now tabby is working, after some clean restarts

services:
  tabby2:
    restart: always
    image: tabbyml/tabby:20240721
    pull_policy: always
    init: true
    # https://tabby.tabbyml.com/docs/models/
    command: serve --model DeepseekCoder-6.7B --device cuda
    volumes:
      - /mnt/disk1/tabby4:/data
    ports:
      - 8008:8080
    environment:
      - RUST_BACKTRACE=full
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities:
                - gpu
⠸   134.738 s   Starting...
tabby-tabby2-1: 
tabby-tabby2-1: ████████╗ █████╗ ██████╗ ██████╗ ██╗   ██╗
tabby-tabby2-1: ╚══██╔══╝██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝
tabby-tabby2-1:    ██║   ███████║██████╔╝██████╔╝ ╚████╔╝ 
tabby-tabby2-1:    ██║   ██╔══██║██╔══██╗██╔══██╗  ╚██╔╝  
tabby-tabby2-1:    ██║   ██║  ██║██████╔╝██████╔╝   ██║   
tabby-tabby2-1:    ╚═╝   ╚═╝  ╚═╝╚═════╝ ╚═════╝    ╚═╝   
tabby-tabby2-1: 
tabby-tabby2-1: 📄 Version 0.13.0-dev.0
tabby-tabby2-1: 🚀 Listening at 0.0.0.0:8080

Unfortunately my history was not backed up and is lost. Will make sure to have back up of the db and events when upgrading next time. Closing this issue.

Mizzlr commented 3 months ago

And thank you for building Tabby, coming from a true stargazer.