Corrupt database?

Chris Muller ma.chris.m at gmail.com
Mon May 11 19:51:27 UTC 2009


Hi,

> I started again with another copy of the "bad" database directory, so there
> have been no changes to the MaClassDefinitions.
>
> I was able to get a MagmaFileTraverser connected and running.
>
> I have 9 STBUser instances in my database.  7 claim to be version 4 with 10
> instance variables, 2 claim to be version 1 with 10 instance variables.  I
> believe all should be version 4 with 10 instance variables.   My  current
> image class definition has 10 ivars.

Since only one of your MaClassDefinitions has 10 inst-vars, any buffer
of that class that also has 10 instVars should be pointing to that
MaClassDefinition.  i.e., it sounds like the two that claim to be
version 1 are pointing to the incorrect version.

> I believe the image thinks that our current in-image version is 1 because
> that is the version number of the last entry in the MaClassDefinitions for
> STBUser.

The image uses whichever one matches the #allInstVarNames defined in the image.

> I think I should change the version numbers of each STBUser
> MaClassDefinition so they are in order from 1 to 4, but I don't need to
> re-order the definitions.

Yes, that sounds right based on the information given.

>  This will mean that new instances of STBUser
> will be version 4, which is correct.

New instances will be based on the inImageDefinition, which is based
on the allInstVarNames defined to STBUser in the image that
instantiates the new STBUser.

> Finally, I should go through the 2 incorrect instances on disk and convert
> their class ID to 4 from 1.

Yes.

>  Is this something that MagmaFileTraverser can
> handle?  I can change the buffer's values, but can I write the repaired
> buffer back to disk?

No, the only way buffers get changed in a Magma repository is via a
commit through a MagmaSession, because you want the repository to
remain consistent with the commit-log.

All you need to do is commit those two objects that appear to be
pointing to the wrong version of the class.  Pull them up by oid,
assign them to a temp var so no chance of GC, commit a change to them,
then commit another change back to the original value.  Whatever
version of the class is loaded in the image is the version that will
be written to the buffer (so verify ahead of time the image definition
of STBUser matches version 4!).

You can then use the FileTraverser again or the MagmaBufferBrowser to
verify the original buffers now point to the correct class-definition
version.

 - Chris


More information about the Magma mailing list