The Problem

by John Samuel Anderson last modified Jan 15, 2009 01:56 AM
An error occurred while attempting to pack the ZODB.

All I Wanted Was a Backup

We needed to backup our Data.fs nightly.  An easy way to do this without taking down the server is to pack the database, then backup the pre-packed "Data.fs.old."  One solution suggests using "wget" to run the "pack" command via HTTP.  A more up-to-date solution recommends running zeopack.py.  Here's a script that attempts to do the latter:

#!/bin/bash
# NOTE: You'll have to adjust the paths, of course.
# PORT comes from the buildout.cfg -- it's the zeo port number.
export PLONE=/var/Plone
export PORT=8100
export PYTHONPATH=$PLONE/parts/zope2/lib/python
$PLONE/parts/Python-2.4.5/bin/python $PLONE/parts/zope2/utilities/ZODBTools/zeopack.py -p $PORT -d 7

Bad Behavior and Bad Error Messages

After running about 10 minutes, the script failed with this message:

 Odd-length string

That's it. No more detail, just that.  What's worse, Google search revealed no useful information about this string.  Without any stack trace information, we're still in the dark.  (We'll turn on a light in a moment.)

Where is the Bug?

But first, let's ponder the source of the problem.  There are three possibilities:

  • Bad Data - Perhaps the data got mangled and needs to be corrected.  (This can happen, for example, when you migrate content improperly.)
  • Bad Configuration - Perhaps my Plone configuration and/or my operating system are not setup correctly.  ("Cannot adapt" is a huge signal that this is occurring.)
  • Bad Code - Though much less likely, it is possible that the source code has a bug.

As you read stack traces, log files, and other diagnostic information, be aware that most of the problems you will face are either bad data or bad configuration.  This insight has been very helpful to me.