The CoreData stack initialization is freeze at the function call
-[NSPersistentStoreCoordinator addPersistentStoreWithType:configuration:URL:options:error:].
It doesn't return any errors. The CoreData debug logs console shows:
CoreData: annotation: Core Data multi-threading assertions enabled.
CoreData: annotation: Connecting to sqlite database file at "/var/mobile/Containers/Data/Application/1B4CD169-5CCB-4949-B8B2-943A8EDC7478/Documents/myDB.sqlite"
CoreData: sql: SELECT TBL_NAME FROM SQLITE_MASTER WHERE TBL_NAME = 'Z_METADATA'
2023-02-28 16:29:37.357278-0800 AppName[1016:183178] [BackgroundTask] Background Task 8 ("CoreData: Adding persistent store"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
CoreData: error: Unexpected background task assertion cancellation.
2023-02-28 16:30:35.668186-0800 AppName[1016:183178] [BackgroundTask] Background task still not ended after expiration handlers were called: <_UIBackgroundTaskInfo: 0x28258fec0>: taskID = 8, taskName = CoreData: Adding persistent store, creationTime = 16118 (elapsed = 753). This app will likely be terminated by the system. Call UIApplication.endBackgroundTask(_:) to avoid this.
It repeats multiple times the same log:
2023-02-28 16:30:01.186448-0800 AppName[1016:183461] [GEOXPC] Throttled "PlaceRequest.REQUEST_TYPE_REVERSE_GEOCODING" request: Tried to make more than 50 requests in 60 seconds, will reset in 1 seconds - Error Domain=GEOErrorDomain Code=-3 "(null)" UserInfo={details=(
{
intervalType = short;
maxRequests = 50;
"throttler.keyPath" = "app:com.company.myApp/0x20304/short(default/any)";
timeUntilReset = 1;
windowSize = 60;
}
), requestKindString=PlaceRequest.REQUEST_TYPE_REVERSE_GEOCODING, timeUntilReset=1, requestKind=772}
The DB is populated with 11 MB size data, is created by iOS app, is opened after app version upgraded. The new app version has new DB module version with basic data migration (removed 3 tables, changed data type with entity mapping).
It happens rare with a released app. I cannot reproduce it in the Xcode debug or released app. No crash reports. The exported DB sqlite file is opened successfully with the SQLite editors and all module updates are applied successful. If it's imported to another iOS device then the app works well and can read data. Something happens on this iPad and after app reinstall it works.
Why CoreData init freeze on Z_METADATA query? Possible the table is corrupted. How I can verify it for any issues?
Why Background Task 8 is created? The func is called on the background thread. Possible migration process creates a Background Task.
What GEOXPC log means?
I found that the sqlite-wal file exists so far the DB session is opened but it's still on the iPad disk storage even the iOS app is force closed. This file keeps transactions that were previously committed to the DB. Is it possible that the file keeps bad DB status and next app execution freezes at the first `SELECT' query?
I tried to export the DB sqlite, sqlite-shm, sqlite-wal files from the iPad but only sqlite, sqlite-shm are copied to my mapbook. How I can copy WAL file?
I found that the sqlite-wal file exists so far the DB session is opened but it's still on the iPad disk storage even the iOS app is force closed. This file keeps transactions that were previously committed to the DB.
Is it possible that the file keeps bad DB status and next app execution freezes at the first `SELECT' query?
Should iOS close DB session when app is force closed?