rails / solid_queue

Database-backed Active Job backend
MIT License
1.94k stars 127 forks source link

ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked #133

Closed anoobbava closed 9 months ago

anoobbava commented 10 months ago

I was trying to create a sample application with the solid_queue gem, and it seems like the single case failing when we use the perform_later.

Here is the attached repo for the same, https://github.com/anoobbava/solid_queue_sample I have received the error as below,

/home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:108:instep': database is locked (SQLite3::BusyException) from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:108:in block in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:107:inloop' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:107:in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:42:into_a' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:42:in block (2 levels) in internal_exec_query' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:1028:inblock in with_raw_connection' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/concurrency/null_lock.rb:9:in synchronize' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:1000:inwith_raw_connection' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:33:in block in internal_exec_query' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/notifications/instrumenter.rb:58:ininstrument' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:1143:in log' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:32:ininternal_exec_query' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:61:in exec_delete' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:208:indelete' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:25:in delete' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:624:in_delete_record' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:1198:in _delete_row' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:1194:indestroy_row' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/counter_cache.rb:197:in destroy_row' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/locking/optimistic.rb:125:indestroy_row' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:783:in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/callbacks.rb:423:inblock in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:110:in run_callbacks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:952:in_run_destroy_callbacks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/callbacks.rb:423:in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:305:inblock in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:365:in block in with_transaction_returning_status' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/transaction.rb:535:inblock in within_new_transaction' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/concurrency/null_lock.rb:9:in synchronize' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/transaction.rb:532:inwithin_new_transaction' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:344:in transaction' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:361:inwith_transaction_returning_status' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:305:in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:797:indestroy!' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/app/models/solid_queue/process.rb:23:in deregister' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/registrable.rb:33:inderegister' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:403:in block in make_lambda' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:274:inblock in simple' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:602:in block in invoke_after' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:602:ineach' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:602:in invoke_after' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:111:inrun_callbacks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/runnable.rb:52:in do_start_loop' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/runnable.rb:39:instart_loop' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/runnable.rb:13:in start' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:123:inblock in start_fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/fork_tracker.rb:20:in block in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/debug-1.9.1/lib/debug/session.rb:2460:inblock in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/debug-1.9.1/lib/debug/session.rb:2462:in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/debug-1.9.1/lib/debug/session.rb:2462:infork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/fork_tracker.rb:18:in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:122:instart_fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:72:in block in start_forks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:72:ineach' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:72:in start_forks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:45:insupervise' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:26:in start' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:14:instart' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/tasks.rb:4:in block (2 levels) in <main>' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:281:inblock in execute' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:281:in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:281:inexecute' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:219:in block in invoke_with_call_chain' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:199:insynchronize' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:199:in invoke_with_call_chain' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:188:ininvoke' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:182:in invoke_task' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:138:inblock (2 levels) in top_level' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:138:in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:138:inblock in top_level' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:147:in run_with_threads' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:132:intop_level' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:83:in block in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:208:instandard_exception_handling' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:80:in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/exe/rake:27:in<top (required)>' from /home/AnoobBava/.rbenv/versions/3.0.6/bin/rake:25:in load' from /home/AnoobBava/.rbenv/versions/3.0.6/bin/rake:25:in<top (required)>' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in load' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli/exec.rb:58:inkernel_load' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli/exec.rb:23:in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli.rb:479:inexec' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:ininvoke_command' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in dispatch' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli.rb:31:indispatch' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in start' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli.rb:25:instart' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/libexec/bundle:49:in block in <top (required)>' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/friendly_errors.rb:103:inwith_friendly_errors' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/libexec/bundle:37:in <top (required)>' from /home/AnoobBava/.rbenv/versions/3.0.6/bin/bundle:23:inload' from /home/AnoobBava/.rbenv/versions/3.0.6/bin/bundle:23:in <main>'

image

sreeram-venkitesh commented 10 months ago

Formatted version of the stacktrace given above:

/home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:108:in step': database is locked (SQLite3::BusyException)
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:108:in block in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:107:in loop'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/sqlite3-1.7.0-x86_64-linux/lib/sqlite3/statement.rb:107:in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:42:in to_a'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:42:in block (2 levels) in internal_exec_query' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:1028:in block in with_raw_connection'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/concurrency/null_lock.rb:9:in synchronize' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:1000:in with_raw_connection'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:33:in block in internal_exec_query' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/notifications/instrumenter.rb:58:in instrument'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:1143:in log' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:32:in internal_exec_query'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/sqlite3/database_statements.rb:61:in exec_delete' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:208:in delete'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:25:in delete' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:624:in _delete_record'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:1198:in _delete_row' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:1194:in destroy_row'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/counter_cache.rb:197:in destroy_row' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/locking/optimistic.rb:125:in destroy_row'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:783:in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/callbacks.rb:423:in block in destroy'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:110:in run_callbacks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:952:in _run_destroy_callbacks'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/callbacks.rb:423:in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:305:in block in destroy'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:365:in block in with_transaction_returning_status' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/transaction.rb:535:in block in within_new_transaction'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/concurrency/null_lock.rb:9:in synchronize' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/transaction.rb:532:in within_new_transaction'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:344:in transaction' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:361:in with_transaction_returning_status'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/transactions.rb:305:in destroy' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activerecord-7.1.3/lib/active_record/persistence.rb:797:in destroy!'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/app/models/solid_queue/process.rb:23:in deregister' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/registrable.rb:33:in deregister'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:403:in block in make_lambda' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:274:in block in simple'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:602:in block in invoke_after' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:602:in each'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:602:in invoke_after' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/callbacks.rb:111:in run_callbacks'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/runnable.rb:52:in do_start_loop' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/runnable.rb:39:in start_loop'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/processes/runnable.rb:13:in start' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:123:in block in start_fork'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/fork_tracker.rb:20:in block in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/debug-1.9.1/lib/debug/session.rb:2460:in block in fork'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/debug-1.9.1/lib/debug/session.rb:2462:in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/debug-1.9.1/lib/debug/session.rb:2462:in fork'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/activesupport-7.1.3/lib/active_support/fork_tracker.rb:18:in fork' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:122:in start_fork'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:72:in block in start_forks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:72:in each'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:72:in start_forks' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:45:in supervise'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:26:in start' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/supervisor.rb:14:in start'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/solid_queue-0.2.0/lib/solid_queue/tasks.rb:4:in block (2 levels) in <main>' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:281:in block in execute'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:281:in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:281:in execute'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:219:in block in invoke_with_call_chain' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:199:in synchronize'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:199:in invoke_with_call_chain' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/task.rb:188:in invoke'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:182:in invoke_task' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:138:in block (2 levels) in top_level'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:138:in each' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:138:in block in top_level'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:147:in run_with_threads' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:132:in top_level'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:83:in block in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:208:in standard_exception_handling'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/lib/rake/application.rb:80:in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/rake-13.1.0/exe/rake:27:in <top (required)>'
from /home/AnoobBava/.rbenv/versions/3.0.6/bin/rake:25:in load' from /home/AnoobBava/.rbenv/versions/3.0.6/bin/rake:25:in <top (required)>'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in load' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in kernel_load'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli/exec.rb:23:in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli.rb:479:in exec'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in run' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in dispatch' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli.rb:31:in dispatch'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in start' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/cli.rb:25:in start'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/libexec/bundle:49:in block in <top (required)>' from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/3.0.0/bundler/friendly_errors.rb:103:in with_friendly_errors'
from /home/AnoobBava/.rbenv/versions/3.0.6/lib/ruby/gems/3.0.0/gems/bundler-2.2.33/libexec/bundle:37:in <top (required)>' from /home/AnoobBava/.rbenv/versions/3.0.6/bin/bundle:23:in load'
from /home/AnoobBava/.rbenv/versions/3.0.6/bin/bundle:23:in <main>' 
rosa commented 9 months ago

Hey @sreeram-venkitesh, thanks for reporting this and sorry for the trouble! I haven't had time to look into it yet but will try to address soon 🤞

jvillarejo commented 9 months ago

Hi @rosa I'm having the same problem. database is locked

I'm building a new application and I'm using broadcasts_refreshes in order to morph de dom with Turbo 8. I'm using the same sqlite DB for ActiveRecord and for solid_queue, and I'm using redis for ActionCable.

The flow is like this:

The broadcast doesn't happen because the database is locked

If you can guide me I can try to debug more about the issue and try to fix it.

rosa commented 9 months ago

@sreeram-venkitesh, I'm trying to reproduce this with your sample app, but I can't. Here's what I'm doing. In one tab, I'm running solid_queue:start. In another tab, I have a Rails console open where I enqueue jobs via SolidQueueSampleJob.perform_later.

These are performed correctly for me, no errors:

bundle exec rake solid_queue:start
[SolidQueue] Starting Dispatcher(pid=57990, hostname=rosas-air.lan, metadata={:polling_interval=>1, :batch_size=>500})
[SolidQueue] Starting Worker(pid=57991, hostname=rosas-air.lan, metadata={:polling_interval=>0.1, :queues=>"*", :thread_pool_size=>5})
[SolidQueue] Claimed 1 jobs
[SolidQueue] Claimed 1 jobs
[SolidQueue] Claimed 1 jobs
[SolidQueue] Claimed 1 jobs
[SolidQueue] Claimed 1 jobs
[SolidQueue] Claimed 1 jobs

Could you give me more details of what you're doing besides running solid_queue:start when you get the error?

rosa commented 9 months ago

@jvillarejo,

The broadcast doesn't happen because the database is locked

Do you get this error in the app process or in the Solid Queue process?

jvillarejo commented 9 months ago

Do you get this error in the app process or in the Solid Queue process?

Hey @rosa ! Thanks for your reply.
I got it in both the app process and in the solid queue process.

rosa commented 9 months ago

Hmm... yeah. I think SQLite is a bit tricky when it comes to write to the same DB from multiple processes. What's your configured timeout in database.yml?

kidandcat commented 9 months ago

Same error for me, my configured timeout is: timeout: 5000

rosa commented 9 months ago

Thanks @kidandcat! Could you try increasing that to 10000 or even 20000?

kidandcat commented 9 months ago

I had an error in my job, so it had to timeout, but I've noticed that when the jobs where stuck, the main website was also stuck, probably waiting for the sqlite write lock to be free. After fixing my job issue, it works as expected.

PD: I'm not sure how complex would be this but, just for the SQLite case, it could be worth to have a separated database for Solid Queue, so the write lock do not affect the main Rails app and vice versa.

rosa commented 9 months ago

Ahh, that makes sense, thanks for letting us know!

PD: I'm not sure how complex would be this but, just for the SQLite case, it could be worth to have a separated database for Solid Queue, so the write lock do not affect the main Rails app and vice versa.

It's not complex at all; that's supported out of the box, via connects_to and would be my recommended way for SQLite, no doubt.

mhamza15 commented 7 months ago

Hi, this isn’t a solid_queue question exactly, but I’m wondering if anyone has any recommendations as I’m new to using SQLite in production. I’ve created a separate database for solid_queue jobs but I forgot to realize that some jobs still interact with the main application database, leading to these situations where there’s a multi-process contention. Is there a recommended way to having synchronized access to SQLite with multiple processes, or kind of funneling access through one process? I know concurrency isn’t SQLite’s strong suit 😅

Thanks in advance!

jvillarejo commented 7 months ago

I know this issue is closed. But this post about SQLite concurrency helped me a lot.

Maybe this can help you @mhamza15 https://fractaledmind.github.io/2024/04/15/sqlite-on-rails-the-how-and-why-of-optimal-performance/

mhamza15 commented 5 months ago

This was exactly what I needed, thanks a bunch!