'Unknown error calling sqlite3_step (11: database disk image is malformed) eu : iOS
I am working on an iOS App, using SQLite DB. The app has a functionality where on opening the app, records from the server are inserted into the local SQLite db. During this process, my SQLite DB is getting corrupted.
Gives the following error:
Unknown error calling sqlite3_step (11: database disk image is malformed) eu
2022-04-05 11:55:39.643654+0530 HCUserBook[30620:1755003] DB Query: INSERT OR REPLACE INTO HCUserInfo (UserID, UserCode, UserSubCode, UserType, IDNumber, Status, PB_Update_Date, SOS_ID, PCode, Precinct, PrecSub, PartyID, DateTimeStamp, isPushedToServer) VALUES (1704059, "0322", "00", "P", "1546811", "APPR", "2019-04-04 07:54:23:539", "1106853801", "", "0210", "01", "D", "2022-02-01 09:01:11", 1)
2022-04-05 11:55:39.643746+0530 HCUserBook[30620:1755003] Unknown error finalizing or resetting statement (11: database disk image is malformed)
2022-04-05 11:55:39.643815+0530 HCUserBook[30620:1755003] DB Query: INSERT OR REPLACE INTO HCUserInfo (UserID, UserCode, UserSubCode, UserType, IDNumber, Status, PB_Update_Date, SOS_ID, PCode, Precinct, PrecSub, PartyID, DateTimeStamp, isPushedToServer) VALUES (1704059, "0322", "00", "P", "1546811", "APPR", "2019-04-04 07:54:23:539", "1106853801", "", "0210", "01", "D", "2022-02-01 09:01:11", 1)
2022-04-05 11:55:39.644163+0530 HCUserBook[30620:1755003] Unknown error calling sqlite3_step (11: database disk image is malformed) eu
2022-04-05 11:55:39.644244+0530 HCUserBook[30620:1755003] DB Query: INSERT OR REPLACE INTO HCUserInfo (UserID, UserCode, UserSubCode, UserType, IDNumber, Status, PB_Update_Date, SOS_ID, PCode, Precinct, PrecSub, PartyID, DateTimeStamp, isPushedToServer) VALUES (1736570, "0322", "00", "P", "1862069", "APPR", "2019-04-04 07:54:23:540", "1114139138", "", "0491", "02", "D", "2022-02-03 13:41:16", 1)
2022-04-05 11:55:39.644329+0530 HCUserBook[30620:1755003] Unknown error finalizing or resetting statement (11: database disk image is malformed)
.
.
.
This is a random issue, happens only a few times.
I extracted the SQLite DB from the device and ran PRAGMA integrity_check _command on it using DBBrowser.
I got the following result
*** in database main ***
Page 19100: free space corruption
Page 22612: free space corruption
Page 22858: free space corruption
Page 19602: free space corruption
On tree page 56 cell 0: invalid page number 24126
On tree page 56 cell 2565: invalid page number 24125
On tree page 56 cell 2564: invalid page number 24124
On tree page 56 cell 2563: invalid page number 24122
On tree page 56 cell 2562: invalid page number 24121
On tree page 56 cell 2561: invalid page number 24120
On tree page 56 cell 2560: invalid page number 24119
On tree page 56 cell 2559: invalid page number 24117
On tree page 56 cell 2558: invalid page number 24115
On tree page 56 cell 2557: invalid page number 24114
On tree page 56 cell 2556: invalid page number 24112
Page 21881: free space corruption
On tree page 82 cell 36: invalid page number 24123
On tree page 58 cell 158: invalid page number 24118
On tree page 58 cell 102: invalid page number 24116
On tr
row 1 missing from index idx_HCPDR_Name
row 1 missing from index idx_HCPDR_DriverLicNo
row 1 missing from index idx_HCPDR_Birthdate
row 2 missing from index idx_HCPDR_Name
row 2 missing from index idx_HCPDR_DriverLicNo
row 2 missing from index idx_HCPDR_Birthdate
row 3 missing from index idx_HCPDR_Name
row 3 missing from index idx_HCPDR_DriverLicNo
row 3 missing from index idx_HCPDR_Birthdate
row 4 missing from index idx_HCPDR_Name
row 4 missing from index idx_HCPDR_Birthdate
row 5 missing from index idx_HCPDR_Name
row 5 missing from index idx_HCPDR_DriverLicNo
row 5 missing from index idx_HCPDR_Birthdate
row 6 missing from index idx_HCPDR_Name
row 6 missing from index idx_HCPDR_DriverLicNo
row 6 missing from index idx_HCPDR_Birthdate
row 7 missing from index idx_HCPDR_DriverLicNo
row 7 missing from index idx_HCPDR_Birthdate
row 8 missing from index idx_HCPDR_Name
row 8 missing from index idx_HCPDR_DriverLicNo
row 8 missing from index idx_HCPDR_Birthdate
row 9 missing from index idx_HCPDR_Name
row 9 missing from index idx_HCPDR_DriverLicNo
row 9 missing from index idx_HCPDR_Birthdate
row 10 missing from index idx_HCPDR_Name
row 10 missing from index idx_HCPDR_DriverLicNo
row 10 missing from index idx_HCPDR_Birthdate
row 11 missing from index idx_HCPDR_Name
row 11 missing from index idx_HCPDR_DriverLicNo
row 11 missing from index idx_HCPDR_Birthdate
row 12 missing from index idx_HCPDR_Name
row 12 missing from index idx_HCPDR_DriverLicNo
row 12 missing from index idx_HCPDR_Birthdate
row 13 missing from index idx_HCPDR_Name
row 13 missing from index idx_HCPDR_DriverLicNo
row 13 missing from index idx_HCPDR_Birthdate
row 14 missing from index idx_HCPDR_Name
row 14 missing from index idx_HCPDR_DriverLicNo
row 14 missing from index idx_HCPDR_Birthdate
row 15 missing from index idx_HCPDR_Name
row 15 missing from index idx_HCPDR_DriverLicNo
row 15 missing from index idx_HCPDR_Birthdate
row 16 missing from index idx_HCPDR_Name
row 16 missing from index idx_HCPDR_Birthdate
row 17 missing from index idx_HCPDR_Name
row 17 missing from index idx_HCPDR_DriverLicNo
row 17 missing from index idx_HCPDR_Birthdate
row 18 missing from index idx_HCPDR_Name
row 18 missing from index idx_HCPDR_DriverLicNo
row 18 missing from index idx_HCPDR_Birthdate
row 19 missing from index idx_HCPDR_Name
row 19 missing from index idx_HCPDR_DriverLicNo
row 19 missing from index idx_HCPDR_Birthdate
row 20 missing from index idx_HCPDR_Name
row 20 missing from index idx_HCPDR_DriverLicNo
row 20 missing from index idx_HCPDR_Birthdate
row 21 missing from index idx_HCPDR_Name
row 21 missing from index idx_HCPDR_DriverLicNo
row 21 missing from index idx_HCPDR_Birthdate
row 22 missing from index idx_HCPDR_Name
row 22 missing from index idx_HCPDR_DriverLicNo
row 22 missing from index idx_HCPDR_Birthdate
row 23 missing from index idx_HCPDR_Name
row 23 missing from index idx_HCPDR_DriverLicNo
row 23 missing from index idx_HCPDR_Birthdate
row 24 missing from index idx_HCPDR_Name
row 24 missing from index idx_HCPDR_DriverLicNo
row 24 missing from index idx_HCPDR_Birthdate
row 25 missing from index idx_HCPDR_Name
row 25 missing from index idx_HCPDR_DriverLicNo
row 25 missing from index idx_HCPDR_Birthdate
row 26 missing from index idx_HCPDR_Name
row 26 missing from index idx_HCPDR_DriverLicNo
row 26 missing from index idx_HCPDR_Birthdate
row 27 missing from index idx_HCPDR_Name
row 27 missing from index idx_HCPDR_DriverLicNo
row 27 missing from index idx_HCPDR_Birthdate
row 28 missing from index idx_HCPDR_Name
row 28 missing from index idx_HCPDR_DriverLicNo
row 28 missing from index idx_HCPDR_Birthdate
row 29 missing from index idx_HCPDR_Name
row 29 missing from index idx_HCPDR_DriverLicNo
row 29 missing from index idx_HCPDR_Birthdate
row 30 missing from index idx_HCPDR_Name
row 30 missing from index idx_HCPDR_DriverLicNo
row 30 missing from index idx_HCPDR_Birthdate
row 31 missing from index idx_HCPDR_Name
row 31 missing from index idx_HCPDR_DriverLicNo
row 31 missing from index idx_HCPDR_Birthdate
row 32 missing from index idx_HCPDR_Name
row 32 missing from index idx_HCPDR_DriverLicNo
row 32 missing from index idx_HCPDR_Birthdate
row 33 missing from index idx_HCPDR_Name
row 33 missing from index idx_HCPDR_DriverLicNo
row 33 missing from index idx_HCPDR_Birthdate
row 34 missing from index idx_HCPDR_Name
row 34 missing from index idx_HCPDR_DriverLicNo
row 34 missing from index idx_HCPDR_Birthdate
Note: While creating SQLite DB for my iOS App, I set PRAGMA page_size = 65536 _and after that ran Vaccum.
Earlier, I used to solve this problem by creating a fresh SQLite DB and then use it in my iOS App. But this time it didn't work. The issue is random, sometimes I don't get any corruption issue, and sometimes I do.
Please help.
Thanks
Solution 1:[1]
Few suggestions:
- Make sure you are not trying to access the db from multiple threads at same time. All the db operations should be performed serially while working with sqlite.
- Have you checked this issue on different devices to see if it is occurring on a specific device, iOS version.
- If you are using any library for db operations on iOS, make sure the version of library is stable and don't have any such issue reported by any other user.
please update this thread if this issue is already fixed and what fix worked for you.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shivam Bansal |