Commit 9f4ac6f7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b37af2a2
......@@ -471,11 +471,11 @@ func (db *DB) get(atMin, at Tid) *Connection {
return at < db.pool[i].at
})
fmt.Printf("pool:\n")
for i := 0; i < l; i++ {
fmt.Printf("\t[%d]: .at = %s\n", i, db.pool[i].at)
}
fmt.Printf("get [%s, %s] -> %d\n", atMin, at, i)
//fmt.Printf("pool:\n")
//for i := 0; i < l; i++ {
// fmt.Printf("\t[%d]: .at = %s\n", i, db.pool[i].at)
//}
//fmt.Printf("get [%s, %s] -> %d\n", atMin, at, i)
// search through window of X previous connections and find out the one
// with minimal distance to get to state @at that fits into requested range.
......
......@@ -268,6 +268,11 @@ func (obj *Persistent) PDeactivate() {
}
}
// already ghost
if obj.state == GHOST {
return
}
obj.serial = InvalidTid
obj.istate().DropState()
obj.state = GHOST
......@@ -284,6 +289,11 @@ func (obj *Persistent) PInvalidate() {
panic(obj.badf("invalidate: refcnt != 0 (= %d)", obj.refcnt))
}
// already ghost
if obj.state == GHOST {
return
}
obj.serial = InvalidTid
obj.istate().DropState()
obj.state = GHOST
......
......@@ -84,10 +84,9 @@ func _checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial T
xbase := reflect.ValueOf(obj).Elem().FieldByName("Persistent")
pbase := xbase.Addr().Interface().(*Persistent)
var badv []string
badf := func(format string, argv ...interface{}) {
t.Helper()
msg := fmt.Sprintf(format, argv...)
t.Fatalf("%#v: %s", obj, msg)
badv = append(badv, fmt.Sprintf(format, argv...))
}
zc := pbase.zclass
......@@ -116,6 +115,14 @@ func _checkObj(t testing.TB, obj IPersistent, jar *Connection, oid Oid, serial T
badf("base.instance != obj")
}
// XXX loading too?
if len(badv) != 0 {
msg := fmt.Sprintf("%#v:\n", obj)
for _, bad := range badv {
msg += fmt.Sprintf("\t- %s\n", bad)
}
t.Fatal(msg)
}
}
func tCheckObj(t testing.TB) func(IPersistent, *Connection, Oid, Tid, ObjectState, int32, *loadState) {
......@@ -233,7 +240,7 @@ func TestPersistentDB(t *testing.T) {
assert.Equal(ClassOf(xobj1), "t.zodb.MyObject")
assert.Equal(ClassOf(xobj2), "t.zodb.MyObject")
// XXX objX -> c1objX
// XXX objX -> c1objX ?
obj1 := xobj1.(*MyObject)
obj2 := xobj2.(*MyObject)
......@@ -325,7 +332,6 @@ func TestPersistentDB(t *testing.T) {
assert.Equal(conn1.txn, nil)
assert.Equal(db.pool, []*Connection{conn1})
println("\n\nCONN3")
// open new connection - it should be conn1 but at updated database view
txn3, ctx3 := transaction.New(ctx)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment