beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.75k stars 1.82k forks source link

database access error: attempt to write a readonly database #4039

Closed lovesegfault closed 3 years ago

lovesegfault commented 3 years ago

Problem

Running this command in verbose (-vv) mode:

$ beet -vv upd

(or any other command that touches the database)

Led to this problem:

Clairo - Sling - Just For Today
  deleted
database access error: attempt to write a readonly database
the library file might have a permissions problem

I've verified that the file is not readonly:

$ stat /srv/music/library.db
  File: /srv/music/library.db
  Size: 151322624   Blocks: 295695     IO Block: 131072 regular file
Device: 3bh/59d Inode: 4282        Links: 1
Access: (0666/-rw-rw-rw-)  Uid: ( 8888/bemeurer)   Gid: (  998/   media)
Access: 2021-04-20 01:14:41.247206743 -0700
Modify: 2021-08-21 15:02:42.394427840 -0700
Change: 2021-08-31 03:44:47.596976491 -0700
 Birth: -
$ lsattr /srv/music/library.db 
---------------------- /srv/music/library.db

This seems to have started happening on the update to 1.5.0

Setup

My configuration (output of beet config) is:

lyrics:
    bing_lang_from: []
    auto: no
    fallback: ''
    google_API_key: REDACTED
    bing_client_secret: REDACTED
    bing_lang_to:
    google_engine_ID: REDACTED
    genius_api_key: REDACTED
    force: no
    local: no
    sources:
    - google
    - musixmatch
    - genius
    - tekstowo
absubmit:
    auto: yes
    extractor: /home/bemeurer/.nix-profile/bin/streaming_extractor_music
    force: no
    pretend: no
acoustid:
    apikey: REDACTED
alternatives:
    opus:
        directory: /srv/opus
        formats: opus
        query: ''
art_filename: cover
asciify_paths: no
chroma:
    auto: no

clutter: [Thumbs.DB, .DS_Store]
convert:
    formats:
        opus:
            command: ffmpeg -i $source -y -c:a libopus -b:a 510k $dest
            extension: opus
        aac:
            command: /nix/store/dlqvyg1fayrkrzrszd9m5yms1wyzqwzl-ffmpeg-4.4-bin/bin/ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        alac:
            command: /nix/store/dlqvyg1fayrkrzrszd9m5yms1wyzqwzl-ffmpeg-4.4-bin/bin/ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        flac: /nix/store/dlqvyg1fayrkrzrszd9m5yms1wyzqwzl-ffmpeg-4.4-bin/bin/ffmpeg -i $source -y -vn -acodec flac $dest
        mp3: /nix/store/dlqvyg1fayrkrzrszd9m5yms1wyzqwzl-ffmpeg-4.4-bin/bin/ffmpeg -i $source -y -vn -aq 2 $dest
        ogg: /nix/store/dlqvyg1fayrkrzrszd9m5yms1wyzqwzl-ffmpeg-4.4-bin/bin/ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: /nix/store/dlqvyg1fayrkrzrszd9m5yms1wyzqwzl-ffmpeg-4.4-bin/bin/ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    dest:
    pretend: no
    link: no
    hardlink: no
    threads: 16
    format: mp3
    id3v23: inherit
    max_bitrate: 500
    auto: no
    tmpdir:
    quiet: no
    embed: yes

    paths: {}
    no_convert: ''
    never_convert_lossy_files: no
    copy_album_art: no
    album_art_maxwidth: 0
    delete_originals: no
directory: /srv/music
embedart:
    auto: yes
    maxwidth: 0
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
    quality: 0
fetchart:
    auto: yes
    cautious: no
    enforce_ratio: 10%
    minwidth: 600
    sources: filesystem fanarttv *
    fanarttv_key: REDACTED
    google_key: REDACTED
    maxwidth: 0
    quality: 0
    max_filesize: 0
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    google_engine: 001442825323518660753:hrh5ch1gjzm
    lastfm_key: REDACTED
    store_source: no
    high_resolution: no
format_album: $albumartist - $album

format_item: $artist - $album - $title
format_raw_length: no
id3v23: no
ignore:
- .*
- '*~'
- System Volume Information
- lost+found
ignore_hidden: yes

import:
    autotag: yes
    bell: yes
    copy: yes
    default_action: apply
    delete: no
    detail: yes
    duplicate_action: ask
    flat: no
    from_scratch: yes
    group_albums: no
    hardlink: no
    incremental: yes
    languages: [en]
    link: no
    log: /home/bemeurer/.local/share/beets.log
    move: yes
    none_rec_action: ask
    pretend: no
    quiet: no
    quiet_fallback: skip
    resume: ask
    search_ids: []
    set_fields: {}
    singletons: no
    timid: yes
    write: yes
lastgenre:
    auto: yes
    canonical: yes
    fallback: ''
    whitelist: yes
    min_weight: 10
    count: 1
    source: album
    force: yes
    separator: ', '
    prefer_specific: no
    title_case: yes
library: /srv/music/library.db

match:
    distance_weights:
        album: 3
        album_id: 5
        albumdisambig: 0.5
        artist: 3
        catalognum: 0.5
        country: 0.5
        label: 0.5
        media: 1
        mediums: 1
        missing_tracks: 0.9
        source: 2
        track_artist: 2
        track_id: 5
        track_index: 1
        track_length: 2
        track_title: 3
        tracks: 2
        unmatched_tracks: 0.6
        year: 1
    ignore_video_tracks: no
    ignored: []
    max_rec:
        missing_tracks: medium
        unmatched_tracks: medium
    medium_rec_thresh: 0.25
    preferred:
        countries: [US, GB|UK]
        media: [Digital Media|File, CD]
        original_year: yes
    rec_gap_thresh: 0.25
    required: []
    strong_rec_thresh: 0.04
    track_length_grace: 10
    track_length_max: 30
max_filename_length: 0

musicbrainz:
    host: musicbrainz.org
    ratelimit: 1
    ratelimit_interval: 1
    searchlimit: 5
original_date: yes
path_sep_replace: _

paths:
    comp: Various Artists/$album%aunique{}/$disc.$track $title
    default: $albumartist/$album%aunique{}/$disc.$track $title
per_disc_numbering: yes
permissions:
    file: 644
    dir: 755
pluginpath: []

plugins:
- absubmit
- acousticbrainz
- alternatives
- badfiles
- chroma
- convert
- edit
- embedart
- fetchart
- fromfilename
- info
- lastgenre
- lyrics
- mbsync
- missing
- permissions
- replaygain
- scrub
- unimported

replace:
    '[<>:"\?\*\|]': _
    '[\\/]': _
    '[\x00-\x1f]': _
    \.$: _
    \s+$: ''
    ^-: _
    ^\.: _
    ^\s+: ''
replaygain:
    backend: gstreamer
    auto: yes
    overwrite: no
    threads: 16
    parallel_on_import: no
    per_disc: no
    peak: 'true'
    targetlevel: 89
    r128: [Opus]
    r128_targetlevel: 84
scrub:
    auto: yes

sort_album: albumartist+ album+
sort_case_insensitive: yes
sort_item: artist+ album+ disc+ track+

statefile: state.pickle
threaded: yes
time_format: '%Y-%m-%d %H:%M:%S'
timeout: 5

ui:
    color: yes
    colors:
        action: blue
        action_default: turquoise
        text_error: red
        text_highlight: red
        text_highlight_minor: lightgray
        text_success: green
        text_warning: yellow
    length_diff_thresh: 10
    terminal_width: 120
va_name: Various Artists
verbose: 0
acousticbrainz:
    auto: yes
    force: no
    tags: []
missing:
    count: no
    total: no
    album: no
edit:
    albumfields: album albumartist
    itemfields: track title artist album
    ignore_fields: id path
unimported:
    ignore_extensions: []
lovesegfault commented 3 years ago

Moving the db elsewhere does solve the issue, but it's not clear why.

jackwilsdon commented 3 years ago

What are the permissions on the containing folder (/srv/music)? From my testing, write access is required to the folder containing the beets database:

$ beet rm -f Test1        
$ chmod 555 ~/.config/beets
$ beet rm -f Test2
database access error: attempt to write a readonly database
the library file might have a permissions problem

I believe this is related to how SQLite works - it writes some temporary files to the same location as the database: https://sqlite.org/tempfiles.html

lovesegfault commented 3 years ago

Yeah, I was being a complete tool and forgot to check the perms of the parent directory.

Thanks!