Crash or Error related to "11: database disk image is malformed"

Product(s): WaterGEMS, WaterCAD, HAMMER, SewerGEMS, CivilStorm, StormCAD, SewerCAD
Version(s): 10.XX.XX.XX
Area: Other


When using the "Update database cache" tool, the following error occurs:

Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Inner Exception: Haestad.SQLite.SQLiteException: 11: database disk image is malformed


The following error is generated after compacting database and opening the model:

“11: database disk image is malformed”


This error or exception can occur when the database is corrupted in some way. When updating or compacting a database, the step "Purging elements marked as deleted…" is skipped. This step is skipped when compacting the database while the model is opened and when compacting with the model closed and selecting "Purge records to save space". The deleted elements do not get purged from the database which can sometimes result in this problem.


To resolve this notification the following options can be adopted;

Option 1: Restoring the model from backup

The first step would be to try to restore the model from the backup file.

For example, if this crash or error occurred while working on WaterGEMS, then try to locate the .WTG.SQLITE.BAK and .WTG.BAK files to restore the model from.

The steps to recover models from backup files can be found here.

If the model is successfully restored, check if you get the error or crash by going to File > Database Utilities > Update Database Cache. If the error or crash persists, then please contact Technical Support for resolution.

Option 2: Export sub-model and import it into new workspace

With this option you can simply export the entire model as a sub-model and importing it in a new workspace.

1. Select all elements in the model (Home > Drawing > Select > Select All) or manually select all elements.

2. Go to File > Export > Submodels

3. Save the .sqlite file in a separate location. Close the model.

4. Go to File > Import > Database. Browse to the location of the newly saved database file (.sqlite) and open it.

5. The exception will no longer occur.

Note: With this option there might be some minor loss of data though (things not exported to the submodel). It is better to save a backup of the model for future reference.

If the above options do not work, please contact Technical Support to repair your database. Repairing the database involves checking the integrity of the database (.SQLITE file) and re-indexing which should fix this problem.

If you are comfortable with doing so, you can try repairing the database yourself. Be sure to make a backup of the model’s .SQLITE file first. This is the model’s database file and is in the same folder where the model is stored, with the same base file name. Using an application that can open SQLITE files, try re-indexing all tables or run an integrity check for  the SQLITE file. There are several applications like SQLITE Export or DB Browser for SQLITE has options to check the integrity of the database and repair it.

See Also

Can I restore a backup file of my model project or software component?