SQLite FTS4aux regression causes LMS to delete and rebuild a valid music database

オープン
#1,730 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
perl, sqlite
領域
backend, databases

調査の方向性

Read Slim/Plugin/FullTextSearch/Plugin.pm around _initPopularTerms() and Slim/Schema/Storage::throw_exception(), then reproduce the reported FTS4aux query against SQLite 3.53.2 or later. Trace how the auxiliary table error reaches the database rebuild path. Done when an auxiliary search failure no longer causes a valid library.db to be deleted, while the failure is logged and LMS can continue where possible.

索引モデルが issue の本文から書いたものです。

説明

Note: English is not my native language, so I used AI assistance to help translate and structure this report. However, all tests described below were performed by me on my own system, and I personally verified the results. This is a real, reproducible issue, not an AI-generated assumption.

SQLite FTS4aux regression causes LMS to delete and rebuild a valid music database

Environment

  • Lyrion Music Server 9.1.1

  • Fedora 45, x86_64

  • Perl 5.44

  • SQLite 3.53.4

  • DBD::SQLite 1.78

Problem

Lyrion Music Server treats an SQLite SQLITE_CORRUPT error originating from its FTS4 auxiliary table as corruption of the entire music database.

As a result, LMS attempts to delete and rebuild library.db, even though the underlying problem is an SQLite regression and not actual database corruption.

Root cause

SQLite introduced an FTS4aux regression between versions 3.53.1 and 3.53.2.

The issue is reproducible independently of LMS, Perl, or Fedora-specific SQLite patches.

Minimal SQLite reproducer:

CREATE VIRTUAL TABLE ft USING fts4(c1,c2,c3);
INSERT INTO ft VALUES ('Depeche Mode','Depeche Mode','Depeche Mode');
CREATE VIRTUAL TABLE aux USING fts4aux(ft);
SELECT term, col, documents FROM aux LIMIT 10;

Results:

SQLite version | Result -- | -- 3.52.0 | Works 3.53.0 | Works 3.53.1 | Works 3.53.2 | SQLITE_CORRUPT 3.53.4 | SQLITE_CORRUPT

These versions were tested using official SQLite source distributions.

LMS failure

During initialization, Slim::Plugin::FullTextSearch::Plugin::_initPopularTerms() executes a query against fulltext_terms, an FTS4aux virtual table.

The query fails with:

DBD::SQLite::db selectcol_arrayref failed:
database disk image is malformed

The exception reaches Slim::Schema::Storage::throw_exception(), which logs:

Trying to rebuild /var/lib/lyrionmusicserver/cache/library.db from scratch.

The existing music database is then removed, and subsequent queries fail with errors such as:

no such table: tracks

In my case, the server failed to initialize correctly and the music library had to be rebuilt.

Workaround

I temporarily added an early return to _initPopularTerms() in Slim/Plugin/FullTextSearch/Plugin.pm:

sub _initPopularTerms {
    return; # Temporary workaround for SQLite FTS4aux regression
    my $scanDone = shift;

After applying this workaround, LMS started successfully and completed a full library scan of 38,732 tracks.

The full-text index was built successfully, and album artwork including dynamic resizing worked again.

Suggested improvement

Even if SQLite is responsible for returning the incorrect corruption error, LMS should ideally avoid deleting the entire music database based solely on an error from an auxiliary full-text search table.

Possible improvements:

  • Handle errors from fts4aux separately from errors indicating corruption of the main database.

  • Preserve the existing library.db when an auxiliary index query fails.

  • Log the failure and allow the server to continue with reduced search functionality where possible.

The underlying SQLite regression has also been reported upstream.

主要言語
Perl
スター
1.8k
フォーク
389
平均マージ
1日 4時間
マージ済み PR(30日)
10

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

LMS-Community/slimserver のほかの issue

LMS-Community/slimserver の issue をすべて見る

似ている issue

Perl の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。