rc3.org

Strong opinions, weakly held

Month: March 2006 (page 3 of 3)

Being smart about database backups

The other day I mentioned a problem I created for myself using CocoaMySQL. There were a number of mishaps involved, but the end result was data loss. Basically what happened is that I unintentionally told CocoaMySQL to run an alter statement on a table in a production database which zeroed out all of the data in a particular column.

I was, in fact, just trying to look at the structure for a table and clicked in the wrong place. Then, poof, the data was gone. Of course, aside from the issue of how to get back as much data as possible, the question is how to prevent such data loss in the future. One problem is that the development and production databases live on the same server, and I generally accessed them with the same account. (Not root, but still an account with all privileges for both databases.) When I connected with CocoaMySQL, the production database was selected by default. This meant that I was putting myself in a position to mess up the production data even though there was no reason to assume this risk. I immediately created a new account with access only to staging, which makes mistakes that could destroy production data much less likely.

The second issue, though, is backups. There are three basic means by which you can back up a MySQL server that uses InnoDB tables. The options are offline data dump, hot backups, and replication. What I learned from this episode it’s best to apply several of these approaches at once.

The database in question was once backed up using the hot backup tool, which creates backup files that can be used to completely restore the database to the point before it was backed up. Then replication was set up, and the hot backups were turned off. In this case, the fact that replication was the only backup option we employed turned out to be costly. The alter command was replicated just like any other database operation and within seconds the data was deleted from both databases.

Even if I had a full backup from the hot backup tool, I would have had to fully restore the database to some server to get back the data from the one column I needed, which would have been painful. Both the replication and the hot backup tool are fine disaster recovery tools, but aren’t so useful in a case like this, where data is inadvertently destroyed. Given my recent experience, protecting against inadvertent data destruction is probably more important that insuring against natural disaster or hardware failure (although they’re important too).

I think that in the future, for MySQL, the solution I’m going to recommend is a replicated database that is taken offline regularly to be backed up using mysqldump, which yields ASCII files that are more accessible than the files the hot backup tool creates. The way replication works, the slave database will catch back up with the master database when it comes back online.

I would be curious to know what readers recommend for database backup practices.

Smarter random screen saver for the Mac

As a general rule, I prefer to have my computer randomly select a screen saver rather than using any one screen saver in particular. Unfortunately, some of the screen savers on my MacBook are really useless, because they use data that I don’t have on my computer (like iTunes album art). So what would be great is a screen saver that lets you select the set of screen savers from which to choose, rather than just using all of them. Anybody heard of such a thing?

The Oscars and why I love Jon Stewart

I always watch the Oscars, but of course I was especially interested to see last night’s show because I am a total Jon Stewart fanboy. Anyway, the show sucked, and I’m not sure whether Jon Stewart was at fault. Either he was the only redeemable bit, or he was a big part of the problem. Either way, it was awful. About halfway through I pledged to myself not to watch next year, because it was just that boring. I didn’t get the sense that the audience was eating up Stewart’s jokes, even the ones that I thought were pretty funny.

Anyway, in the time during the show when I wasn’t hoping for a meteor to put an end to my misery, I was thinking about what it is I like so much about The Daily Show in general and Jon Stewart in particular. The fact that he’s a liberal doesn’t hurt, but that’s not really it. The thing I admire about Stewart is his obsession with the truth (rather than truthiness). There are plenty of people out there who bill themselves as truth tellers, but who don’t really meet the definition. The obvious comparison here would be to the Bill O’Reillys and Rush Limbaughs of the world, people who claim to tell the truth but lie constantly. But that’s too easy.

Instead I want to compare Jon Stewart to Bill Maher. You’d think that Jon Stewart and Bill Maher would have a lot in common. They’re comedians who do topical talk shows with guests, bits, and monologues. They’re both situated at the leftward end of the political spectrum. But the similarities end there. Bill Maher is, I think, an honest guy who pretty much always gives his honest opinion. But his primary interest is not revealing the truth. He has points to make, and if a little embellishment or obfuscation help him make his points, then so be it. He’s sloppy with the truth because it matters to him less than his point of view.

Contrast that with Jon Stewart, who rarely ever discusses his point of view, even if he’s the one being interviewed. It’s not difficult to discern what he thinks from the topics he chooses to cover, but it’s nearly impossible for me to imagine him sitting there and telling us how we should get health care costs under control or what kind of relationship the United States should have with Saudi Arabia. Indeed, the Daily Show spends no time telling us to be outraged and instead simply exposes us to the outrageous. That, to me, is ultimately a more powerful way to communicate.

MacBook upgrade speedbumps

This morning I’ve discovered that a lot of the Unix-ish stuff on my MacBook is dead, due to problems with libraries that think they’re on the wrong architecture. For example, Quicksilver is crashing due to problems with Perl on the MacBook, and Darwinports won’t work for similar problems with TCL. Oh, the pain of being an early adopter. Once I’ve figured out how to solve the problem I’ll update this entry with what I did.

Darwinports: To get Darwinports to work, you have to reinstall from source. There’s no universal binary yet.

It’s worth noting that some Darwinports binaries work fine, I assume due to the magic of Rosetta. The problems come into play when scripts are tied to native code and have to specify a processor architecture. They’re set to mach-o rather than i386. I’m still trying to figure out how to get around that.

OK, now I’ve uninstalled Darwinports. Hopefully the default OS X Perl is in better shape. (… and it is. It seems to just work.)

After nuking Darwinports and updating the HTML::Parser module from CPAN, I have Quicksilver up and running again.

Overpowered

I’ve never been entirely happy with CocoaMySQL, and after a mishap last night our relationship is at an end. Like most database clients, CocoaMySQL enables you to run queries, browse tables, and view the structure of your database. It has its problems (like hanging and locking the database when I run custom queries that return a lot of data), but for the most part, they’re avoidable.

Last night, however, I found that it just puts too much power in the hands of its users to be safe for everyday use. When you’re viewing the structure of a table in CocoaMySQL, you can modify the schema as well as view it. In fact, it makes modifying the schema really easy. You can just click on the data type for a column and change it from, say, varchar(255) to tinyint. In fact, it’s rather easy to make such a change accidentally. Needless to say, doing something like that results in losing every bit of the data in that column. Any sane person writing a database tool would ask for confirmation before applying such a page, perhaps even two or three times, especially when a schema change will result in data loss. CocoaMySQL doesn’t.

Time to find another database client.

Cookin’ with gas

My MacBook Pro showed up today. I have the 2.0ghz model, and I am overwhelmed by the speed difference over my 17″ Powerbook G4. I haven’t run any benchmarks, but for everyday use, the speed difference is astounding. The key, of course, is to use Universal applications. Applications that run through Rosetta work, but they’re slow. I’d say that they’re somewhat slower than they were on the old Powerbook G4, but they are absurdly slow when compared to their Universal equivalents on the MacBook. The biggest difference is between Firefox (not Universal) and Camino (Universal). As some others have noted, when you’re using Camino, Gmail feels like a desktop application. The applications built into the OS open almost instantly, iTunes opens in a blink.

Other than the raw speed, I don’t have much else to say. Everything seems to just work, except for Eclipse, which has some native bindings that are broken on the MacBook. Oh, I should also note that the MagSafe connector is incredibly cool.

I also have to say a word about the migration utility built into Mac OS X. If you have never moved from one Mac to another, you don’t know the joy of booting up your old computer in Firewire hard drive mode and just letting the new one copy everything over. I honestly can’t imagine a more painless process.

Deal or No Deal

I happened to catch a new game show on TV last night called Deal or No Deal after seeing an incredibly long line of people queueing on the sidewalk for open auditions to be contestants on my way home from dinner. The show itself is incredibly boring, but the mechanics of the game are kind of interesting.

The game starts with 26 briefcases, each of which represents a dollar amount, running from one cent to one million dollars (or in the case of last night’s show, two million dollars). The game begins when the contestant picks one of the briefcases, which contains the amount of money they’re playing for. The contestant then chooses other briefcases to open, revealing amounts of money that they didn’t pick. Periodically the “banker” calls then and offers them money to stop playing, based on the amount of money still in play.

Once the person has picked their initial briefcase, they eliminate five or six other briefcases, then the first offer comes in. On last night’s show, contestants never eliminated the big dollar amounts in this first round, so with the person having a 1 in 20 chance (or maybe 1 in 19) of winning the big money, the bank offered something like $23,000 to buy them out. As they eliminated briefcases without revealing the top prize, the amount offered by the bank would go up. In one of the games, the person got to a point where there were four briefcases left and the two million dollar prize had not been revealed. They got a buyout offer of over $400,000, took it, and learned that their briefcase had $5 in it. Good choice.

What I haven’t figured out yet is whether the banker is trying to cheat people or whether the game is really just about tolerance of risk. In other words, are the offers fair given the amount of money left in play? If every offer is fair, then the only question is how much risk you’re willing to accept. Each time you open a briefcase, you chance removing a big amount of money from play and causing the banker to adjust your offer downward. On the other hand, removing a small amount will get you a higher offer. If some of the offers are unfair, then there’s math involved in determining whether or not to take the offer.

The game Web site doesn’t reveal how the offers are calculated, but the calculations I did in my head make it seem like the offers are fair, so the game is about a contestant’s willingness to gamble. (The odds are completely set, obviously.) I wonder how many of the players know that?

A new formula

Someone needs to come up with an algebraic formula that includes the number of posts in a weblog’s RSS feed, the number of days in a row that all of the old posts in it show up as new, and the amount of mental effort it takes to unsubscribe from the feed to calculate how long a feed can stay broken before users unsubscribe en masse. I wonder if other people are like me — I generally unsubscibe without letting the person know that there was even a problem.

This is also a good reason to subscribe to your own feeds. I sometimes even consider subscribing to my feeds with more than one tool just to be absolutely sure everything is going OK. These days I think that feed usability is even more important than the usability of the actual Web page where your weblog is published.

Newer posts

© 2024 rc3.org

Theme by Anders NorenUp ↑