3

This is a corollary to this question.

I've got a Mac app that uses sqlite pretty extensively. Several threads are deadlocking in sqlite code without using any shared resources. I've set up sqlite_config_log via the sqlite3_config function, and I keep getting this message with code 28:

file renamed while open:

Code 28 is SQLITE_WARNING. I found what appears to be the source code that logs that warning (search the page for "file renamed while open"), and it seems like it should be giving me the path to the offending file, but that doesn't come through in the log statement. I've even put a breakpoint in my log function and inspected the memory of the "file renamed" string, and there is no filename there; it's not just cutting off the log because of an errant null character.

I also know that I'm not actually renaming the file. It's giving me this warning right after the file is created. And the same code runs in an iOS app (which is linked against sqlite version 3.7.13, while the Mac is at 3.8.5) without generating the warning. So, the question: what could cause this warning besides renaming the file?

Update: The warning does not appear if the database is converted to DELETE journal mode before having any statements run against it.

Community
  • 1
  • 1
Tom Hamming
  • 10,577
  • 11
  • 71
  • 145

1 Answers1

2

I was able to fix this by bundling the latest version of SQLite into my project as source instead of linking against the dylib. It was some kind of bug in sqlite, likely caused by the fact that because of how my app manages files, it creates an empty file on disk and then passes it to sqlite to create a database file (as opposed to passing sqlite a path to an empty location). I'm currently running 3.8.8.2; the version that was bundled with Yosemite was 3.7.something, I think. The same version comes in iOS 8 and caused the same issue in my companion iOS app.

Note: If you bundle sqlite into an Xcode project, make sure HAVE_USLEEP is defined or else it'll sleep whole seconds waiting for locks.

Tom Hamming
  • 10,577
  • 11
  • 71
  • 145