ApptiveGrid / MoniBase

OmniBase is Smalltalk efficient objects repository, BTree and filesystem based with full ACID features
MIT License
7 stars 6 forks source link

Rehashing HashedCollections on import locks up the image if there are cycles #162

Open pdebruic opened 2 years ago

pdebruic commented 2 years ago

with PR #144 this test will lock up the image:

testSetsRehashing

    | obj1 obj2 obj3 fromDb1 fromDb2 fromDb3 |
    [ 
    obj1 := ODBTestClass1 new.
    obj1 makePersistent.

    obj2 := ODBTestClass1 new.
    obj2 makePersistent.

    obj3 := ODBTestClass1 new.
    obj3 makePersistent.
    obj1
        one: 'obj1';
        two: ODBTestClass1 new.
    obj1 two
        one: (Set with: obj2);
        two: (Set with: obj2 with: obj3);
        three: (Set with: obj2 with: obj3).
    obj2
        one: 'obj2';
        two: (Set with: obj1).
    obj3
        one: 'obj3';
        two: (Set with: obj1).

    OmniBase root at: 'one' put: obj1.
    OmniBase root at: 'two' put: obj2.
    OmniBase root at: 'three' put: obj3 ] evaluateAndCommitIn:
        db newTransaction.

    [ 
    fromDb1 := OmniBase root at: 'one'.
    fromDb2 := OmniBase root at: 'two'.
    fromDb3 := OmniBase root at: 'three'.
    self assert: (fromDb1 isIdenticalTo: obj1).
    self assert: (fromDb2 isIdenticalTo: obj2).
    self assert: (fromDb3 isIdenticalTo: obj3).
    self deny: (fromDb1 two one includes: fromDb2).
    self assert: (obj1 two one includes: fromDb2).
    fromDb1 two one rehash.
    self assert: (fromDb1 two one includes: fromDb2) ] evaluateIn:
        db newReadOnlyTransaction
pdebruic commented 2 years ago

I don't even think the test needs to be complex like this it was just the one I made prior to working out that the Sets needed to be rehashed. Seems like maybe a registry would be better than rehashing them when you see them, then rehashing all Sets all at once. I've no idea.

MarcusDenker commented 2 years ago

Cycles in collections are generally problematic.

e.g. you can not even inspect an Arrray that points to itself. #hash is an endless loop...

There is an issue tracker entry here: https://github.com/pharo-project/pharo/issues/7724