It’s Monday, and a blizzard in the Lake Tahoe area has stranded several of our developer. No interesting things for standup today.
Hoping to improve performance, we changed a query to use the :include condition like this:
Project.find(id, :include => :stories)
and we noticed two things:
- ActiveRecord decided to turn that into a LEFT OUTER JOIN. Egads! This drastically slowed things down (although we didn’t notice until several days later, when we ran a real load test with production data).
- acts_as_paranoid did not manage to stick it’s little “and deleted_at = nil” phrase into the query. This meant that “deleted” stories showed up when they weren’t supposed to.
So that’s two gotchas for the price of one.
In email, Nick pointed out that the joining behavior is documented and appropriate (”otherwise if there is a nil association (eg a project without any stories) you wouldn’t get a project back even though it exists!”) and Miho rejoined that AR can be dangerous because it changes what looks like beautiful, elegant Ruby into nasty, ugly, hard-to-understand SQL under the hood.
Only project updates today.
- After the appable_plugins folks applied some of our patches, we upgrade. Thanks guys!
- Beer suggestions welcome for the retrospective tomorrow!
- One of our guys presented at the East Bay Ruby Meetup. Subject: Pivotal Labs’ Capistrano extensions. Of note: when he asked the group of 45 Ruby enthusiasts who among them knew much about Agile Software Development and continuous integration, only 4-5 people raised their hands. Disappointing.
- We might present at the O’Reilly Web 2.0 Expo in San Francisco this April (topic TBD). We’ll post the details here if it works out.
Ask for Help
- Is something goofy happening with Rail 1.2 REGEX pattern matching? One group is having problems after the upgrade.
UPDATE: Not really. It was a case where Rails 1.2 caught the bug that Rails 1.1 did not.
Total Stand-up Meeting Time: 10:00 minutes
- If you are using named parameters, watch out! A routes-named-parameters bug bit us. It’s fixed in Edge Rails but not in a released version of Rails.
- … And as a public service announcement, Rails’ routing was rewritten for version 1.2. If you are experiencing weird routing behavior, check the bug list.
- False alarm! The REGEX bug we mentioned the the last standup meeting… our fault.
- Let’s say you have the desperate need to generate a drop-shadow for an image, or any other sort of shadow (haven’t we all?). Check out Rmagick’s Image::shadow() method, which can do it for you. Very cool stuff!
svn:externalsproblems. I won’t get into the gory details, but if are changing or removing a
svn:externalsproperty on a directory, your best bet is to delete that portion of the directory tree and get a fresh version from SVN. You’ll avoid most problems.
- One project is using the Rails Simple Captcha plugin with success, and even has a successful Selenium testing strategy.
- Watch out for this appable_plugins bug ActiveRecord models in your plugin do not reload when your environment sets
config.cache_classes = true. End result: you might get “method missing” errors in your application for methods that the plugin’s model declares. Ouch. Details available upon request.
Ask for Help
- Doh! Somehow we broke
ruby script/generate migration MyMigration. I suppose we should fix that.
Total Stand-up Meeting Time: 20:00 minutes
We’ve been talking to the appable_plugins folks and they have been very receptive to addressing the issues and bugs we’ve found; they’ve even applied several patches we’ve submitted. Details:
Ask for Help
- 4 of our developers are trapped in Flagstaff, AZ! Can anyone give them a ride, perhaps in a short bus?
Total Stand-up Meeting Time: 13:00 minutes
A shorty today.
- A massive group of developers is revisiting and debating the current state of our shared-code architecture. appable_plugins might not be a perfect match, and we might develop our own or plugin-sharing system.
Total Stand-up Meeting Time: 12:00 minutes
Never be afraid to refactor. It may seem scary right now, but it will only become more daunting as the code base increases in size.
The right time to refactor is NOW… grasshopper
And now that my pair and I have rallied around this post, to the refactoring!
- Subversion Tip: We were reminded of a handy tip: when saving shell scripts in subversion, you can save them as both executable and also in a ‘native’ end-of-line style, which will run on any platform.
<code> $> svn propset svn:executable ON somescript.sh $> svn propset svn:eol-style native somescript.sh </code>
- Another handy plugin we’ve used many times: QueryTrace. It helps you find slow database queries, but it really floods your logs with data, so make sure to turn it off in production!
- We’re using appable_plugins for several projects but having problems with dependencies between the plugins, especially in fixtures. This might be caused by our fancy-dancy fixture loading extensions.
Ask for Help
ruby -r profile, and our own custom ruby test benchmarker, amongst others.
- One project is seeing a very strange memory leak that causes 100MB of memory loss per second (guh! guh!). It started when they begin using
ActiveRecord.connection.execute("some sql")to build some reporting statistics, but it seems too early to blame that. Coincidental, though.
Brown Bag Lunch Topic: Rails 1.2 features, ideas, and gotchas.
Total Stand-up Meeting Time: 25:00 minutes
- We’ll be sending 6 people to RailsConf, so say ‘hi’ if you see the Pivots!
- We have a fix to our Amazon S3-causing-mongrel-to-hang problem: you can tell the connection not to be persistent by passing in
:persistent => false:
<code> AWS::S3::Base.establish_connection!( :access_key_id => access_key, :secret_access_key => access_key, :persistent => false ) </code>
Ask for Help
- From the community: the JRuby team is putting out a cry for help for everyone to get JRuby running Rails 100%.
Total Stand-up Meeting Time: 14:00 minutes
Not much of interest today beyond project updates.
Total Stand-up Meeting Time: 17:00
- Jetbrains has released their official Ruby and Ruby on Rails plugin for IntelliJ IDEA. Many of us have been using this and it has some nice features: structure view, code completion, open class/symbol, and other Java-IDE style features. Now if they only had a fast debugger… oh sweet, sweet debuggers…
Ask for Help
- RMagick: One project is having new RMagick problems. Some image uploading and transformations are hanging the Mongrel process. Some are suggesting explicitly calling
GC.startafter heavy RMagick use. We’ll also check the version and insure that it’s 1.13.
Follow-up: Actually it looks like we were hanging connecting to Amazon’s S3 service.. Once we figure out the details we’ll let you know what the problem was.
Total Stand-up Meeting Time: About 19 minutes.
Ever do “
less log/development.log” and see the following?
ESC[4;35;1mSQL (0.001084)ESC[0m ESC[0mSET character_set_results = utf8;ESC[0m
ESC[4;36;1mSQL (0.001792)ESC[0m ESC[0;1mSHOW TABLESESC[0m
Wouldn’t it be nicer to see the colorization like when you’re tailing the log with
tail -f? Try using -R:
less -R log/development.log
Then you’ll see
SQL (0.001084) SET character_set_results = utf8;
SQL (0.001792) SHOW TABLES
A bit more legible, eh wot old chaps?
Works on Mac and Cygwin too.
And -X makes it not clear the screen when you stop less, so you get to keep seeing what you were just seeing.
So that means you may want to put
alias less="less -RX"
Also, if you don’t want the fancy colors at all, specify
ActiveRecord::Base.colorize_logging = false
in your environment file (e.g.
test.rb.) We’re doing that in our
test.rb so we can more clearly read the output from our CruiseControl build.