kagemomiji / airsonic-advanced

airsonic-advanced
GNU General Public License v3.0
143 stars 13 forks source link

[Bug]: some problems with podcasts #339

Closed microniko closed 5 months ago

microniko commented 6 months ago

What happened?

2 problems with podcasts, I don't know if they related. 1st : Many podcasts episodes are still in the list even though they have been deleted. The status is deleted. 2nd : when I do a Clean-up database some podcast are deleted :-(

Do you have an idea ? Can I delete podcast episodes that are marked as deleted in the database without any side effects ?

Steps to reproduce

2 examples :

Screenshot 2023-12-27 at 19-12-35 Airsonic Screenshot 2023-12-27 at 19-14-49 Airsonic

Before Clean-up database :

MariaDB [airsonic]> select id, title, status from podcast_channel;
+----+----------------------------------------------------+-----------+
| id | title                                              | status    |
+----+----------------------------------------------------+-----------+
|  4 | Le code a changé                                   | COMPLETED |
|  5 | La Suite dans les idées                            | COMPLETED |
|  9 | La main verte                                      | COMPLETED |
| 11 | On va déguster                                     | COMPLETED |
| 12 | Olma                                               | COMPLETED |
| 13 | Les Savanturiers                                   | COMPLETED |
| 16 | Je reviens du monde d'avant                        | COMPLETED |
| 18 | Les odyssées                                       | COMPLETED |
| 19 | La science, CQFD                                   | COMPLETED |
| 20 | LSD, La série documentaire                         | COMPLETED |
| 22 | La Conversation scientifique                       | COMPLETED |
| 23 | Histoire de                                        | COMPLETED |
| 24 | Le grand dimanche soir                             | COMPLETED |
| 26 | Yamanote                                           | COMPLETED |
| 27 | Mécaniques des épidémies                           | COMPLETED |
| 28 | Les mondes de Chloé - A la belle étoile            | COMPLETED |
| 29 | Signal sur bruit                                   | COMPLETED |
| 30 | De cause à effets, le magazine de l'environnement  | COMPLETED |
| 32 | Mécaniques du complotisme                          | COMPLETED |
| 33 | Passion Médiévistes                                | COMPLETED |
| 34 | Le Meilleur des mondes                             | COMPLETED |
| 36 | La Voie du chercheur                               | COMPLETED |
| 40 | Libre à vous ! April et Cause Commune              | COMPLETED |
| 41 | Votre cerveau                                      | COMPLETED |
| 42 | Rendez-vous avec X                                 | COMPLETED |
| 44 | 100 000 ans                                        | COMPLETED |
| 45 | Rappelle-toi demain                                | COMPLETED |
| 46 | Le moment Meurice                                  | COMPLETED |
| 47 | En quête de politique                              | COMPLETED |
| 48 | Le Billet de Sophia Aram                           | COMPLETED |
| 49 | Sur les routes de la musique                       | COMPLETED |
| 50 | Bémol et Compagnie                                 | COMPLETED |
| 51 | Le Billet de François Morel                        | COMPLETED |
| 52 | Au Poste                                           | COMPLETED |
+----+----------------------------------------------------+-----------+
34 rows in set (0,000 sec)
MariaDB [airsonic]> select count(0) from podcast_episode where status="deleted";
+----------+
| count(0) |
+----------+
|     3967 |
+----------+
1 row in set (0,002 sec)

An example :

MariaDB [airsonic]> select count(0) from podcast_episode where channel_id=4 and status="deleted";
+----------+
| count(0) |
+----------+
|       46 |
+----------+
1 row in set (0,001 sec)

After clean-up:

MariaDB [airsonic]> select id, title, status from podcast_channel;
+----+----------------------------------------------------+-----------+
| id | title                                              | status    |
+----+----------------------------------------------------+-----------+
| 19 | La science, CQFD                                   | COMPLETED |
| 20 | LSD, La série documentaire                         | COMPLETED |
| 24 | Le grand dimanche soir                             | COMPLETED |
| 30 | De cause à effets, le magazine de l'environnement  | COMPLETED |
| 46 | Le moment Meurice                                  | COMPLETED |
| 51 | Le Billet de François Morel                        | COMPLETED |
+----+----------------------------------------------------+-----------+
6 rows in set (0,000 sec)
MariaDB [airsonic]> select count(0) from podcast_episode where status="deleted";
+----------+
| count(0) |
+----------+
|     1009 |
+----------+
1 row in set (0,001 sec)

Version

11.1.x (Edge)

Version Detail

11.1.3-SNAPSHOT.20231222134307

Operating System

GNU/Linux Debian

Java Version

Apache Tomcat/9.0.80, java 17.0.9, Linux (295,6 MB / 339,0 MB)

Database

MariaDB 8.x

DB Detail

No response

Configuration paramter

# Airsonic preferences.  NOTE: This file is automatically generated. Do not modify while application is running

JWTKey=plouf
SettingsChanged=1703391145300 
IndexCreationInterval=1 
IndexCreationHour=5 
FastCacheEnabled=false 
OrganizeByFolderStructure=true 
ExcludePattern= 
IgnoreSymLinks=false 
PodcastUpdateInterval=24 
PodcastEpisodeRetentionCount=-1 
PodcastEpisodeDownloadCount=-1 
PodcastFolder=/x/podcasts 
IndexString=A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ)
IgnoredArticles=The El La Los Las Le Les
Shortcuts=New Incoming Podcast
PlaylistFolder=/var/playlists
MusicFileTypes=mp3 ogg oga aac m4a m4b flac wav wma aif aiff ape mpc shn mka opus
VideoFileTypes=flv avi mpg mpeg mp4 m4v mkv mov wmv ogv divx m2ts webm
CoverArtFileTypes2=cover.jpg cover.png cover.gif folder.jpg jpg jpeg gif png
SortAlbumsByYear=true
GettingStartedEnabled=false
WelcomeTitle=En avant la musique
WelcomeSubtitle=Network
WelcomeMessage2=Bienvenue
LoginMessage=Network
Theme=coolandclean
LocaleLanguage=fr
LocaleCountry=
LocaleVariant=
DatabaseMysqlMaxlength=512
DatabaseConfigType=EMBED
DatabaseConfigEmbedDriver=org.mariadb.jdbc.Driver
DatabaseConfigEmbedPassword=plouf
DatabaseConfigEmbedUrl=jdbc:mariadb://localhost:3306/airsonic
DatabaseConfigEmbedUsername=airsonic
DatabaseUsertableQuote=
server.use-forward-headers=native
server.forward-headers-strategy=framework
EncryptionKeyPassword=plouf
EncryptionKeySalt=plouf
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3306/airsonic
spring.datasource.username=airsonic
spring.datasource.password=plouf
spring.liquibase.parameters.mysqlVarcharLimit=512
spring.liquibase.parameters.defaultPodcastFolder=/x/podcasts
UploadsFolder=%{['USER_MUSIC_FOLDERS'][0]}/Incoming
EnableCueIndexing=false
HideIndexedFiles=false
DownloadBitrateLimit=0
UploadBitrateLimit=0
LdapEnabled=false
LdapUrl=ldap://host.domain.com:389/cn=Users,dc=domain,dc=com

Proxy Server

No response

client detail

No response

language

French

Relevant log output

Nothing on log after *clean-up*.
microniko commented 6 months ago

I've noticed that the podcasts remaining after the purge are listed in the left-hand area when I select "podcasts" from the drop-down list (corresponds to the folder where the podcasts are stored). (I restored the snapshot of the VM hosting Airsonic)

kagemomiji commented 6 months ago

@microniko

1. Issue with Podcast Episodes Remaining in the List After Deletion:

The first issue regarding podcast episodes still appearing in the list despite being marked as deleted is because, currently, the system only supports a soft delete for podcast episodes. This means they are marked as deleted but not completely removed from the database. However, this can be improved by implementing a hard delete as part of the clean database process, which would allow for complete removal of these episodes.

2. Podcast Episodes Getting Deleted During Database Cleanup:

The second issue, where some podcasts are deleted during the database cleanup, is likely due to the relationship between 'channel' and 'media_file' being set to cascade delete. It seems that if the 'present' flag for media files associated with a channel is set to false, they get removed in the clean database process. This is probably why some podcasts are unintentionally deleted.


Can I delete podcast episodes that are marked as deleted in the database without any side effects ?

At present, the functionality to delete podcast episodes that are marked as deleted from the database without any side effects does not exist in the system.

microniko commented 6 months ago

@kagemomiji, thanks for your replies.

1. Issue with Podcast Episodes Remaining in the List After Deletion:

The first issue regarding podcast episodes still appearing in the list despite being marked as deleted is because, currently, the system only supports a soft delete for podcast episodes. This means they are marked as deleted but not completely removed from the database. However, this can be improved by implementing a hard delete as part of the clean database process, which would allow for complete removal of these episodes.

Can I delete podcast episodes that are marked as deleted in the database without any side effects ?

At present, the functionality to delete podcast episodes that are marked as deleted from the database without any side effects does not exist in the system.

Ok, I understand that there is noting in Airsonic to do this. But, can I do it directly in the db via Mariadb prompt ? Could this eventually cause a problem in the database ? Something like :

delete from podcast_episode where status="deleted";

2. Podcast Episodes Getting Deleted During Database Cleanup:

The second issue, where some podcasts are deleted during the database cleanup, is likely due to the relationship between 'channel' and 'media_file' being set to cascade delete. It seems that if the 'present' flag for media files associated with a channel is set to false, they get removed in the clean database process. This is probably why some podcasts are unintentionally deleted.

I don't understand if this is a bug or a feature ;-) and if there's anything I can do to avoid it?

kagemomiji commented 5 months ago

@microniko

Ok, I understand that there is noting in Airsonic to do this. But, can I do it directly in the db via Mariadb prompt ? Could this eventually cause a problem in the database ? Something like : delete from podcast_episode where status="deleted";

It can delete without any particular side effects or problems.

I don't understand if this is a bug or a feature ;-) and if there's anything I can do to avoid it?

Before edge-11.1.3-SNAPSHOT.20240124120602 release, there was a bug where the present flag of media_file would unintentionally become false if the library scan timed out. This issue could be related to that. The specific story is as follows: The scan times out -> Some of the media_files related to Podcasts become 'present = false' -> During database cleanup, media_files with 'present=false' are deleted, and the Podcasts are also deleted due to 'cascade delete'.

Therefore, as a solution, please update to the latest edge-release and ensure that the scan is fully completed. If you are experiencing timeouts, refer to this document and extend the scan timeout duration.

microniko commented 5 months ago

I upgraded Airsonic 11.1.3-SNAPSHOT.20240118010212 to 11.1.3-SNAPSHOT.20240128135559 then I ran a full-scan :

janv. 28 17:20:39 assurancetourix java[50441]: 2024-01-28 17:20:39.051  INFO --- o.a.p.s.MediaScannerService              : Scanned media library with 12500 entries.
janv. 28 17:20:39 assurancetourix java[50441]: 2024-01-28 17:20:39.594  INFO --- o.a.p.s.MediaScannerService              : Scanned media library with 12750 entries.
janv. 28 17:20:42 assurancetourix java[50441]: 2024-01-28 17:20:42.384  INFO --- o.a.p.s.MediaScannerService              : Scanned media library with 13000 entries.
janv. 28 17:20:42 assurancetourix java[50441]: 2024-01-28 17:20:42.390  INFO --- o.a.p.s.MediaScannerService              : Scanned media library with 13011 entries.
janv. 28 17:20:42 assurancetourix java[50441]: 2024-01-28 17:20:42.390  INFO --- o.a.p.s.MediaScannerService              : Persisting albums
janv. 28 17:20:42 assurancetourix java[50441]: 2024-01-28 17:20:42.396  INFO --- o.a.p.s.MediaScannerService              : Persisting artists
janv. 28 17:20:42 assurancetourix java[50441]: 2024-01-28 17:20:42.401  INFO --- o.a.p.s.MediaScannerService              : Persisting genres
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.129  INFO --- o.a.p.s.MediaScannerService              : Updating genres
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.129  INFO --- o.a.p.s.MediaScannerService              : Marking non-present albums.
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.130  INFO --- o.a.p.s.MediaScannerService              : Marking non-present artists.
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.135  INFO --- o.a.p.s.MediaScannerService              : Artist persistence complete
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.136  INFO --- o.a.p.s.MediaScannerService              : Album persistence complete
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.151  INFO --- o.a.p.s.MediaScannerService              : Genre persistence successfully complete: true
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.152  INFO --- o.a.p.s.MediaScannerService              : Completed media library scan.
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.154  INFO --- o.a.p.s.MediaScannerService              : Media library scan took 336s
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.154  INFO --- o.a.p.s.MediaScannerService              : Media library scan completed.
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.154  INFO --- o.a.p.service.PlaylistService            : Starting playlist import.
janv. 28 17:20:43 assurancetourix java[50441]: 2024-01-28 17:20:43.154  INFO --- o.a.p.service.PlaylistService            : Completed playlist import.

Then I click on Clean-up database but nothing seems happened - nothing in log… I don't loose my podcast and this is a good new :+1:

kagemomiji commented 5 months ago

I consider this bug resolved by #337. If there are any issues, please Reopen it and I will address them.