Read the Source, Luke

by John Samuel Anderson last modified Jan 15, 2009 09:34 PM
Read the source code to find the bug.

Back to Square 1

We originally saw this error while trying the command-line zeopack.py utility.  It is there that be begin our search.  Without boring you with a lot of source-code snippets, here's the basic order of execution:

  1. main() is called (Line 120)
  2. Based on the command-line switches, we can guess that pack2() is called (Line 116)
  3. a ClientStorage object is called to pack the database (Line 67)

Now, we need to find the ClientStorage object.  In line 33, we have:

from ZEO.ClientStorage import ClientStorage

Therefore, we know that there must be a ClientStorage.py somewhere on the filesystem.

Find and Grep are even better together

Linux users have a sweet combination at their fingertips. If you know part of the filename you want, you can try this trick:
$ find * | grep ClientStorage
The results:
lib/python/ZEO/ClientStorage.pyc
lib/python/ZEO/ClientStorage.py
This is even better than the locate command, because it only returns results below the current directory. The locate command searches the entire filesystem, possibly returning many irrelevant results.

 A Brief Dip into the ZEO Library

By this time, we are on a desperate search for the bug.  In lib/python/ZEO/ClientStorage.py, the trail goes as follows:

  • line 846 - pack() calls self._server.pack().
  • lines 541-543 have this comment about when self._server gets set:
        # If verify_cache() finishes the cache verification process,
        # it should set self._server.  If it goes through full cache
        # verification, then endVerify() should set self._server.

 Incidentally, this is recorded in "instance fg" and also in the server logs with these lines:

2009-01-12 14:32:46 INFO ZEO.ClientStorage (18262) Verifying cache
2009-01-12 14:32:46 INFO ZEO.ClientStorage (18262) endVerify finishing
2009-01-12 14:32:46 INFO ZEO.ClientStorage (18262) endVerify finished

 While this tells us what is happening, it's not terribly clear what type of object the server is.  Rather than do a lot more grepping, let's try another set_trace.