dan-online / autopulse

💫 automated scanning tool that bridges media organizers such as Sonarr and Radarr with media servers such as Plex and Jellyfin
https://autopulse.dancodes.online
MIT License
127 stars 5 forks source link

bug: timer_wait not working and db locked errors #27

Closed BaukeZwart closed 1 month ago

BaukeZwart commented 2 months ago

Description of the bug

Running with this in my config, but when DL multiple episodes I see every episode is being processed by Plex the moment it's imported in Sonarr. Also the log is filled with db locked errors. (Using SQLite)

opts:
  default_timer_wait: 180 # In seconds

triggers:
  sonarr:
    type: "sonarr"
    timer:
      wait: 5 # In seconds
ERROR autopulse::service::runner: unable to delete not found events: DatabaseError(Unknown, "database is locked")
ERROR autopulse::service::runner: unable to delete failed events: DatabaseError(Unknown, "database is locked")

Steps To Reproduce

See above

Additional Information

No response

dan-online commented 2 months ago

Hmm, this is odd as I recently added options to prevent this on SQLite

BaukeZwart commented 2 months ago

For now I reverted to autoscan but if there is anything I can test to help please let me know. EDIT: I see that root is the owner of the db and the shm and wal files, is that correct?

dan-online commented 2 months ago

For now I reverted to autoscan but if there is anything I can test to help please let me know. EDIT: I see that root is the owner of the db and the shm and wal files, is that correct?

Yep that should be correct, and the presence of those files show it should be working correctly.. I'll do some testing on my end to see

BaukeZwart commented 2 months ago

Side note, I see you closed my earlier bug report about incorrect discord time stamp as solved. But the issue is still there.

dan-online commented 2 months ago

@BaukeZwart the timestamp uses local time now, so as long as you set /etc/localtime:/etc/localtime:ro it should be correct, I'll add it to the docker-compose

BaukeZwart commented 2 months ago

I removed that from my compose when it didn't change anything during earlier testing. Tried again and time stamp is correct now.

dan-online commented 2 months ago

Could you share more logs with log_level set to debug?

BaukeZwart commented 2 months ago

I have set log level to debug. I will force a few imports later when my server is done with the bulk import from the seedbox and post the log.

BaukeZwart commented 2 months ago

Log: https://logs.notifiarr.com/?fa95c54a5d0df9e8#6rHLHTaU4B2mpSRQaFnJm7LEnENbsXMHM8k1cJD4R68m

dan-online commented 1 month ago

Hey @BaukeZwart can you test if #35 i.e. danonline/autopulse:pr-35 resolves your issue?

BaukeZwart commented 1 month ago

pulling it now, I will let you know.

BaukeZwart commented 1 month ago

@dan-online pr-35 seems to work much better. I still see db locked errors in the log but the delay now seems to work. This is the debug log after adding a 3 episode mini series. https://logs.notifiarr.com/?586f50ab99ec1076#HK7i1jjcSU1Zc8M2c5Sny55bQKho4y7M6YUB9HVcYMew

BaukeZwart commented 1 month ago

Discord_xKaLNnHES2

dan-online commented 1 month ago

Hmm, I've increased the busy_timeout in the same tag, perhaps that might fix it?

BaukeZwart commented 1 month ago

That also didn't fix it. I noticed the timestamp of the db itself never changes, it seems noting is written to it.

dopus_DLmPTPxgjk

dan-online commented 1 month ago

That is extremely odd, could you try deleting the folder and then starting autopulse, seems to be some weird permissions issue

BaukeZwart commented 1 month ago

I tried that yesterday, stopped the container, deleted the db file and restarted. I will try again but would be surprised if any changes. EDIT: I checked, none of the other containers I run that use sqlite have the db with root as owner. They all use user: ${PUID}:${PGID} as the owner. Can that be the reason?

dan-online commented 1 month ago

That is very possibly the reason, I originally tried having the image not be root but that led to some permissions issues so I had to go root in #18

BaukeZwart commented 1 month ago

As a test I tried manually changing the perm and ownership of the db files and added ${PUID}:${PGID} to docker compose, but still the same db locked errors.

dan-online commented 1 month ago

Hmm, quite odd since I don't get these errors with example/docker-compose-sqlite.yml

BaukeZwart commented 1 month ago

I'm using the same docker compose. Is there anything in the config that can cause this?

BaukeZwart commented 1 month ago

Switched to postgres and it all working fine now.

dan-online commented 1 month ago

I'll tentatively close this but if someone else sees this issue then feel free to comment to reopen this