新手问题 SQLite 经常说 database is locked

LinuxGit · December 12, 2012 · Last by LinuxGit replied at December 12, 2012 · 8623 hits
ActiveRecord::StatementInvalid in RelationshipsController#create

SQLite3::BusyException: database is locked: commit transaction

正在看 railstutorial 的教程,Follow 时老是出现上面的报错,有时过一段时间又好了,搜了下增加了 database.yml 中 timeout 也不行。还有说 switch to another database that supports multiple connections like MySQL or PgSQL. 想知道大家是怎么设置的。

pool 参数的关系?

#2 楼 @dotnil

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

这个我没改过,默认是5。

你是不是起了一个 Rails console?

redis 比 sqlite 牛

#4 楼 @woody1983 好像启了,😊这个是不是有影响?

并发连接太多了

#7 楼 @daqing 应该没有其他连接啊,测试可以通过,我自己在浏览器点击 Follow 就跳出这个错误。是不是楼上说的开了 rails c 的原因。

#8 楼 @LinuxGit 你应该是启了两个 一个没有 commit 掉 猜的。因为我遇到过一次类似的情况

都关掉,重新启动 rails s。

pool 去掉,timeout 再改长一点呢?比如 10 秒(10000)

#11 楼 @dotnil 改成 10000 试过一次不行,也重启 rails s 了。如楼上说的,我的 rails c 好像是开了一个。 之后不知怎么的行了。

ActiveRecord::Base.connection.execute("BEGIN TRANSACTION; END;")

Rails c 里面运行这个试试?

#13 楼 @ericguo 多谢,下次再遇到试试。

You need to Sign in before reply, if you don't have an account, please Sign up first.