yes, I did suggest it may be a software/hardware issue.
the relays are powered by 12v, arduino is isolated from the relay. relay control input use opto isolator.
I don't think it is an issue of under powered power supply (though I'm not ruling that out yet), but may be a spike or surge as you suggested. I can try delaying the sd write, say 2 seconds after the relay switches.
Tim, I like your logic, just because you do not see a problem, you conclude there is no problem. lol.
As fat16lib said, the overhead is minimal to add the SPI initialization code. It will take 2-3 clock cycles to do it (refer to AVR datasheet, SBR and CBR instructions take 1 clock cycle each). Don't get too hung up on code performance where it does not matter.
As to my source code, it is a very large project so I do not want to waste anyone's time perusing it. I will eventually put it in github as an open source project.