In just a few days, I'll be off to PostgreSQL West. I've attended PostgreSQL East and PGCon both of the last two years, but this will be my first trip out to PG West. As with past conferences, this will be a good opportunity for me to catch up with people I normally speak with only via the Internet. But, there's something that's a little different about this one. Take a look at the agenda.
Thursday, October 28, 2010
Monday, October 25, 2010
WAL Reliability
I recently learned, somewhat to my chagrin, that operating systems are pathological liars, and in particular that they habitually lie about whether data has actually been written to disk. If you use any database product, you should care about this, because it can result in unfixable, and in some cases undetected, corruption of your database. First, a question. On which of the following operating systems do fsync() and related calls behave properly out of the box?
A. Linux
B. Windows
C. MacOS
A. Linux
B. Windows
C. MacOS
Thursday, October 14, 2010
Choosing a Datastore
In thinking about which database might be best for any particular job, it's easy to get lost in the PR. Advocates of traditional relational database systems like Oracle and PostgreSQL tend to focus on the fact that systems are feature-rich and provide features such as atomicity, consistency, isolation, and durability (ACID), while advocates of document databases (like MongoDB) and key-value stores (memcached, Dynamo, Riak, and many others) tend to focus on performance, horizontal scalability, and ease of configuration. This is obviously an apples-and-oranges comparison, and a good deal of misunderstanding and finger-pointing can result. Of course, the real situation is a bit more complicated: everyone really wants to have all of these features, and any trade-off between them is bound to be difficult.
Wednesday, October 06, 2010
Down To Six
From early July until the beginning of this week, the PostgreSQL project has been maintaining eight active branches: 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, and the master branch (9.1devel). As a result, a significant number of bug fixes and security updates had to be back-patched into all of those releases. At least for me, the recent switch to git has made back-patching, at least for simple cases, a whole lot simpler. But it's still a fair amount of work - some parts of the code have changed a good deal since 2003, when 7.4 was released.
Monday, October 04, 2010
SURGE Recap
Bruce Momjian and I spent Thursday and Friday of last week in Baltimore, attending Surge. It was a great conference. I think the best speakers were Bryan Cantrill of Joyent (@bcantrill), John Allspaw of Etsy (@allspaw), and Artur Bergman of Wikia (@crucially), but there were many other good talks as well. The theme of the conference was scalability, and a number of speakers discussed how they'd tackled scalability challenges. Most seem to have started out with an infrastructure based on MySQL or PostgreSQL and added other technologies around the core database to improve scalability, especially Lucene and memcached. But there were some interesting exceptions, such as a talk by Mike Malone wherein he described building a system to manage spatial data (along the lines of PostGIS) on top of Apache Cassandra.
Some general themes I took away from the conference:
Some general themes I took away from the conference:
Tuesday, September 28, 2010
Stupid Git Tricks for PostgreSQL
Even before PostgreSQL switched to git, we had a git mirror of our old CVS repository. So I suppose I could have hacked up these scripts any time. But I didn't get around to it until we really did the switch. Here's the first one. It's a one-liner. For some definition of "one line".
git log --format='%H' --shortstat `git merge-base REL9_0_STABLE master`..master | perl -ne 'chomp; if (/^[0-9a-f]/) { print $_, " "; } elsif (/files changed/) { s/^\s+//; my @a = split /\s+/; print $a[3] + $a[5], "\n" }' | sort -k2 -n -r | head | cut -d' ' -f1 | while read commit; do git log --shortstat -n 1 $commit | cat; echo ""; done
This will show you the ten "biggest" commits since the REL9_0_STABLE branch was created, according to number of lines of code touched. Of course, this isn't a great proxy for significance, as the output shows. Heavily abbreviated, largest first:
Of course, some of these are not-very-interesting commits that happen to touch a lot of lines of code, but a number of them represented significant refactoring work that can be expected to lead to good things down the line. In particular, latches are intended to reduce replication latency and eventually facilitate synchronous replication; and Tom's PARAM_EXEC refactoring is one step towards support for the SQL construct LATERAL().
OK, one more.
This one shows you the total number of lines of code committed to 9.1devel, summed up by committer. It has the same problem as the previous script, which is that it sometimes you change a lot of lines of code without actually doing anything terribly important. It has a further problem, too: it only takes into account the committer, rather other important roles, including reporter, authors, and reviewers. Unfortunately, that information can't easily be extracted from the commit logs in a structured way. I would like to see us address that defect in the future, but we're going to need something more clever than git's Author field. Most non-trivial patches, in the form in which they are eventually committed, are the work of more than one person; and, at least IMO, crediting only the main author (if there even is one) would be misleading and unfair in many cases.
I think the most interesting tidbit I learned from playing around with this stuff is that git merge-base can be used to find the branch point for a release. That's definitely handy.
git log --format='%H' --shortstat `git merge-base REL9_0_STABLE master`..master | perl -ne 'chomp; if (/^[0-9a-f]/) { print $_, " "; } elsif (/files changed/) { s/^\s+//; my @a = split /\s+/; print $a[3] + $a[5], "\n" }' | sort -k2 -n -r | head | cut -d' ' -f1 | while read commit; do git log --shortstat -n 1 $commit | cat; echo ""; done
This will show you the ten "biggest" commits since the REL9_0_STABLE branch was created, according to number of lines of code touched. Of course, this isn't a great proxy for significance, as the output shows. Heavily abbreviated, largest first:
66424a284879b Fix indentation of verbatim block elements (Peter Eisentraut)
9f2e211386931 Remove cvs keywords from all files (Magnus Hagander)
4d355a8336e0f Add a SECURITY LABEL command (Robert Haas)
c10575ff005c3 Rewrite comment code for better modular
ity, and add necessary locking (Robert Haas)
53e757689ce94 Make NestLoop plan nodes pass outer-relation variables into their inner relation using the general PARAM_EXEC executor parameter mechanism, rather than the ad-hoc kluge of passing the outer tuple down through ExecReScan (Tom Lane)
5194b9d04988a Spell and markup checking (Peter Eisentraut)
005e427a22e3b Make an editorial pass over the 9.0 release notes. (Tom Lane)
3186560f46b50 Replace doc references to install-win32 with install-windows (Robert Haas)
debcec7dc31a9 Include the backend ID in the relpath of temporary relations (Robert Haas)
2746e5f21d4dc Introduce latches. A latch is a boolean variable, with the capability to wait until it is set (Heikki Linnakangas)9f2e211386931 Remove cvs keywords from all files (Magnus Hagander)
4d355a8336e0f Add a SECURITY LABEL command (Robert Haas)
c10575ff005c3 Rewrite comment code for better modular
ity, and add necessary locking (Robert Haas)
53e757689ce94 Make NestLoop plan nodes pass outer-relation variables into their inner relation using the general PARAM_EXEC executor parameter mechanism, rather than the ad-hoc kluge of passing the outer tuple down through ExecReScan (Tom Lane)
5194b9d04988a Spell and markup checking (Peter Eisentraut)
005e427a22e3b Make an editorial pass over the 9.0 release notes. (Tom Lane)
3186560f46b50 Replace doc references to install-win32 with install-windows (Robert Haas)
debcec7dc31a9 Include the backend ID in the relpath of temporary relations (Robert Haas)
Of course, some of these are not-very-interesting commits that happen to touch a lot of lines of code, but a number of them represented significant refactoring work that can be expected to lead to good things down the line. In particular, latches are intended to reduce replication latency and eventually facilitate synchronous replication; and Tom's PARAM_EXEC refactoring is one step towards support for the SQL construct LATERAL().
OK, one more.
#!/bin/sh
BP=`git merge-base master REL9_0_STABLE`
git log --format='format:%an' $BP..master | sort -u |
while read author; do
echo "$author: \c"
git log --author="$author" --numstat $BP..master |
awk '/^[0-9]/ { P += $1; M += $2 }
/^commit/ { C++ }
END { print C " commits, " P " additions, " M " deletions, " (P+M) " total"}'
done
BP=`git merge-base master REL9_0_STABLE`
git log --format='format:%an' $BP..master | sort -u |
while read author; do
echo "$author: \c"
git log --author="$author" --numstat $BP..master |
awk '/^[0-9]/ { P += $1; M += $2 }
/^commit/ { C++ }
END { print C " commits, " P " additions, " M " deletions, " (P+M) " total"}'
done
This one shows you the total number of lines of code committed to 9.1devel, summed up by committer. It has the same problem as the previous script, which is that it sometimes you change a lot of lines of code without actually doing anything terribly important. It has a further problem, too: it only takes into account the committer, rather other important roles, including reporter, authors, and reviewers. Unfortunately, that information can't easily be extracted from the commit logs in a structured way. I would like to see us address that defect in the future, but we're going to need something more clever than git's Author field. Most non-trivial patches, in the form in which they are eventually committed, are the work of more than one person; and, at least IMO, crediting only the main author (if there even is one) would be misleading and unfair in many cases.
I think the most interesting tidbit I learned from playing around with this stuff is that git merge-base can be used to find the branch point for a release. That's definitely handy.
Friday, September 24, 2010
Enjoying Git
OK, I admit it. This is awesome. I'm still getting used to committing to PostgreSQL with git rather than CVS, but it's sort of like the feeling of being let out of the dungeon. Wow, sunlight, what am I supposed to do about that?
Actually, I've never really been into CVS bashing; it's an OK system for what it does. And compare to RCS, which I actually used once or twice a long time ago, it's positively phenomenal. But git, despite its imperfections, is just a lot better.
There are two major things that caused problems for me when committing to CVS. First, it was painfully slow. Second, since I was doing all of my development work on git, that meant extracting the patch, applying it to CVS, making sure to CVS add/rm any new/deleted files, retyping (or copying) the commit message, and double-checking that I hadn't messed anything up while moving the patch around.
Nice! I feel like someone gave me an easy button.
Actually, I've never really been into CVS bashing; it's an OK system for what it does. And compare to RCS, which I actually used once or twice a long time ago, it's positively phenomenal. But git, despite its imperfections, is just a lot better.
There are two major things that caused problems for me when committing to CVS. First, it was painfully slow. Second, since I was doing all of my development work on git, that meant extracting the patch, applying it to CVS, making sure to CVS add/rm any new/deleted files, retyping (or copying) the commit message, and double-checking that I hadn't messed anything up while moving the patch around.
$ git commit
$ git show
$ git push
Nice! I feel like someone gave me an easy button.
Subscribe to:
Posts (Atom)