Page 1 of 1

DataIntegrityViolationException with duplicate albums

PostPosted: Thu Apr 18, 2013 1:01 am
by sparkplug
Hello,

My media library scan is aborting when it gets to a specific file.

The following exception is in the musicabinet.log:

Code: Select all
[2013-04-18 10:24:59] ERROR LibraryScannerService - Unexpected error caught during scanning!
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into library.file_headertag_import (path, filename, extension,bitrate, vbr, duration, artist_name, album_artist_name, composer_name,album_name, track_name, track_nr, track_nrs, disc_nr, disc_nrs, year,tag_name, lyrics, coverart, artistsort_name, albumartistsort_name) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)]; Batch entry 0 insert into library.file_headertag_import (path, filename, extension,bitrate, vbr, duration, artist_name, album_artist_name, composer_name,album_name, track_name, track_nr, track_nrs, disc_nr, disc_nrs, year,tag_name, lyrics, coverart, artistsort_name, albumartistsort_name) values('I:\Tagged Tunes\7\7 Year Bitch\Sick ''Em [US,1992,m4a,12]','7 Year Bitch-Sick ''Em 01-Chow Down.m4a','M4A','256','true','186','7 Year Bitch','7 Year Bitch',NULL,'Sick ''Em','Chow Down','1','12','1','1','1992','PunkPunk Grunge Alternative Rock Punk Rock Alternative',NULL,'false','7 Year Bitch','7 Year Bitch') was aborted.  Call getNextException to see the cause.; nested exception is java.sql.BatchUpdateException: Batch entry 0 insert into library.file_headertag_import (path, filename, extension,bitrate, vbr, duration, artist_name, album_artist_name, composer_name,album_name, track_name, track_nr, track_nrs, disc_nr, disc_nrs, year,tag_name, lyrics, coverart, artistsort_name, albumartistsort_name) values('I:\Tagged Tunes\7\7 Year Bitch\Sick ''Em [US,1992,m4a,12]','7 Year Bitch-Sick ''Em 01-Chow Down.m4a','M4A','256','true','186','7 Year Bitch','7 Year Bitch',NULL,'Sick ''Em','Chow Down','1','12','1','1','1992','PunkPunk Grunge Alternative Rock Punk Rock Alternative',NULL,'false','7 Year Bitch','7 Year Bitch') was aborted.  Call getNextException to see the cause.
   at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)
   at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
   at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
   at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
   at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
   at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:615)
   at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:884)
   at org.springframework.jdbc.object.BatchSqlUpdate.flush(BatchSqlUpdate.java:184)
   at com.github.hakko.musiccabinet.dao.jdbc.JdbcLibraryAdditionDao.addMetadata(JdbcLibraryAdditionDao.java:104)
   at com.github.hakko.musiccabinet.dao.jdbc.JdbcLibraryAdditionDao.addFiles(JdbcLibraryAdditionDao.java:61)
   at com.github.hakko.musiccabinet.service.library.LibraryAdditionService.receive(LibraryAdditionService.java:44)
   at com.github.hakko.musiccabinet.service.library.LibraryScannerService$1.run(LibraryScannerService.java:135)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into library.file_headertag_import (path, filename, extension,bitrate, vbr, duration, artist_name, album_artist_name, composer_name,album_name, track_name, track_nr, track_nrs, disc_nr, disc_nrs, year,tag_name, lyrics, coverart, artistsort_name, albumartistsort_name) values('I:\Tagged Tunes\7\7 Year Bitch\Sick ''Em [US,1992,m4a,12]','7 Year Bitch-Sick ''Em 01-Chow Down.m4a','M4A','256','true','186','7 Year Bitch','7 Year Bitch',NULL,'Sick ''Em','Chow Down','1','12','1','1','1992','PunkPunk Grunge Alternative Rock Punk Rock Alternative',NULL,'false','7 Year Bitch','7 Year Bitch') was aborted.  Call getNextException to see the cause.
   at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)


The scan then aborted without scanning the rest of the files. I tried restarting the service then restarting the scan, deleting the database, restarting the service then restarting the scan. It always fails here and does not recover. If I run the SQL query in pgAdmin it returns successfully (one row affected)

I then went to remove the file from the media folder and noticed that I have two copies of the same album - one has the MP4 extension and the another is MP3. Removing the duplicate album allows the scan to continue but then abort again when it reaches the next duplicate album - this time FLAC and MP3. I have several duplicates especially with the FLAC and MP3. I find it useful to have the FLAC files for quality playback of my favourite albums and the MP3 files for portability. Can either the code be changed so that it ignores the duplicate albums or the database indexes changed so that the extension is included in the relevant unique constraint?

Thanks,
Dave

Re: DataIntegrityViolationException with duplicate albums

PostPosted: Mon Apr 22, 2013 1:17 am
by sparkplug
Anyone?

I've tried removing unique indexes from a couple of the database tables but cannot locate which one could be causing this exception?

This issue is a show stopper for me and I'll have to go back to the standard subsonic server if there is no fix.

Thanks,
Dave