Just another Weblog

12/10/2007 - Ruby vs. The Enterprise

Since we have started using Ruby at work, development life has been off the chain. We've got a couple Rails apps that no doubt would have taken at least twice as long to do in Java or .NET. We also have some sweet PDF print drivers that we created using Ruby versus buying ridiculously licensed 3rd party drivers. We have approached the time that we knew would come, gasp, "enterprise integration."

Everywhere I've worked, whenever I start hearing talk about enterprise systems, it's a bunch of rogue systems glued together that seem to work using some supernatural phenomenon. Fair enough, it gets the job done, for now. Going against conventional wisdom, we want to take a different approach. We want to actually model out the entire business in a single code base. No rogue systems, just happy code working, just like the company. Call it being naive, but I feel that Ruby is going to be a great ally in this task. I understand that a language is just a language and nothing more, but Java has been bred to create bloated, frankensteined out, piecemealed enterprise systems. And the Microsoft shops I've worked at have not been very successful. I believe a company I used to work at has been in design mode for over a year trying to create their new enterprise system. A guy I used to work with, has had success in creating a true single code-base enterprise system, so I know it can be done. I plan to write about our adventures, especially because we are in somewhat uncharted waters using Ruby as a tool to help run a company.

10/24/2007 - A solution to Rails and Postgres connection issues

At work, after battling some issues with connections to MySql from a Rails app locking up, we decided to check out Postgres. I mean, if you hop on IRC, and you even mention Postgres, you're going to get nailed with "Postgres is awesome!!!" So after our venture of setting it up, it was time to roll. Everything was cool until the next day we came in and we were getting the following error message from Postgres: "server closed the connection unexpectedly. This probably means the server terminated abnormally before or while processing the request." After digging and debugging, we learned that the Postgres adapter that comes with Rails does not have reconnect logic if an existing idle connection has been dropped. If your Rails app is on a different server than your Postgres server, Postgres will drop idle connections, and ActiveRecord won't try to reconnect because it doesn't know the connection is stale. You may also get errors when resetting Postgres, because once again, the Rails adapter won't attempt a reconnect. The hack that we ended up putting in was to attempt a reconnect if there was an exception during the execution of SQL statement. The code that needs patched is located in the gem installation of ActiveRecord (activerecord-1.#.##.#/lib/active_record/connection_adapters/postgresql_adapter.rb). Find the method "execute", and you will see that it does not contain the same exception handling as the below snippet. I believe this bug is reported, and hopefully will be fixed in a later release.

def execute(sql, name = nil) #:nodoc:
  log(sql, name) do
    if @async
      @connection.async_exec(sql)
    else
      begin
        @connection.exec(sql)  #try to execute sql statement
      rescue Exception => e
        reconnect!             #try to reconnect if there was an error
        @connection.exec(sql)  #execute the same sql statement
    end
   end
 end

10/23/2007 - Alice in Chains acoustic show in Kansas City

I have to say, as big of a Tool fan as I am, I think the Alice in Chains acoustic show that I went to this past Sunday may have been the best show I've ever seen. They picked a few dates they had off during their current tour to play acoustic sets. The band consisted of the original members with the exception of their new front-man William DuVall. They basically played the same set that was on their Unplugged album, plus a few goodies like "Love, Hate, Love", "Don't Follow", and "I Can't Remember." Let me just say I hope, and have heard that they will write new material with William DuVall. If people can just accept that Layne Staley is gone, I think these guys will give us some more awesome music. DuVall is a talented guy, and great fit for the band. Most importantly, they all seemed very happy to be playing together.