BackgrounDRB and Sqlite3 / Autotest / Memory_test_fix Issues

Hello all.

I am using BackgrounDRB with "great happiness and joy", however, I am running into one problem in that when I am running my tests with autotest using Sqlite3 3.3.17 I am getting "ActiveRecord::StatementInvalid" exception inside of the sqlite_adapter.rb:360 which is checking for an empty structure.

I thought it might be the version of Sqlite, so I upgraded to 3.3.17 (just did a download, configure, make, make install and then saved the old binary and linked back to the newly installed version. Calling sqlite3 -version from the shell returns 3.3.17 (Running MacOSX 10.4.9)

Tracing the stack back gets me to line 18 of my code which is doing:

@object = Object.find_by_id(object_id)

And the next item in the stack trace is calling method_missing in ActiveRecord:Base. It seems like the Object table is not being loaded in at the start of the tests... or at least not getting loaded into to the same environment that BackgrounDRB is running in. I am using autotest with memory_test_fix.

The same code runs error free in MySQL (passes tests and runs properly in the app).

The Unit Test that raises the error is including the fixtures for the object being "finded".

Has anyone else run into this problem?

It's a bummer as to test BackgrounDRB section of the code, I need to swap out to MySQL (as I use Sqlite3 for the speed on tests).

From what I can see the solution would be somehow linking BackgrounDRB

back into the same DB that Autotest is tearing down and setting back up.

Not sure where to start on this.

Stack trace follows. Thanks!

Regards

Mikel

ActiveRecord::StatementInvalid - (ActiveRecord::StatementInvalid) /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/sqlite_adapter.rb:360:in `table_structure' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/core_ext/object/misc.rb:23:in `returning' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/sqlite_adapter.rb:359:in `table_structure' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/sqlite_adapter.rb:210:in `columns' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:763:in `columns' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:776:in `column_names' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:789:in `column_methods_hash' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1262:in `all_attributes_exists?' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/inflector.rb:250:in `all?' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1262:in `each' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1262:in `all?' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1262:in `all_attributes_exists?' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1196:in `method_missing' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../lib/workers/book_import_worker.rb:18:in `do_work' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb_rails.rb:36:in `start_process' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb_rails.rb:32:in `initialize' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb_rails.rb:32:in `new' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb_rails.rb:32:in `start_process' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb.rb:57:in `new_worker' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb.rb:49:in `synchronize' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/../../config/../vendor/plugins/backgroundrb/ backgroundrb.rb:49:in `new_worker' /usr/local/lib/ruby/1.8/drb/drb.rb:1555:in `__send__' /usr/local/lib/ruby/1.8/drb/drb.rb:1555:in `perform_without_block' /usr/local/lib/ruby/1.8/drb/drb.rb:1515:in `perform' /usr/local/lib/ruby/1.8/drb/drb.rb:1589:in `main_loop' /usr/local/lib/ruby/1.8/drb/drb.rb:1585:in `loop' /usr/local/lib/ruby/1.8/drb/drb.rb:1585:in `main_loop' /usr/local/lib/ruby/1.8/drb/drb.rb:1581:in `start' /usr/local/lib/ruby/1.8/drb/drb.rb:1581:in `main_loop' /usr/local/lib/ruby/1.8/drb/drb.rb:1430:in `run' /usr/local/lib/ruby/1.8/drb/drb.rb:1427:in `start' /usr/local/lib/ruby/1.8/drb/drb.rb:1427:in `run' /usr/local/lib/ruby/1.8/drb/drb.rb:1347:in `initialize' /usr/local/lib/ruby/1.8/drb/drb.rb:1627:in `new' /usr/local/lib/ruby/1.8/drb/drb.rb:1627:in `start_service' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/start:98 /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/start:94:in `fork' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/start:94 /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/start:86:in `fork' /Users/mikel/working/translation-system/trunk/config/../script/ backgroundrb/start:86

I should also say that the sqlite3 setup works fine on the other 100+ tests :slight_smile: It is only playing up when BackgrounDRB tries to access it. So the config is correct.

Another gotcha that i think I have already handled is that as BackgrounDRB forks into a new thread, the test can complete before BackgrounDRB completes. To handle this I have my test sleep for a few seconds (enough for the background task to handle what it has to handle). This means that the test database stays in memory while the test is sleeping so I thought that would handle it, but it seems not.

Anyway, just extra data.

Also have resinstalled sqlit3-ruby gem.

Mikel