perl client: thawing in eval { .. }

Brad Fitzpatrick brad@danga.com
Fri, 9 Apr 2004 13:33:33 -0700 (PDT)


The perl client in cvs now wraps the thawing of serialized object (from
Storable) in thaw, in case there's an error.

This came about because we were upgrading one of our mail machines to
Debian sarge.  I feared that upgrading it would pull in Perl 5.8 (I'm sure
there's enough cross-dependencies it would) and then when our mail
machines do procmail deliver to a perl script which uses our ljlib code,
which uses memcached, we'd end up with perl 5.8 Storable objects in our
memcached farm which perl 5.6 machines would later fetch and croak on.

But memcached clients should never die, so instead it's wrapped in eval
and if Perl 5.6 fetches a Perl 5.8 serialized object, it's just ignored
(if the eval dies) and it's like a cache miss.

For what it's worth, they fixed this stupid behavior in Perl 5.8 so the
Perl 5.8 to 5.10 transition won't have this problem:

$ perldoc Storable

...

files from future versions of Storable

 Earlier versions of Storable would immediately croak if
 they encountered a file with a higher internal version
 number than the reading Storable knew about.  Internal version
 numbers are increased each time new data types (such as restricted
 hashes) are added to the vocabulary of the file format.  This meant
 that a newer Storable module had no way of writing a file readable by
 an older Storable, even if the writer didn't store newer data types.

 This version of Storable will defer croaking until it encounters a
 data type in the file that it does not recognize.  This means that it
 will continue to read files generated by newer Storable modules which
 are careful in what they write out, making it easier to upgrade
 Storable modules in a mixed environment.

......