Failed to Initialize database

Post your Server Bug Report
Clifford
Posts: 21
Joined: 07 Nov 2013, 17:03
Has thanked: 0
Been thanked: 9 times

Failed to Initialize database

Unread post by Clifford »

Any idea how I might fix this? Logfile is attached, but here are the first few lines

[2014-04-10 09:28:44,410] INFO DaoHelper - Checking database schema.
[2014-04-10 09:29:39,806] ERROR DaoHelper - Failed to initialize database.
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: File input/output error c:\madsonic/db/subsonic.backup java.io.EOFException: Unexpected end of ZLIB input stream
Attachments
madsonic.log
(12.74 KiB) Downloaded 247 times
User avatar
Madsonic
Administrator
Administrator
Posts: 984
Joined: 07 Dec 2012, 03:58
Answers: 7
Has thanked: 1201 times
Been thanked: 470 times

Re: Failed to Initialize database

Unread post by Madsonic »

hi there,

it looks like you have a corrupted database file, try to stop the Madsonic Service, delete the c:\madsonic\db folder (to restart DB from scratch)
and restart your service. A new Database will be created automatically.

best regards
Clifford
Posts: 21
Joined: 07 Nov 2013, 17:03
Has thanked: 0
Been thanked: 9 times

Re: Failed to Initialize database

Unread post by Clifford »

Thanks, recreating now.

For future, is there any way to save/backup playlists, ratings, etc?
GJ51
Contributor
Contributor
Posts: 192
Joined: 15 Dec 2012, 17:52
Has thanked: 42 times
Been thanked: 83 times

Re: Failed to Initialize database

Unread post by GJ51 »

Sure - make a back up BEFORE it crashes.

Just make a regular archive copy of the C:\Madsonic directory so you have a recent backup. You can manually copy once in a while, or if you're on Windoze you can use SyncToy to make automated backups. If you do the automated route, just be sure to occasionally back up one of the backups so that the process doesn't just blindly overwrite a good backup with a new "crashed" copy.
Clifford
Posts: 21
Joined: 07 Nov 2013, 17:03
Has thanked: 0
Been thanked: 9 times

Re: Failed to Initialize database

Unread post by Clifford »

Do I need to shutdown madsonic prior to the backup?
GJ51
Contributor
Contributor
Posts: 192
Joined: 15 Dec 2012, 17:52
Has thanked: 42 times
Been thanked: 83 times

Re: Failed to Initialize database

Unread post by GJ51 »

Probably a good idea. I'm not sure, but it makes sense to stop the service, copy, then restart.
Clifford
Posts: 21
Joined: 07 Nov 2013, 17:03
Has thanked: 0
Been thanked: 9 times

Re: Failed to Initialize database

Unread post by Clifford »

Synctoy wasn't working for me, not enough control.

Here's my attempt at a backup batch file. If you're interested I can send the called batch files as well.

@echo off
set appver=1.1
:: Check for new version on the server, move it local if updated
call checkbat MadSonicBackup
echo .
echo %0 Ver 1.0
if (%debug%)==(on) set debug=on

if /i (%1)==(/w) echo Force Weekly
:: Backup Drive
set dest=R:

:: every tried to break out of process that doesn't ask for keyboard input?
set break on
:: Time the backup. A backup time that is out of whack indicates a problem
call elapsedtime /start

call Logger MadSonic Backup Started
:: Determine which day it is. Daily backups have their own folder
call dow.bat
set wkly=Sun

:: Are we forcing a weekly backup?
if /i (%1)==(/w) set wkly=%dow%
echo %wkly%

if /i (%debug%)==(on) pause

echo Backing up for %dow%
echo stopping MadSonic service
"c:\madsonic\madsonic-service.exe" -stop
echo Madsonic Service Stopped

if (%dow%)==(%wkly%) echo Backup for %dow% is Weekly (%wkly%)
if not (%dow%)==(%wkly%) echo Backup for %dow% is Daily (weekly is %wkly%)
echo .

:next1
:: Make folders if they don't exist
if not exist R:\backups\Madsonicbackup\*.* md R:\backups\Madsonicbackup
if not exist R:\backups\madsonicbackup\%computername%\*.* md R:\backups\madsonicbackup\%computername%
if not exist R:\backups\madsonicbackup\%computername%\daily\*.* md R:\backups\madsonicbackup\%computername%\daily
if not exist R:\backups\madsonicbackup\%computername%\weekly_%wkly%\*.* md R:\backups\madsonicbackup\%computername%\weekly_%wkly%

:: Variable dest is where the backups will go
set dest=R:\backups\madsonicbackup\%computername%\daily
set msg=Madsonic Backup Finished
if /i (%debug%)==(on) pause

if (%1)==(/t) set msg=TEST %msg%

if (%dow%)==(%wkly%) set dest=R:\backups\madsonicbackup\%computername%\weekly_%wkly%
if (%dow%)==(%wkly%) set msg=Madsonic Weekly Backup on %dow% Finished
if not (%dow%)==(%wkly%) echo Doing daily Backup to %dest%
if (%dow%)==(%wkly%) echo Doing Weekly Backup to %dest%

Echo Some quick Housekeeping
echo Backing up to: %dest%

echo Cleaning DB folder
if not (%dow%) == (Fri) goto noclean
del %dest%\db\*.* /s /f /q > nul
echo Cleaning Jetty Folder
del %dest%\jetty\*.* /s /f /q > nul
echo Cleaning Lucene Folder
del %dest%\lucene\*.* /s /f /q > nul
echo Cleaning Main Folder
del %dest%\*.* /f /q > nul

:noclean

set break=on
echo Copying MadSonic files to %dest%
call Logger "%msg%" %dest%
echo on
del %dest%\db\*.* /f /Q
dir c:\madsonic
echo Backing up to: %dest%, This will take a while
echo .
xcopy c:\madsonic\*.* %dest% /Y /d /s > nul


:: Clean up the Podcast folder, we don't need to keep that
del %dest%\podcasts\*.mp3 /f /Q

echo off
call elapsedtime /stop
call Logger Ended: "%msg%" %dest% " Total Elapsedtime: "%elapsed%
sleep 5

if exist %dest%\tmp*.txt del %dest%\tmp*.txt /f
:: We call Filestamp so folders will show they have been updated
call filestamp R:\backups\madsonicbackup\%computername%\


:: All good - restart
c:\madsonic\madsonic-service.exe -start

if /i (%debug%)==(on) pause

:next2
if (%1)==(/t) echo Backup to %dest%


:: We should email the log here....but we haven't yet
These users thanked the author Clifford for the post (total 2):
MadsonicGJ51
Rating: 15.38%
GJ51
Contributor
Contributor
Posts: 192
Joined: 15 Dec 2012, 17:52
Has thanked: 42 times
Been thanked: 83 times

Re: Failed to Initialize database

Unread post by GJ51 »

Thank you,

Nice job. Personally, I don't run into db failures very often and I run several Subsonic/Madsonic instances in parallel in multiple VM's, but your efforts here are much appreciated. This seems to be a common issue in the forums. I don't know why, other than factors that might turn the host machine off without giving the db time to close out the files properly. Could be related to drive caches not flushing prior to shutdown or something along those lines.

In any event, I'm sure that many Windows users might find this a valuable way to be prepared.
These users thanked the author GJ51 for the post:
Madsonic
Rating: 7.69%
Clifford
Posts: 21
Joined: 07 Nov 2013, 17:03
Has thanked: 0
Been thanked: 9 times

Re: Failed to Initialize database

Unread post by Clifford »

Thanks. BTW, I noticed a bug where I used the subfolder named ...\daily where I should have used ...\%dow%. I could have gone with son, father, grandfather, but this was easier.

I've attached the updated file here. If anyone is interested, let me know and I can supply the supporting files.
Attachments
MadSonicBackup.rar
(1.2 KiB) Downloaded 208 times
These users thanked the author Clifford for the post (total 2):
MadsonicGJ51
Rating: 15.38%
Post Reply