App is crashing due to the SQLite error code:11 - objective-c

My application is keep crashing first or second time with the error "abc.sqlite is corrupted. SQLite error code:11, 'database disk image is malformed', NSSQLiteErrorDomain=11"
I am unable to track it . anyone Plz help
thanks

(Taken from one of the comments above)
The app was crashing because it was loading on a different thread, app tried to retrieve data before the database was even installed.

This is not entirely true, I ran into same issue today on my iphone, hookup to macbook and use xcode to bring db from iphone to macbook. I used SQLite DB browser, ran PRAGMA integrity_check, it shows an error on one of the pages with code 11. Luckily my table only has 10 records. Wierd thing was when I run "select * from tableA", only 3 records come back. I was able to fix the database accidentally by re-number of some record ID, when saving changes, those missing records shows up mysteriously.. while the corrupted record disappeared.

Related

Realm objective c - really huge db file size - 64GB

We have recently planned to switch from SQLite to Realm in macOS and iOS app due to db file corruption issue with SQLite so we first started with macOS app. All coding changes were smooth and app started working fine.
Background about app and DB usage - app really uses DB very heavily and performs too many read and writes to DB in each minute and saves big xml's to it. In each minute it writes / updates around 10-12 records (at max) with xml and reads 25-30records too. After each read it deletes data along with xml from database and my expectation is once data is deleted it should free up space and reduce file size but looks like it is growing continuously.
To test the new DB changes we kept app running app 3-4 days and DB file size went to 64.42GB and app started being slow. Please refer the attached screen shot.
To further debug, I started app with new DB file and size was 4KB but within 5min it goes to 295KB and never reduced in size even records were continuously added and deleted.
To further clarify, app uses NSThreads to perform various operations and those threads writes and reads data to DB but with proper begin\commit transactions. I also read at 'Large File Size' at https://realm.io/docs/java/latest/#faq and tried to find compactRealm but can't find it in objective c.
Can anybody please advise.
Update - I Give up on Realm
After 15days of efforts, Finally I have stopped usage of Realm and starting to fix/workaround db file corruption issue with SQLite. Realm Huge DB file issue was fixed by making changes to code for threads but then I started getting Too many open files error after running the app for 7-8 hours.
Debugged for whole week and made all possible changes and at some point looks like all was good as xcode were not showing any open files. But again I started getting Too many open files crash and then debugged with instrument and found there were so many open files to realm database, lock, commit and cv files.
I am sure there are no leaks in app and xcode also does not shows those open files in Disk usage as well. I decided to invoke lsof command in code before and after Realm calls and most of the it doesn't increase open file count but sometime n between it increases. In My app it started from 120 files to 550 in around 6 hours. Xcode looks all fine via Disk usage but instrument shows open files.
No good support from Realm team, sent email to them, just got one response. Made many changes to code following their suggestions and doesn't work at all so gave up on it. I think it's good for small apps only.

MS Access occassional "Cannot open any more databases" error

I have an MS Access (2013) application with a split database. Everything seems to run smoothly except for occasionally I will get Error 3048: Cannot open any more databases.
The error occurs when the front end tries to run vba code which involves pulling data from the back end and will stall on any line with: Set DB = OpenDatabase() or DoCmd.RunSQL() commands.
The strange thing is that this error seems to be time based. I can access the back end hundreds of times without error if I do it quickly enough but after some time has passed (~1 hr) the error shows up. In fact, I can open the application and leave it running in the background (with no code running) then go back into it after an hour and I will get the error the first time the code tries to open the back end.
I've searched the length and breath of this site and google for solutions so I know this error has been addressed before. To save people reiterating the usual fixes I will list what I've tested for so far with no success:
Recordset limit: I'm not leaving any recordsets open, every time I open one I make sure to close it. The same for the databases. All my requests
to the back end are done via 3 or 4 vba functions and each of these has
a Rec.Close or DB.Close corresponding to every OpenRecordset()
and OpenDatabase() and I never have more than 2 recordsets open at
a time.
Control limit: I have 151 controls on the biggest form in the application so I should be below the limit (I believe this is 245 for a single form?)
Corrupt database: I've copied all my forms and code to a new Access database and run a Compact and Repair.
Machine Issue: I've tested the application on several machines and reproduced the same error.
Anyway with most of the above situations I would expect the application not to run at all, instead of running fine for a set amount of time and then crashing.
Some other points of note:
Citrix Users: The users are split between normal windows machines users who are experiencing this error and others who are using the application through a virtual desktop software (Citrix) who are having no issues. Unfortunately I don't know enough about this virtual desktop to really work out what that implies.
Background vs Foreground: Some users have claimed that the application only crashes if it has been running for a long time AND they switch over to another program and switch back. I've confirmed that simply switching between the application and other programs doesn't cause it to crash but haven't yet been able to leave it running in the foreground long enough to confirm if it crashes without switching between programs.
I've been struggling with this for days, anyone able to help me out?

org.hibernate.ObjectNotFoundException [Company.Table#-1]

I set up a new database on 2 new servers and got this error in my GWT application on both servers:
Fatal Error:
org.orm.PersistentException: org.orm.PersistentException:
org.orm.PersistentException:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [Company.Table#-1]
The same system is already running on 5 other servers without problems (same MS SQL version, same GWT application, sql data is replicated). Therefore, I think it is not a bug in my GWT application.
The same error I used to get. I found that the data is already deleted or not available in database but still data was accessed from eg: from client.
ex. I deleted one row from from my view GRID in GWT App but it was not reloaded and it was showing on screen I again tried to delete the same row I got this error.
Solution : Refresh the page will solve the problem. It worked for me. :)

SQLite database image getting malformed at build time in Xcode

I'm working on a iOS 6 app, and am using a SQLite database to store data. At startup the app does a select on the database and displays the results on the first screen.
However I've started to get an "Database disk image is malformed" error when trying to run the select.
The strange thing is that I can use SQLite browser, http://sqlitebrowser.sourceforge.net/, to do the select on the database in the project folder. But if I try to open the database after it has been copied to the simulator folder, /Users//Library/ApplicationSupport/iPhone simulator/6.0/Applications/... then I get a disk image is malformed.
The database is not being accessed by a background thread, nor am I using breakpoints to halt execution as is being suggested as a reason here sqlite database disk image malformed on iPhone SDK.
No more than one execution being done on the database at once.
All hints, tips and possible solutions are appreciated.
I've found out that this had something to do with me bundling a rather large database file with the app (larger than 3 GB). I've fixed the problem by doing a in-app download of the data over wifi. This caused the database error to fade away.

sqlite unclosed read transaction

I'm using sqlite3 in an iOS application and I've encountered a very strange issue multiple
times.
I'm using WAL and all of my writes happen on a managed thread that only allows 1 operation at a time and my reads use a different database handle and everything works fine. The issue I'm seeing is sometimes my read handle gets into this weird state where it won't read committed data. It's like it has an uncommitted read transaction...
I can write successfully to the database and I've exported my results to my computer where I see the newly written results just fine. However, my reads seem to access the database at an older point in time...it's like they're stuck. If I close the application and reopen it, they're fine and they read the newly committed data, but I'm wondering how my application is getting stuck in this state.
ANY help would be appreciated. Thanks in advance.
I ran into the exact same issue but on Debian Lenny (kernel 2.6.33) w/ SQLite3 3.7.7.1.
It turned out that I got some processes hanging on to some stale DB file descriptors after I deleted and recreated a database file.
I fixed it by making sure all processes that used the DB were killed before recreating the DB again.
By getting rid of the old processes, the file handles were deleted as well.