On Wed, Sep 26, 2012 at 8:42 PM, Bill Moseley <mose...@hank.org> wrote: > On Wed, Sep 26, 2012 at 2:07 PM, Bill Moseley <mose...@hank.org> wrote: > >> >> Need some ideas how to proceed here: >> >> Perhaps the way to proceed is to turn off the check_version and accept > that I need to be responsible for tracking version incompatibilities. > > I wasn't aware of these checks so not sure what the consequences might be, > though. Anyone know what class changes might make de-serializing fail?
Any changes in the attributes, especially *removing* attributes or adding new required attributes. Basically anything that changes what your instance data foot print looks like. > But, clearly, I need to be able to release updates with new versions and > expect older serialized versions to still be thawed. Yes. Basically you need to keep backwards compatibility with old data structures serialized out. You can do this by making sure that any *new* attributes either are not required, or have good defaults; and by making sure that any attributes you remove are never actually removed from the class, but instead are deprecated in some fashion. The easiest way to do this is only bump the version number any time you futz with the number and/or type of attributes in a class. But that's a distasteful solution unless your object is basically just a data object with almost no custom behavior. What you really want is a way to provide a Binary Compatibility version or something like that. Waaaay back in the dawn of time Yuval wrote MooseX::Storage::Base::WithChecksum which actually goes the opposite direction and makes sure that you don't inflate classes where the .pm file checksum doesn't tie out against what you serialized it with. I'd suggest starting with that and looking at how to go the opposite direction and check say a class-level instance_version() method that you only increment when you break back compat. Also there is some prior art in the way that KiokuDB handles migrating between versions of objects. I'm not sure that solution is fully baked, having used it a few times, but it does provide another possible avenue. -Chris