-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
closing FMDB database #848
Comments
I'm not sure what the policies of iOS would be concerning this. Maybe close it just to be safe, so in case the disk encryption kicks in or something you won't have a handle later on that's not in good working order? |
I have this crash 0xdead10cc. https://developer.apple.com/forums/thread/126438 I was wondering if is necessary or I have to 'sql interrupt' what the transaction is doing before iOS system kills the app |
This is beyond my expertise (I'm not an iOS coder). So I'd just say do whatever the Apple person is recommending in that post. |
FWIW,
So, there are one of two possibilities. Either:
Bottom line, there are multiple sources of this problem and each has its own solution. |
No, IMHO, it is exceedingly unlikely that the problem rests in FMDB. The problem is undoubtedly how you are using it. Like I said, the problem is likely that the
I’m not entirely surprised by that. When SQLite is busy or a GCD queue is blocked, that won't generally result in Xcode warnings. Instruments is a little better in this regard, but not even that will always show it. Besides, as I said, you cannot test this lifecycle stuff while attached to the Xcode debugger anyway. I'd suggest you post a MRE. Note, we don’t want to see your whole project, but create a small, standalone example that manifests the problem in question. There is simply not enough here for us to diagnose the problem. But do I gather that you are reporting an intermittent crash? That suggests option 1, above, with |
I wrapped the close procedure function in a background task to see if it solves the problem. Checking my code I found that I open 2 FMDB queue on the same file 1 dedicated to read the other to write |
You should only have one queue open. Two queues open will possibly lead to a deadlock. |
the idea was to have 2 FMDBQueue instances (1reader/1writer) on the same file. 2.2. Concurrency .... Writers merely append new content to the end of the WAL file. Because writers do nothing that would interfere with the actions of readers, writers and readers can run at the same time. However, since there is only one WAL file, there can only be one writer at a time. [WAL](https://www.sqlite.org/wal.html) If I use the FMDBQueue methods I don't see how they can hang they are processed in separate dispatch_queue and sqlite seems built to manage the internal concurrency |
The crash report is simply telling you that the SQLite database (or some other file) is open when the app suspends. End of story. So, it strikes me that you first have to determine whether it is really deadlocking, or whether it’s just slow and is still in progress when the app suspends. (Given that the problem is intermittent, I bet it is not really deadlocking, but is just slow.) Some logging statements would help here. (And if you want to watch these logging statements while running the app while not connected to the Xcode debugger, rather than using And if it’s just slow, the next question is whether it is taking more time than But there simply is not enough here for us to help you further. We need more diagnostic information (or a MRE). By the way, you say that you’re closing the database in
Personally, I never start and end background tasks in |
Thanks :) |
do I have to close the database when the app is sent to background or I can keep it open?
Thanks
The text was updated successfully, but these errors were encountered: