#1 2016-10-18 13:49:34

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Had an error "database disk image is malformed"

Experienced an error:

ESQLite3Exception {"ErrorCode":11,"SQLite3ErrorCode":12,"Message":"Error SQLITE_CORRUPT (11) [Step] using 3.15.0 - database disk image is malformed, extended_errcode=11"}

Not sure why...

Full error msg below, I'm wondering if anybody have any ideas about...

20161018 21414020 EXC   	ESQLite3Exception {"ErrorCode":11,"SQLite3ErrorCode":12,"Message":"Error SQLITE_CORRUPT (11) [Step] using 3.15.0 - database disk image is malformed, extended_errcode=11"} at 006A540E SynSQLite3.sqlite3_check (5317)  stack trace 00406C32 System.@FreeMem 0040DBE6 System.@DynArrayClear 0079C872 mORMot.TSQLModel.GetTableIndexesFromSQLSelect (32232) 007AFB63 mORMot.TSQLRestServerURIContext.ExecuteORMGet (38666) 007AE538 mORMot.TSQLRestServerURIContext.ExecuteCommand (38323) 0040B56F System.@LStrFromPCharLen 007ADA0A mORMot.TSQLRestServerURIContext.InternalSetTableFromTableName (38111) 0067477D SynCommons.SortDynArrayAnsiStringI (41926) 007B438E mORMot.TSQLRestServer.URI (39873) 0067DA82 SynCommons.TTextWriter.AddPointer (46786) 0090F457 mORMotHttpServer.TSQLHttpServer.Request (929) 008F79FF SynCrtSock.THttpServerGeneric.Request (3954) 008FC635 SynCrtSock.THttpApiServer.Execute (6408) 004A925D madExcept.HookedTThreadExecute (17342) 00538FF9 System.Classes.ThreadProc 0040B216 System.ThreadWrapper 004A9143 madExcept.CallThreadProcSafe (17277) 004A91AB madExcept.ThreadExceptFrame (17325) 

20161018 21414022 ERROR 	DbSvr.TDbSvr(042175E0) {"ESQLite3Exception(026D01D0)":{"ErrorCode":11,"SQLite3ErrorCode":"secCORRUPT","Message":"Error SQLITE_CORRUPT (11) [Step] using 3.15.0 - database disk image is malformed, extended_errcode=11"}} for (SQL eliminated here...) stack trace API 0079F6C8 mORMot.TSQLRest.InternalLog (33183) 0090028E mORMotSQLite3.TSQLRestServerDB.GetAndPrepareStatementRelease (819) 00902326 mORMotSQLite3.TSQLRestServerDB.MainEngineList (1336) 007AFB63 mORMot.TSQLRestServerURIContext.ExecuteORMGet (38666) 007AE538 mORMot.TSQLRestServerURIContext.ExecuteCommand (38323) 007B438E mORMot.TSQLRestServer.URI (39873) 0090F457 mORMotHttpServer.TSQLHttpServer.Request (929) 008F79FF SynCrtSock.THttpServerGeneric.Request (3954) 004A925D madExcept.HookedTThreadExecute (17342) 00538FF9 System.Classes.ThreadProc 0040B216 System.ThreadWrapper 004A9143 madExcept.CallThreadProcSafe (17277) 004A91AB madExcept.ThreadExceptFrame (17325) 

Thanks!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2016-10-18 14:22:49

Chaa
Member
Registered: 2011-03-26
Posts: 244

Re: Had an error "database disk image is malformed"

I got this error when I use (by mistake) non thread-safe SQLite connection in multi-threaded server.
After some time the database has been corrupted.
My mistake: http://synopse.info/forum/viewtopic.php?id=3352

Offline

#3 2016-10-18 15:38:37

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: Had an error "database disk image is malformed"

I discover such errors (sometimes) in case SynchronousMode <> Full and I shut down server, quickly copy the database and run a server with a database copy. I think this is because windows not flush a disk buffers.

Last edited by mpv (2016-10-18 15:38:58)

Offline

#4 2016-10-18 16:31:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Had an error "database disk image is malformed"

Did you use encryption?

Offline

#5 2016-10-19 08:01:17

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Had an error "database disk image is malformed"

@ab, No, I'm not using any database-level encryption.

@mpv, Just checked, In my program, TSQLRestServerDB.Synchronous is set to smFull;// to ensure max data stability!

@chaa, If I understand you correctly - I'm not using RemoteDataCreate() nor TSQLDBSQLite3ConnectionProperties (nor its decadent classes) directly.


PS, My win7 has the latest updated, and the db file is inside a TrueCrypt 7.1a virtual disk, but I don't think it's the problem, since I've been using TrueCrypt for over 10 years now, it's extremely stable.

And another extended question - Is it possible to cause database corruption if the program accessing it is killed by the Windows Task Manager?


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#6 2016-10-19 09:17:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Had an error "database disk image is malformed"

I suspect that database corruption can occur if you kill a process.
Like for any database corruption.

Even if smFull should reduce the risk.
See https://www.sqlite.org/howtocorrupt.html

In all cases, ensure you delete the journal files before re-starting it.

Offline

#7 2016-10-20 15:52:31

turrican
Member
From: Barcelona
Registered: 2015-06-05
Posts: 94
Website

Re: Had an error "database disk image is malformed"

Are you using static linked SQLite3 Library or external library? I am using the last SQLite3 library and a 7GB database no corruption.

Offline

#8 2016-10-20 19:25:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,183
Website

Re: Had an error "database disk image is malformed"

We have SQLite3 DBs of more than 100GB, with no corruption problems...

Offline

#9 2016-10-21 08:55:03

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Had an error "database disk image is malformed"

I use the .obj files - it's statically linked.

@ab, yes, I've been using mORMot for a long time, and this is the first time i had such situation.

PS, the db file is not entirely corrupted - Some tables are completely ok, while one of the tables will emit the originally posted error message in the server log, but, some of the record data can still be read from that so-called malfunctioned table...


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB