help with safecopy + acid-state

Dear all, I can't quite get safecopy to work with acid-state: old version of code : data T = T Foo $(deriveSafeCopy 0 'base ''T) new version : data T_orig = T_orig Foo $(deriveSafeCopy 0 'base ''T_orig) data T = T Foo Bar $(deriveSafeCopy 0 'extension ''T) instance Migrate T where type MigrateFrom T = T_Orig ... but when my (new) application reads the state from disk (written by the old application) I get "Could not parse saved checkpoint due to the following error: Failed reading: Duplicate version tags: [0,0]" When I change the version number in deriveSafeCopy, I get "Failed reading: safecopy: Map: Cannot find getter associated with this version number: Version {unVersion = 2}" I don't even know where the "2" comes from. Any hints appreciated - J.W.

On Fri, Jan 27, 2012 at 3:04 PM, Johannes Waldmann
data T_orig = T_orig Foo $(deriveSafeCopy 0 'base ''T_orig) data T = T Foo Bar $(deriveSafeCopy 0 'extension ''T) instance Migrate T where type MigrateFrom T = T_Orig ...
As you can read from deriveSafeCopy's documentation [1], you need to increase the version of your data type (e.g. change that zero to one). HTH, [1] http://hackage.haskell.org/packages/archive/safecopy/0.6.1/doc/html/Data-Saf... -- Felipe.

Felipe Almeida Lessa
data T_orig = T_orig Foo $(deriveSafeCopy 0 'base ''T_orig) data T = T Foo Bar $(deriveSafeCopy 0 'extension ''T) instance Migrate T where type MigrateFrom T = T_Orig ...
As you can read from deriveSafeCopy's documentation [1], you need to increase the version of your data type (e.g. change that zero to one).
Thanks - which zero? (there are two of them.) and how does it play together with Data.Acid? Can I really rename old.T => new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot. Best - J.W.

On Mon, Jan 30, 2012 at 4:46 PM, Johannes Waldmann
Thanks - which zero? (there are two of them.)
You should not change the deriveSafeCopy of your old data type. The only allowed change is renaming your data type (see below). You should increment the version of the new version of your data type, akin to releasing a new version of a library.
Can I really rename old.T => new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot.
The name of your data type doesn't matter as acid-state doesn't store that on the disk. HTH, -- Felipe.

Can I really rename old.T => new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot.
The name of your data type doesn't matter as acid-state doesn't store that on the disk.
I think it does - because file names are state/T/*.log and so on? J.W.

On Tue, Jan 31, 2012 at 8:27 AM, Johannes Waldmann
Can I really rename old.T => new.T_orig ? It looks as if then tries to load the wrong acid-state snapshot.
The name of your data type doesn't matter as acid-state doesn't store that on the disk.
I think it does - because file names are state/T/*.log and so on?
The function 'openLocalState' in AcidState uses the name of the passed in state type to locate the log files on disk. So as long as you always call 'openLocalState' with types of the same name to represent the same state you'll be fine - this is why it is safe to rename your old type, because you call 'openLocalState' with the new type. Alternatively, you can call 'openLocalStateFrom', which doesn't base anything on names of types (you can tell because there is no 'Typeable' constraint on its arguments). Antoine
J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Antoine Latter
-
Felipe Almeida Lessa
-
Johannes Waldmann