akhilrex / podgrab

A self-hosted podcast manager/downloader/archiver tool to download podcast episodes as soon as they become live with an integrated player.
GNU General Public License v3.0
1.55k stars 87 forks source link

Settings lost on container restart (because of a new ID?) #248

Open nanawel opened 1 year ago

nanawel commented 1 year ago

Describe the bug It seems that settings once saved from the dedicated page and correctly saved into the database, but are not "unique" and assigned a specific ID as seen in the following capture:

image

Everything works as expected... until you restart the container (for an update for example). Then the settings are reset to the default ones, apparently because the application creates and uses a new row from the settings table, instead of reusing the existing/previous one.

Which leads to this question: why this structure for the settings table exactly? I would have expected a row per config key, not a column :thinking:

C.f. issue #163 that seems to point the same bug.

To Reproduce Steps to reproduce the behavior:

  1. Go to the Settings page
  2. Customize the settings
  3. Click on Save
  4. Go back to Home, then Settings
  5. Settings have been save correctly
  6. Restart the container
  7. Go to the Settings page
  8. Settings are back to default

Expected behavior Keep settings, especially the base domain between each container instances.

nanawel commented 1 year ago

Is there anything I can do to help here?

didyouexpectthat commented 1 year ago

Can you share the first few lines of docker-compose logs? Any errors? Can you share your docker-compose config, also (not your password if enabled)?

I tried to reproduce this and failed, and my only guess was config folder permissions.

nanawel commented 1 year ago

Hi @didyouexpectthat

This should be all the data you need:

$ docker logs podgrab
2022/12/18 09:55:53 /config/podgrab.db
2022/12/18 09:55:53 Config Dir:  /config
2022/12/18 09:55:53 Assets Dir:  /assets
2022/12/18 09:55:53 Check Frequency (mins):  240

Permissions from within the container:

# stat /config /config/podgrab.db /assets
  File: /config
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 902h/2306d  Inode: 26214476    Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-12-18 09:55:07.677728486 +0000
Modify: 2022-12-18 07:40:01.993936759 +0000
Change: 2022-12-18 07:40:01.993936759 +0000

  File: /config/podgrab.db
  Size: 9461760     Blocks: 18480      IO Block: 4096   regular file
Device: 902h/2306d  Inode: 26214480    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-12-18 07:40:22.305354316 +0000
Modify: 2022-12-18 07:40:01.961937677 +0000
Change: 2022-12-18 07:40:01.961937677 +0000

  File: /assets
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 902h/2306d  Inode: 26214475    Links: 26
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-12-18 09:58:34.839803461 +0000
Modify: 2022-12-09 06:56:06.813337937 +0000
Change: 2022-12-09 06:56:06.813337937 +0000

I'm also adding the content of the settings table after a restart:

$ sqlite3 /config/podgrab.db 'SELECT * FROM settings'
73385689-ff49-469d-aca9-cd9afc339e75|2022-12-17 07:36:32.603868419+00:00|2022-12-17 07:36:32.603868419+00:00||1|20|1|1|1|0|0|0|1|https://xxxxxxxxxx|5|
04c847fd-6042-4e9e-bfd8-6cc69cf36ce3|2022-12-18 07:36:32.604972178+00:00|2022-12-18 07:36:32.604972178+00:00||1|20|1|1|1|0|0|0|1|https://xxxxxxxxxx|5|

The row dated 2022-12-17 is from yesterday when I cleaned up the content of the table to only keep one row (I had dozens before). The row dated 2022-12-18 has been added since, and I realize the time strangely matches the previous row (07:36:32) although I don't have any scheduled job at that time so it might also be something triggered within Podgrab.

Any clue?

enviousjag commented 1 year ago

I too lost all my settings. No errors in the docker logs either. No changes to folder perms or the container.

enviousjag commented 1 year ago

for whatever reason, my db got wiped and all my backups contain the new and empty .db file. No idea what happened.

nanawel commented 1 year ago

This is the content of my settings table today:

$ sqlite3 podgrab.db 'select * from settings'
73385689-ff49-469d-aca9-cd9afc339e75|2022-12-17 07:36:32.603868419+00:00|2022-12-17 07:36:32.603868419+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
04c847fd-6042-4e9e-bfd8-6cc69cf36ce3|2022-12-18 07:36:32.604972178+00:00|2022-12-18 07:36:32.604972178+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
7a919297-1298-48a8-a81d-d302732e7b39|2022-12-18 21:55:58.931387803+00:00|2022-12-18 21:55:58.931387803+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
4bf29a39-d225-4f2f-b19b-abfa12c74234|2022-12-22 21:55:58.971003655+00:00|2022-12-22 21:55:58.971003655+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
ff6a7cb0-68dd-4326-8ca9-c5d90e0a8981|2022-12-23 09:55:58.971665705+00:00|2022-12-23 09:55:58.971665705+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
436c530f-163b-4d1d-9dbd-861d15db4e9e|2022-12-23 21:55:58.955154973+00:00|2022-12-23 21:55:58.955154973+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
8660a067-dc08-4721-9830-9a107aca96a6|2022-12-24 09:55:58.919994713+00:00|2022-12-24 09:55:58.919994713+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
ecc27ded-6cc3-49d3-9483-5e365279bf98|2022-12-25 21:55:58.937151589+00:00|2022-12-25 21:55:58.937151589+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
02a47bee-882f-4fab-a045-e9de1c262efa|2022-12-26 09:55:58.999274951+00:00|2022-12-26 09:55:58.999274951+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
b2d3987b-574d-41b2-89cf-00be20d86f08|2022-12-27 09:55:58.935576309+00:00|2022-12-27 09:55:58.935576309+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
9bef7a9e-c463-4e24-9d54-4255127c25d0|2022-12-27 21:55:59.031552892+00:00|2022-12-27 21:55:59.031552892+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
c9c822eb-e5d4-490d-8849-e05132d67344|2022-12-29 21:55:59.435458892+00:00|2022-12-29 21:55:59.435458892+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
0e2b62c2-40f6-4923-9f65-e72cfb87bbcb|2022-12-30 21:55:58.96750147+00:00|2022-12-30 21:55:58.96750147+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
c9f1f51f-cfc2-4ee9-a6ca-6ae7418f0082|2022-12-31 21:55:58.931126972+00:00|2022-12-31 21:55:58.931126972+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
51f0eaf1-cba1-4fa8-9295-02975def46f0|2023-01-01 09:55:58.931294854+00:00|2023-01-01 09:55:58.931294854+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
b54b315c-8978-4123-85dc-ee65d3cd3159|2023-01-01 21:55:58.963591801+00:00|2023-01-01 21:55:58.963591801+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
268db910-02f3-44f9-a047-601ad2adf6bf|2023-01-02 21:55:59.790614003+00:00|2023-01-02 21:55:59.790614003+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
d0a47d76-ad79-419f-83ae-7161f096eaaa|2023-01-04 21:55:59.762090219+00:00|2023-01-04 21:55:59.762090219+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
54b653a0-e098-49bb-828c-4b48b78f820a|2023-01-04 21:55:59.818852517+00:00|2023-01-04 21:55:59.818852517+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
a3202b81-c27a-4fa7-a896-ea2022a2876e|2023-01-05 09:55:59.020912601+00:00|2023-01-05 09:55:59.020912601+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
a04c9e3c-68c7-479b-98c5-97e5d62a5c52|2023-01-05 21:55:58.978280699+00:00|2023-01-05 21:55:58.978280699+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
53fc5230-4ae4-40c2-817a-4c62b121a02e|2023-01-06 21:56:00.985333702+00:00|2023-01-06 21:56:00.985333702+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
a8e3b4a2-7697-4b56-b5a4-52e1e5e1061e|2023-01-09 09:55:58.97864682+00:00|2023-01-09 09:55:58.97864682+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
1b474490-64c9-4e2c-8441-5f86c1fcaf73|2023-01-09 21:55:59.407254761+00:00|2023-01-09 21:55:59.407254761+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
4b0ae578-23a4-4de9-842e-628e9917f481|2023-01-09 21:55:59.455305507+00:00|2023-01-09 21:55:59.455305507+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
73039983-8d61-4339-a0a9-c32b1206ffee|2023-01-10 09:55:58.944885616+00:00|2023-01-10 09:55:58.944885616+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
60fe0578-1720-4c1d-b974-08050bf7a8b4|2023-01-10 21:55:59.88133662+00:00|2023-01-10 21:55:59.88133662+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
6d963387-bc55-4cc9-918b-4072ac2463f0|2023-01-11 09:55:58.975705462+00:00|2023-01-11 09:55:58.975705462+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
4ccc0584-841e-4c6e-b781-08c1f38e4367|2023-01-11 21:55:58.983783776+00:00|2023-01-11 21:55:58.983783776+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
2d8b0474-306e-4efa-b86c-48d63dd29acc|2023-01-12 21:55:58.976427971+00:00|2023-01-12 21:55:58.976427971+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
981b3c51-8433-4d9d-b6a1-c79fb61fcefe|2023-01-14 09:55:59.210106985+00:00|2023-01-14 09:55:59.210106985+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
7b8057bd-3eef-4781-83d9-ebb726df365a|2023-01-15 09:55:59.002308677+00:00|2023-01-15 09:55:59.002308677+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
49166eef-bc72-4cc1-9d00-9a2a3940f387|2023-01-17 09:55:58.968879085+00:00|2023-01-17 09:55:58.968879085+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
d6acdd02-53fa-4503-9528-34420d126f86|2023-01-17 21:55:58.974501556+00:00|2023-01-17 21:55:58.974501556+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
bd6d31ff-12e3-473a-923c-fb90ab787df3|2023-01-18 09:55:58.941381008+00:00|2023-01-18 09:55:58.941381008+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
fc1f52c7-6be3-4370-8a36-ab13565549ac|2023-01-19 21:55:59.005965478+00:00|2023-01-19 21:55:59.005965478+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
919a6ba0-5d93-4d9c-bbf2-667d58beb7a7|2023-01-21 09:55:59.209494532+00:00|2023-01-21 09:55:59.209494532+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
90d1f6fe-9453-4cf2-ab09-f08aee4a1afa|2023-01-21 09:56:00.091364054+00:00|2023-01-21 09:56:00.091364054+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
777ae4e0-1d9a-45e3-a0bb-34ea2c5d4da1|2023-01-21 21:55:59.03469651+00:00|2023-01-21 21:55:59.03469651+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
3ba0fb29-73c9-4eb4-bbe1-3ed2203e961c|2023-01-23 21:55:58.979396698+00:00|2023-01-23 21:55:58.979396698+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
bef572ed-7b9b-4c12-81c8-4c07438686b1|2023-01-24 09:55:58.967790834+00:00|2023-01-24 09:55:58.967790834+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
afce3341-20c9-443e-9e38-2440c9c8e77b|2023-01-25 09:55:59.435772195+00:00|2023-01-25 09:55:59.435772195+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
6376ad45-d27d-44ea-8c7c-d381ce0204ad|2023-01-26 21:55:58.953943573+00:00|2023-01-26 21:55:58.953943573+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
7a54d028-dd9c-4925-bc30-9446b2666bb7|2023-01-27 09:55:59.772845269+00:00|2023-01-27 09:55:59.772845269+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
95b71986-e3f5-4554-93d6-a9a48e434fd9|2023-01-27 21:55:58.938606593+00:00|2023-01-27 21:55:58.938606593+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
4a09c850-7ea2-460e-a599-7ca1247a83fa|2023-01-28 09:55:58.94688393+00:00|2023-01-28 09:55:58.94688393+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
b5686792-72e1-4469-aa4d-d83ae59723ac|2023-01-29 09:55:59.004648992+00:00|2023-01-29 09:55:59.004648992+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
906d1db3-f183-489d-bede-7969cbbab09a|2023-01-31 09:55:58.954311283+00:00|2023-01-31 09:55:58.954311283+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|
6974a031-dbf6-4c16-bf5b-86f205bef11a|2023-01-31 21:55:58.943150181+00:00|2023-01-31 21:55:58.943150181+00:00||1|20|1|1|1|0|0|0|1|https://my.private.host|5|

In my case all the rows have the same content, it's because I use a helper script to periodically fix the values, otherwise they get reset to default. Something like

# fix-settings.sh
sqlite3 podgrad.db "update settings set 'download_on_add' = true, 'initial_download_count' = 20, [...]"

with crontab

*/10 * * * * root cd /opt/podgrab && bash fix-settings.sh

As you can see, Im' performing an UPDATE and never an INSERT but you can see rows piling up in the table anyway.

Timestamps are still odd, always at around 09:55:58, 21:55:59. I'm guessing this has something to do with the start time of the container +12h and +24h because when I inspect it I can see

docker inspect podgrab
...
            "StartedAt": "2022-12-18T09:55:53.416455655Z"
...

so it makes me think there's some kind of internal cron job that messes up with this table.

JulsSkogs commented 1 year ago

I'm also having this issue. Hosted in Docker on a Synology DS420+. I'm not sure how I would implement the script solution, unfortunately.