Sqlite代码28“打开时重命名文件" [英] Sqlite code 28 "file renamed while open"

查看:157
本文介绍了Sqlite代码28“打开时重命名文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是此问题的推论.

我有一个Mac应用程序,该应用程序广泛使用sqlite.几个线程在sqlite代码中陷入僵局,而没有使用任何共享资源.我已经通过 sqlite_config_log .sqlite.org/c3ref/config.html"rel =" nofollow noreferrer> sqlite3_config 函数,并且此消息始终通过代码28发出:

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:

代码28 是SQLITE_WARNING.我发现似乎是记录该警告的源代码(在页面上搜索打开时重命名的文件"),似乎它应该给了我有问题的文件的路径,但这在log语句中没有通过.我什至在我的日志函数中设置了一个断点,并检查了文件重命名"字符串的内存,并且那里没有文件名.这不仅仅是因为错误的空字符而切断了日志.

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.

我也知道我实际上没有重命名文件.在创建文件后立即向我发出此警告.相同的代码在iOS应用程序(与sqlite版本3.7.13链接,而Mac为3.8.5)上运行,而不会生成警告.因此,问题是:除了重命名文件之外,还会导致此警告吗?

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?

更新:如果在对数据库运行任何语句之前将数据库转换为DELETE日记模式,则不会出现警告.

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

推荐答案

我可以通过捆绑将最新版本的SQLite 插入到我的项目中,而不是链接到dylib.这是sqlite中的某种错误,可能是由于以下事实引起的:由于我的应用程序如何管理文件,它会在磁盘上创建一个空文件,然后将其传递给sqlite以创建数据库文件(而不是将sqlite传递至一个空的位置).我当前正在运行3.8.8.2;我认为优胜美地捆绑的版本是3.7.同一版本的iOS 8出现了此问题,并在我的同伴iOS应用程序中引起了相同的问题.

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.

注意:如果将sqlite捆绑到Xcode项目中,请确保已定义HAVE_USLEEP,否则它会整秒钟等待锁.

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.

这篇关于Sqlite代码28“打开时重命名文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆