SQLite3 :: SQLException:无法提交 - 没有事务处于活动状态

时间:2012-05-08 12:27:22

标签: ruby-on-rails activerecord sqlite delayed-job

我正在尝试使用黄瓜测试DelayedJob发送的电子邮件。该功能实际上可以在浏览器中工作(在开发和生产环境中)但是当我尝试测试它时,我遇到了一个奇怪的SQlite3异常。

测试日志位于底部。如您所见,在将电子邮件发送作业插入队列后,它仅在SQLite3::SQLException时失败。

根据Delayed :: Job,失败的原因是:

Delayed::DeserializationError
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/psych_ext.rb:108:in `rescue in visit_Psych_Nodes_Mapping_with_class'

任何人都知道这里发生了什么?

我发现了一个相关的问题,但那里的问题似乎并没有受到测试环境的限制。因此,我认为解决方案不会相同。

  1. SQLite3 Error - cannot rollback - no transaction is active
  2. 以下是完整的测试记录:

      SQL (82.7ms)  INSERT INTO "delayed_jobs" ("attempts", "created_at", "failed_at", "handler", "last_error", "locked_at", "locked_by", "priority", "queue", "run_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["attempts", 0], ["created_at", Tue, 08 May 2012 12:14:15 UTC +00:00], ["failed_at", nil], ["handler", "--- !ruby/object:Delayed::PerformableMailer\nobject: !ruby/class 'InvitationMailer'\nmethod_name: :invite\nargs:\n- !ruby/ActiveRecord:Invitation\n  attributes:\n    id: 1\n    sender_id: 1\n    search_id: 1\n    token: 4cba1a8a36de826493b1d8a8cc21091e2fb393e1\n    sent_at: \n    recipient_email: peter@example.com\n    created_at: 2012-05-08 12:14:15.702071000 Z\n    updated_at: 2012-05-08 12:14:15.702071000 Z\n    recipient_id: \n    accepted: \n"], ["last_error", nil], ["locked_at", nil], ["locked_by", nil], ["priority", 0], ["queue", nil], ["run_at", Tue, 08 May 2012 12:14:15 UTC +00:00], ["updated_at", Tue, 08 May 2012 12:14:15 UTC +00:00]]
       (0.9ms)  commit transaction
    SQLite3::SQLException: cannot commit - no transaction is active: commit transaction
       (0.5ms)  rollback transaction
    SQLite3::SQLException: cannot rollback - no transaction is active: rollback transaction
    Completed 500 Internal Server Error in 126ms
      SQL (1.9ms)  UPDATE "delayed_jobs" SET locked_at = '2012-05-08 12:14:16.993126', locked_by = 'host:dtmbp.local pid:14059' WHERE (id = 3 and (locked_at is null or locked_at < '2012-05-08 08:14:16.993126') and (run_at <= '2012-05-08 12:14:16.993126'))
      Invitation Load (0.2ms)  SELECT "invitations".* FROM "invitations" WHERE "invitations"."id" = ? LIMIT 1  [["id", 1]]
      Invitation Load (0.1ms)  SELECT "invitations".* FROM "invitations" WHERE "invitations"."id" = ? LIMIT 1  [["id", 1]]
      Invitation Load (0.1ms)  SELECT "invitations".* FROM "invitations" WHERE "invitations"."id" = ? LIMIT 1  [["id", 1]]
      Invitation Load (0.1ms)  SELECT "invitations".* FROM "invitations" WHERE "invitations"."id" = ? LIMIT 1  [["id", 1]]
      Invitation Load (0.1ms)  SELECT "invitations".* FROM "invitations" WHERE "invitations"."id" = ? LIMIT 1  [["id", 1]]
       (0.1ms)  begin transaction
       (0.5ms)  UPDATE "delayed_jobs" SET "locked_at" = '2012-05-08 12:14:16.993126', "locked_by" = 'host:dtmbp.local pid:14059', "last_error" = '{Delayed::DeserializationError
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/psych_ext.rb:108:in `rescue in visit_Psych_Nodes_Mapping_with_class''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/psych_ext.rb:101:in `visit_Psych_Nodes_Mapping_with_class''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:20:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:134:in `block in visit_Psych_Nodes_Sequence''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:134:in `each''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:134:in `visit_Psych_Nodes_Sequence''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:20:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:276:in `block in revive''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:276:in `map''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:276:in `revive''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:219:in `visit_Psych_Nodes_Mapping''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/psych_ext.rb:119:in `visit_Psych_Nodes_Mapping_with_class''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:20:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:231:in `visit_Psych_Nodes_Document''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:20:in `accept''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/node.rb:35:in `to_ruby''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:128:in `load''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/backend/base.rb:84:in `payload_object''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/backend/base.rb:94:in `block in invoke_job''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/backend/base.rb:91:in `invoke_job''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:178:in `block (2 levels) in run''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:68:in `timeout''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:178:in `block in run''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:177:in `run''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:234:in `block in reserve_and_run_one_job''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:234:in `reserve_and_run_one_job''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:162:in `block in work_off''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:161:in `times''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:161:in `work_off''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:133:in `block (4 levels) in start''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:132:in `block (3 levels) in start''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:129:in `block (2 levels) in start''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:128:in `loop''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:128:in `block in start''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/plugins/clear_locks.rb:7:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `block (2 levels) in add''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:60:in `block in initialize''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:78:in `block in add''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:65:in `execute''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/lifecycle.rb:38:in `run_callbacks''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/worker.rb:127:in `start''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/gems/delayed_job-3.0.2/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain''
    /Users/davidtuite/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `load''
    /Users/davidtuite/.rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `<main>''', "failed_at" = '2012-05-08 12:14:17.131476', "updated_at" = '2012-05-08 12:14:17.132975' WHERE "delayed_jobs"."id" = 3
       (1.5ms)  commit transaction
    

1 个答案:

答案 0 :(得分:0)

我刚刚遇到这个错误并意识到有问题的AR对象已经被删除了。也许这也是你的情况?

相关链接:psych_ext.rb#L101 breaks restoring of deleted serialized objects