Thursday 9 April 2009

More 2.3.2 Upgrade issues

Lots of ActiveRecord::StaleObjectError errors

Ok took some time clearing these. The basic problem was with large complex trees of objects resulting in multiple paths destroying the same objects. For example a 3 level process <-- context <-- parameters. As a handy shortcut process has a collection of parameters and contexts. The delete was cascading down via both process->context->parameter and process->parameter. This resulted in a attempt to delete a record twice.

Methods of fixing these problems:-
  • look carefully and change see if :delete_all raw delete can be used for dependent records.
  • look a collection and see if :destroy options can be removed
  • monkey patch to activerecord/lib/active_record/locking/optimistic.rb line 126 so only errors if real problem with stale record, allow duplicate deletes.
My little patch of Active Record to the last few problems as the following:-

unless affected_rows == 1
raise ActiveRecord::StaleObjectError, "Attempted to delete a stale object"
end


Changed to add test for already delete record and say which object actually had the problem :-

if affected_rows != 1 and self.class.exists?(self.id)
raise ActiveRecord::StaleObjectError, "Attempted to delete a stale object #{self.class}[#{self.id}]"
end

Wednesday 1 April 2009

Rails 2.0 -> 2.3.2 Upgrade

General the upgrade was not a major problems most of the application work. Have about 25 or 2500 tests failing, mainly with stale record on delete for lots of controller and unit tests of destroying object. The main issues where as follows:-

Cleanup

Had a few problems with plugins causing problems after update of rails:-
  • plugin/engines needed to be deleted,now part of rails
  • plugin/arts needed to be deleted
Also had a few renames of Dependencies.load_paths to ActiveSupport::Dependencies.load_paths from the 2.1+ days to sort out

Testing
This caused a number of problem due to widespread use of the Test::Unit::TestCase in the code. These had to be changed a number of large search and replaces in the test tree.
  • unit tests replace Test::Unit::TestCase with ActiveSupport::TestCase
  • function tests Test::Unit::TestCase with ActiveController::TestCase
Database Migrations
Needed a little hack to move development database to rails 2.3.2. Needed to fill the schema_migrations with old style version numbers as follows:-
1.upto(391){|i|DataConcept.connection.execute "insert into schema_migrations (version) values(#{i})"}
Todo List
  • Need to work on destroy test failures, to see if bad code or test under 2.3.2
  • gloc plugin does support new internationalization API will have to be changed
  • Need to test modified action web services plugin with 2.3.2
  • Need to check with ruby 1.9.1

Starting on Biorails 4.0

Boy been a busy year of delivery and going into production on a number of sites. Have not had time to write for ages. Now starting the majors upgrades to Biorails 4.0 cycle. Currently looking and ruby 1.9.1 and rails 2.3.2 updates.

First three rails things todo are:-

1) Update to Rails 2.3
2) Update Action Web services to work
3) Update Oracle drivers to support bulk inserts
4) Check gems on ruby 1.9.1

On the application side

1) Redo the unstructured data management. Time to make the product a better authoring tools
2) Support a lot better printable output in Open Office,word and PDF formats
3) Enhance the recipes to allow creation of a multiple level tree of items from a recipe
4) Time for UI make over again