Libation icon indicating copy to clipboard operation
Libation copied to clipboard

sqlite error after updating to 11.5.x

Open Rondal opened this issue 2 years ago • 5 comments

Describe the bug I updated a docker-compose libation to 11.5.x (not sure which one at the date) and it silently failed with the attached error about the sqlite DB beeing read only. I did not notice right away, as the container continued running. I checked for the DB file beeing writable and not corrupted (both fine). All of the 11.5.x versions show the same behaviour. Downgrading to 11.4.1 fixed the issue without touching anything else.

To Reproduce Not sure if it happens with a fresh install (did not test). So I'm not sure what's needed to reproduce. In my specific case: Update to 11.5.x.

Expected behavior Not throwing an SQL error. Also maybe the script that repeatedly calls libation within the docker container should exit when such an error happens.

Platform

Docker-Compose on an Alpine VM, hosted on a 64bit hypervisor.

Log Files Log output (please ignore the 'integer expected' error. That was fixed in a later version but is visible in that log because I tested an older 11.5 version):

dock1:/srv/docker-stacks/libation# docker-compose up
[+] Running 2/2
 ✔ Network libation_default  Created                                                                                                 0.1s 
 ✔ Container libation        Created                                                                                                 0.3s 
Attaching to libation
libation  | 2024-11-25 16:53:31 info: initializing libation
libation  | 2024-11-25 16:53:31 info: loading AccountsSettings.json
libation  | 2024-11-25 16:53:31 info: loading Settings.json
libation  | 2024-11-25 16:53:31 info: loading settings
libation  | 2024-11-25 16:53:31 info: setting Books to /data
libation  | 2024-11-25 16:53:31 info: setting InProgress to /tmp
libation  | 2024-11-25 16:53:31 info: loading database
libation  | 2024-11-25 16:53:31 info: database found at /config/LibationContext.db
libation  | /libation/liberate.sh: line 152: [: 15m: integer expression expected
libation  | 2024-11-25 16:53:31 info: running every 15m
libation  | 2024-11-25 16:53:31 info: scanning accounts
libation  | Scanning Audible library: 2 accounts. This may take a few minutes per account.
libation  | LibationCli v11.5.4
libation  | ERROR
libation  | =====
libation  | SQLite Error 8: 'attempt to write a readonly database'.
libation  | 
libation  |    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc,
libation  |    sqlite3 db)
libation  |    at
libation  |    Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements()+MoveNext(
libation  |    )
libation  |    at Microsoft.Data.Sqlite.SqliteCommand.GetStatements()+MoveNext()
libation  |    at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
libation  |    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior
libation  |    behavior)
libation  |    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteScalar()
libation  |    at
libation  |    Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalar(Relatio
libation  |    nalCommandParameterObject parameterObject)
libation  |    at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
libation  |    at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String
libation  |    targetMigration)
libation  |    at Dinah.EntityFrameworkCore.DesignTimeDbContextFactoryBase`1.Create(String
libation  |    connectionString)
libation  |    at ApplicationServices.LibraryCommands.importIntoDbAsync(List`1 importItems)
libation  |    in /Source/ApplicationServices/LibraryCommands.cs:line 323
libation  |    at ApplicationServices.LibraryCommands.ImportAccountAsync(Func`2
libation  |    apiExtendedfunc, Account[] accounts) in
libation  |    /Source/ApplicationServices/LibraryCommands.cs:line 144
libation  |    at LibationCli.ScanOptions.ProcessAsync() in
libation  |    /Source/LibationCli/Options/ScanOptions.cs:line 35
libation  |    at LibationCli.OptionsBase.Run() in
libation  |    /Source/LibationCli/Options/_OptionsBase.cs:line 15
libation  | 
libation  | scan Usage:
libation  | 
libation  |   --help               Display this help screen.
libation  | 
libation  |   Accounts (pos. 0)    Optional: user ID or nicknames of accounts to scan.
libation  | 
libation  | 
libation  | 2024-11-25 16:53:35 info: liberating books
^CGracefully stopping... (press Ctrl+C again to force)
[+] Stopping 1/1
 ✔ Container libation  Stopped                                                                                                      10.2s 
libation exited with code 0
canceled

docker-compose.yml (already pinned to 11.4.1):

dock1:/srv/docker-stacks/libation# cat docker-compose.yml 
version: "3.4"

services:
  libation:
    image: rmcrackan/libation:11.4.1
    container_name: libation
    restart: unless-stopped
    environment:
    - SLEEP_TIME=15m
    volumes:
      - ./config:/config
      - /media/Audiobooks:/data

Files in ./config:

dock1:/srv/docker-stacks/libation/config# ls -l
total 1296
-rw-r--r--    1 root     root         11757 Nov 25 17:54 AccountsSettings.json
-rw-r--r--    1 root     root        847358 Nov 25 17:55 FileLocations.json
drwxr-xr-x    2 root     root          4096 Nov 25 17:55 Images
-rw-r--r--    1 root     root        454656 Nov 25 17:55 LibationContext.db
drwxr-xr-x    2 root     root          4096 Nov 25 17:55 SearchEngine
-rw-r--r--    1 root     root          3855 Oct 27  2023 Settings.json

Rondal avatar Nov 25 '24 17:11 Rondal

Just as a note: I'm happy to provide more logs or test on my install.

Rondal avatar Nov 25 '24 17:11 Rondal

There was a recent breaking permissions change with the docker container. This may be what you are experiencing.

[!WARNING]

Breaking Changes

  • The docker image now runs as user 1001 and group 1001. Make sure that the permissions on your volumes allow user 1001 to read and write to them.

Docker.md

jfrazx avatar Nov 26 '24 04:11 jfrazx

Update I changed the /config and /data to the user 1001 and group 1001 and it is working.

Which folder do you change permissions to? I changed the /data folder to 1001, but that didn't solve the issue.

$ ls -l
total 36 lrwxrwxrwx 1 root root 7 Nov 10 17:00 bin -> usr/bin drwxr-xr-x 1 root root 0 Oct 31 05:04 boot drwxr-xr-x 1 99 users 176 Nov 15 01:18 config drwxrwxrwx 1 root root 104 Nov 26 20:44 config-internal drwxr-xr-x 1 1001 1001 16384 Nov 14 18:09 data drwxr-xr-x 5 root root 340 Nov 26 20:44 dev drwxr-xr-x 1 root root 1218 Nov 20 00:05 etc drwxr-xr-x 1 root root 6 Nov 12 11:41 home lrwxrwxrwx 1 root root 7 Nov 10 17:00 lib -> usr/lib lrwxrwxrwx 1 root root 9 Nov 10 17:00 lib64 -> usr/lib64 drwxr-xr-x 1 root root 15160 Nov 19 04:43 libation drwxr-xr-x 1 root root 0 Nov 10 17:00 media drwxr-xr-x 1 root root 0 Nov 10 17:00 mnt drwxr-xr-x 1 root root 0 Nov 10 17:00 opt dr-xr-xr-x 641 root root 0 Nov 26 20:44 proc drwx------ 1 root root 30 Nov 10 17:00 root drwxr-xr-x 1 root root 8 Nov 10 17:00 run lrwxrwxrwx 1 root root 8 Nov 10 17:00 sbin -> usr/sbin drwxr-xr-x 1 root root 0 Nov 10 17:00 srv dr-xr-xr-x 13 root root 0 Nov 26 20:44 sys drwxrwxrwt 1 root root 72 Nov 26 20:44 tmp drwxr-xr-x 1 root root 94 Nov 10 17:00 usr drwxr-xr-x 1 root root 90 Nov 10 17:00 var

battuo avatar Nov 27 '24 04:11 battuo

I'm very sorry for opening this bug. You're of course right and I must have completly missed that note. I changed the permissions accordingly and it is running fine now.

Still the question remains if the script within docker which polls every few minutes should exit in such a case to make sure that the error is noticeable to the user. I think that would be within liberate.sh. If no of the error conditions are met before the main loop it is no longer checking for error while executing the scan and liberate commands.

I can transfer that to a feature request or different bug if needed.

Rondal avatar Nov 27 '24 08:11 Rondal

Sorry for the late reply. I've been out of town. Glad to see that it all looks sorted now.

rmcrackan avatar Dec 01 '24 20:12 rmcrackan