November 2011
Mon Tue Wed Thu Fri Sat Sun
« Jun   Dec »
 123456
78910111213
14151617181920
21222324252627
282930  

Month November 2011

My Code Isn’t Fat, It’s Just Robust

I’ve been working on implementing some infrastructure code for a client. We’re building robust partition swapping to make it easy to load data without disrupting user queries. We’re doing everything eles the right way, but partition swapping makes it really easy to correct a bad load of a past data.

The upside is that this code is really easy to write. There are enough examples, samples, and previous samples out there that a lot of the basics can be easily implemented. Even the complex parts of implementing the partition swapping are fairly trivial. The trick is making the code robust enough to handle almost any failure scenario.

Table partitioning is good to use in different ETL scenarios, but we never want it to fail. If it does fail, we want to make sure that we’re in a recoverable state. Likewise, this code needs to be automated and recover from any potential failures.

It turns out that the actual functionality is just a few lines of code. The robust error handling, logging, and recovery code is about 30 times longer than the functionality. It can be difficult to go through the code and update all of the error handling and logic in response to minor changes to business requirements, but the end product is a stable piece of functionality.

Taking out the Trash

If you’re like me, you probably don’t think a lot about what you throw into the trash on your computer – you just put files and folders in there to be deleted and, eventually, you empty the trash. The other day I dropped a 40GB virtual machine into the trash and then told OS X to empty the trash. A few hours later, it was still chugging away at pretending it was deleting the trash. There were no messages in Console about files being locked and unable to be cleaned up and no warnings of any other kind.

Being the resourceful individual that I am, I dropped into the terminal and ran sudo rm -rf .Trash/*. That process hung as well. I checked the console and all of the various logs again and there was nothing going on.

As a last resort before giving up and switching to the backup computer, I rebooted the Mac into single user mode (hold down Command-S during the boot sequence). Once I was in single user mode, OS X dropped me off at a command prompt as the root user. A few quick cds later and I was able to once again rm -rf .Trash/*. This time it worked like a charm.

I have no idea what happened and there were no logs to point me in the right direction. I can only assume that OS X got hung up trying to read the contents of the virtual hard disk which is, in reality, nothing more than a bundle of files, much like an OS X application. Maybe there was just too much junk…

This site is protected with Urban Giraffe's plugin 'HTML Purified' and Edward Z. Yang's Powered by HTML Purifier. 401 items have been purified.