質問

I'm developing iOS application using CoreData.
And I have got application datas from user that includes following hidden files.

  • Documents/.appname.sqlite.migrationdestination_xxxx (549MB)
  • Documents/.appname.sqlite.migrationdestination_xxxx-shm (721KB)
  • Documents/.appname.sqlite.migrationdestination_xxxx-wal (0Byte)

And There are appname.sqlite, appname.sqlite-wal and appname.sqlite-shm in same Documents folder.
appname.sqlite is main sql file for app. and -wal, -shm seems to be generated automatically by iOS.
(I learned from What are the .db-shm and .db-wal extensions in Sqlite databases?)

I think migrationdestination file is just progress data for migration.
Maybe it remains when user's device failed to migrate. (e.g. iOS terminate my app when my app has been in background long-time.)

By the way, some users using my app have got this trouble.

Mar 10 13:33:24 xxxx-xx-iPhone XXXXXXXX[5416] : CoreData: error: (11) Fatal error. The database at /var/mobile/Applications/95D2823D-37E4-4596-9507-B58571D32EBB/Documents/appname.sqlite is corrupted. SQLite error code:11, 'database disk image is malformed'

And i found this tips.
Core Data store corruption

One of answer says -wal and -shm cause this error. so i removed it.
However, user still gets same error. So i think migrationdestination may cause this error.
I'll test it to remove tomorrow. Then i report the result it to here.

So Does anyone have same trouble, suggestions, answers?
Thank you for reading my issue.

役に立ちましたか?

解決

These are files that exist during a migration. If you are seeing these files then your migration failed. Check your crash logs on that device and confirm.

Are you migrating in the -applicationDidFinishLaunching... method? Are you getting a bad food crash? Those are common situations that will cause a migration to fail in the middle of the migration.

他のヒント

Finally, I found a solution for 'database disk image is malformed'.

I renamed these files

before

  • Documents/.appname.sqlite.migrationdestination_xxxx
  • Documents/.appname.sqlite.migrationdestination_xxxx-shm
  • Documents/.appname.sqlite.migrationdestination_xxxx-wal

after

  • Documents/appname.sqlite
  • Documents/appname.sqlite-shm
  • Documents/appname.sqlite-wal

I deleted old appname.sqlite, appname.sqlite-shm, appname.sqlite-wal files.

I guessed why this error happens.
Maybe user has succeeded migration.
So there are two sql files. appname.sqlite and .appname.sqlite.migrationdestination_xxxx.
Then iOS is going to exchange these files, but if app is killed by some reason, appname.sqlite remains in the middle of deleting.
but app look appname.sqlite every time, then iOS guess wrong it's corrupted, so my app can't run.

Now i'm going to make these exchange script and apply my app.
Thank you for listing my issue.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top