【问题标题】:symfony2 warning: sqlite3 profiler database is readonlysymfony2 警告:sqlite3 分析器数据库是只读的
【发布时间】:2012-03-30 21:40:15
【问题描述】:

我收到一个奇怪的警告,我无法使用 Symfony2 版本 v2.0.12 修复。这昨天工作得很好。我怀疑最近唯一相关的变化是我最近将 symfony2 本身(安装到 vendors/symfony)从 v2.0.5 升级到 v2.0.12。

Warning: SQLite3Stmt::execute(): Unable to execute statement: attempt to write a readonly database in /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php on line 66

Call Stack:
    0.0000     329108   1. {main}() /Symfony2/web/app_dev.php:0
    0.0015     720736   2. Symfony\Component\HttpKernel\Kernel->handle() /Symfony2/web/app_dev.php:10
    0.0102    1461700   3. Symfony\Bundle\FrameworkBundle\HttpKernel->handle() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Kernel.php:171
    0.0102    1462608   4. Symfony\Component\HttpKernel\HttpKernel->handle() /Symfony2/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php:47
    0.0102    1462608   5. Symfony\Component\HttpKernel\HttpKernel->handleRaw() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:71
    0.0594    4226612   6. Symfony\Component\HttpKernel\HttpKernel->filterResponse() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:139
    0.0595    4232664   7. Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher->dispatch() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:157
    0.0598    4245456   8. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() /Symfony2/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php:145
    0.0599    4246116   9. Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher->doDispatch() /Symfony2/vendor/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:49
    0.0609    4265376  10. call_user_func() /Symfony2/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php:82
    0.0609    4265404  11. Symfony\Component\HttpKernel\EventListener\ProfilerListener->onKernelResponse() /Symfony2/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventDispatcher.php:0
    0.0640    4470124  12. Symfony\Component\HttpKernel\Profiler\Profiler->saveProfile() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php:124
    0.0640    4470124  13. Symfony\Component\HttpKernel\Profiler\PdoProfilerStorage->write() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Profiler/Profiler.php:91
    0.0650    4516660  14. Symfony\Component\HttpKernel\Profiler\SqliteProfilerStorage->exec() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php:103
    0.0651    4563392  15. SQLite3Stmt->execute() /Symfony2/vendor/symfony/src/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php:66

app/logs/test.log 我看到类似的行

[2012-03-30 14:40:49] profiler.WARNING: Unable to store the profiler information. [] []

有什么想法吗?

我在调试器中单步调试了 SqliteProfilerStorage,得知有问题的 Sqlite3 数据库位于 app/cache/dev/profiler.db

$ ls -l app/cache/dev/profiler.db
-rw-r--r--+ 1 adam www-data  51200 2012-03-30 13:56 app/cache/dev/profiler.db

$ getfacl app/cache/test/profiler.db
# file: app/cache/test/profiler.db
# owner: www-data
# group: www-data
user::rw-
user:www-data:rwx       #effective:r--
user:adam:rwx           #effective:r--
group::rwx          #effective:r--
mask::r--
other::r--

我定期从命令行运行 phpunit 测试,并点击指向同一个 Symfony2 应用程序的 Apache2 VirtualHost。我认为 ACL 将允许这两者交替发生,但我对上面 ACL 中的effective:r-- 有点困惑。

我设置了权限according to the install doc。我这样做了:

$ mkdir app/{cache,logs}
$ chmod 775 app/{cache,logs}
$ sudo setfacl -R -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs
$ sudo setfacl -dR -m u:www-data:rwx -m u:`whoami`:rwx app/cache app/logs

再一次,这刚刚开始引起问题,所以我怀疑 Symfony2 升级。不过,我正在查看提交,但我还没有发现任何最近可能破坏了这一点的东西。

  • umask 对于我的用户 (adam) 和 www-data 返回 0002
  • 我使用的是 Ubuntu 11.10。
  • This thread covers a similar symptom,但建议的分辨率对我不起作用。 profiler.db 始终拥有权限 0644

【问题讨论】:

  • 我有同样的问题,但只想指出我在 2.0.9 和 2.0.12 上都遇到了这个问题
  • 如果您使用 acl 列表,则不需要 chmod。我想你已经尝试删除 cache 的内容并让 Symfony 从头开始​​重建它?
  • @gilden 是的,试过了。这很奇怪......几乎就像 ACL 不工作一样。不过,getfacl 似乎正在工作。 fs 是 ext4。

标签: ubuntu sqlite symfony


【解决方案1】:

可能只是因为您忘记递归地设置文件的 775 权限。

试试

chmod 775 -R app/{cache,logs}

【讨论】:

  • 嗯,那我必须经常这样做。在我开始看到这个问题之前,我一直在运行rm -rf app/{cache,logs}/*,当事情变得混乱时。
  • 已经有一段时间了,但我很确定这就是问题所在。原因可能是 Symfony2 框架创建了具有错误权限的 sqlite 数据库。
【解决方案2】:

你检查了父目录的权限吗?

我用这个解决了一个类似的问题:

chgrp www-data app app/symfony.db
chmod 775 app
chmod 664 app/symfony.db

【讨论】:

    猜你喜欢
    • 2019-02-12
    • 2017-07-17
    • 1970-01-01
    • 2013-05-25
    • 2019-04-11
    • 2017-09-27
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多