Checking in changes prior to tagging of version 2.66.

Changelog diff is:

diff --git a/CHANGES b/CHANGES
index 64455f4..bd7e38a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,29 @@
+2013-01-06: Release version 2.66
+
+   * add a hook to cmd_updateclass (Daniel Frett <daniel.frett@ccci.org>)
+
+   * support updating the class to the default class which has an id of 0 (Daniel Frett <daniel.frett@ccci.org>)
+
+   * reaper: validate DB connection before reaping (Eric Wong <normalperson@yhbt.net>)
+     Fixes occasional crash in reaper process.
+
+   * improve handling of classes which change hash algorithm (Eric Wong <normalperson@yhbt.net>)
+
+   * fsck: skip non-existent FIDs properly (Eric Wong <normalperson@yhbt.net>)
+
+   * fsck: use replicate lock when fixing FID (Eric Wong <normalperson@yhbt.net>)
+
+   * query: allow "0" key on all commands which take keys (Eric Wong <normalperson@yhbt.net>)
+
+   * prevent reqid mismatches (and queryworker death) (Eric Wong <normalperson@yhbt.net>)
+     Fixes crash case with specific error types.
+
+   * fix use_dest_devs for rebalance (Pyry Hakulinen <pyry@automattic.com>)
+     Fixes "use_dest_devs" argument during rebalance.
+
+   * Fix "skip_devcount" during rebalance (Pyry Hakulinen <pyry@automattic.com>)
+     Now actually skips updating devcount column during rebalance.
+
 2012-08-13: Release version 2.65

    * Postgres advisory lock instead of table-based lock (Robin H. Johnson <robbat2@gentoo.org>)
Reseed the random number generator after forking.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Pull out device sorting into it's own method for overriding.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Do both sorts in one method, to save on shared initialisation.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
worker: set monitor_has_run flag at initialization

This way the queryworker will know it won't have to
wait again for the monitor to run.  This allows
users to (manually) set higher intervals in Monitor.pm
without noticing ill effects.
monitor: remove dead iostats code/comments

* set_observed_utilization() is a no-op, and can be
  safely removed.

* Looking up the device via factory does not incur DB hit
  since the factory changes of May 2011.

* Really avoids propagating invalid devids with correct ordering
  of the hash assignment.  This prevents an invalid devid from
  hitting even the {devutil}->{cur} hash which lasts the
  lifetime of the monitor process.
ProcManager: favor using recently-used queryworkers

As HTTP/1.1 servers tend to disconnect idle connections over
time, recently-used queryworkers are more likely to have
reusable HTTP connections.  This can reduce the number of open
HTTP sockets across the cluster during non-peak periods.

This may improve performance in two ways:

* recently-used worker processes should have better memory locality

* can avoid the chance for TCP slow-start-after-idle behavior
  to kick in for DB connections.

The downside of this patch is memory/CPU usage between workers
may appear lopsided and probably confuse users.  This change
should also make potential memory leaks more noticeable.
disable Nagle's algorithm for accepted clients

Normally, disabling Nagle's algorithm would have little effect
on typical MogileFS traffic:

   < read one request from client
   - process request in queryworker
   > write one response to client
   < read one request from client
   - process request in queryworker
   > write one response to client
   < read one request from client
   - process request in queryworker
   > write one response to client
   ...

However, in certain cases, clients may pipeline requests (and
sort responses on the client side).  This causes tracker traffic
to end up like this:

   < read multiple requests from client
   - process requests in parallel on multiple queryworkers
   > write one response to client
   > write one response to client
   > write one response to client
   ...

Since Nagle's algorithm waits for an ACK from each response the
server writes before sending the next response, it limits the
rate at which the client can receive responses.

Informal testing over loopback running the "file_info" command
on two batches of 1000 keys each (2000 keys total) consistently
reveals a small, ~20-60ms reduction (580-600ms -> 540-580ms) on
a somewhat active machine with four queryworkers (and four
cores).

Like SO_KEEPALIVE, TCP_NODELAY is inherited from the listener by
accepted sockets in every system I've checked, so there's no
additional overhead in userspace when accepting new clients.
sqlite: use immediate transactions to prevent busy errors

The default (deferred) transaction mode in SQLite delays
locking, potentially leading to "database is locked" errors on
concurrent access.  Immediate transactions lock the database
immediately, preventing unnecessary errors at the cost of
reduced concurrency.

I've still occasionally encountered a "database is locked"
or two on my SQLite deployment with many workers over the
months.

Tested on MySQL, Postgres, and DBD::SQLite 1.29 and 1.37.
This feature appeared in DBD::SQLite 1.30, but the extra
attribute for DBI->connect is harmless for drivers which
do not support this attribute.

ref: http://search.cpan.org/dist/DBD-SQLite/lib/DBD/SQLite.pm

Using the following instrumentation patch, I have not hit
busy/locked errors while putting my SQLite-based MogileFS
instance through heavy activity (fsck, uploads, deletes):

  --- a/lib/MogileFS/Store/SQLite.pm
  +++ b/lib/MogileFS/Store/SQLite.pm
  @@ -164,7 +164,12 @@ use constant SQLITE_LOCKED => 6; # A table in the database is locked
   sub was_deadlock_error {
       my $err = $_[0]->dbh->err or return 0;

  -    ($err == SQLITE_BUSY || $err == SQLITE_LOCKED);
  +    if ($err == SQLITE_BUSY || $err == SQLITE_LOCKED) {
  +       Mgd::log('info', "DB locked");
  +       1;
  +    } else {
  +       0;
  +    }
   }

   sub was_duplicate_error {