Commit f4ebe975 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 9f4ac6f7
...@@ -268,7 +268,7 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er ...@@ -268,7 +268,7 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
db.mu.Lock() // unlocked in *DBUnlock db.mu.Lock() // unlocked in *DBUnlock
/* /*
err := db.needHeadOrDBUnlock(ctx, at) err := db.needHeadOrDBUnlock(ctx, at) XXX wait for δtail.head >= at
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -528,6 +528,7 @@ func (db *DB) put(conn *Connection) { ...@@ -528,6 +528,7 @@ func (db *DB) put(conn *Connection) {
defer db.mu.Unlock() defer db.mu.Unlock()
// XXX check if len(pool) > X, and drop conn if yes // XXX check if len(pool) > X, and drop conn if yes
// [i-1].at ≤ at < [i].at // [i-1].at ≤ at < [i].at
i := sort.Search(len(db.pool), func(i int) bool { i := sort.Search(len(db.pool), func(i int) bool {
return conn.at < db.pool[i].at return conn.at < db.pool[i].at
......
...@@ -313,6 +313,8 @@ func TestPersistentDB(t *testing.T) { ...@@ -313,6 +313,8 @@ func TestPersistentDB(t *testing.T) {
// conn1 stays at older view for now // conn1 stays at older view for now
checkObj(obj1, conn1, 101, InvalidTid, GHOST, 0, nil)
checkObj(obj2, conn1, 102, InvalidTid, GHOST, 0, nil)
err = obj1.PActivate(ctx1); X(err) err = obj1.PActivate(ctx1); X(err)
err = obj2.PActivate(ctx1); X(err) err = obj2.PActivate(ctx1); X(err)
checkObj(obj1, conn1, 101, at1, UPTODATE, 1, nil) checkObj(obj1, conn1, 101, at1, UPTODATE, 1, nil)
...@@ -363,10 +365,12 @@ func TestPersistentDB(t *testing.T) { ...@@ -363,10 +365,12 @@ func TestPersistentDB(t *testing.T) {
assert.Equal(obj1.value, "hello") assert.Equal(obj1.value, "hello")
assert.Equal(obj2.value, "kitty") assert.Equal(obj2.value, "kitty")
// finish tnx3 and txn2 - conn1 and conn2 go back to db pool
// XXX
txn3.Abort() txn3.Abort()
txn2.Abort() txn2.Abort()
assert.Equal(conn1.txn, nil)
assert.Equal(conn2.txn, nil)
assert.Equal(db.pool, []*Connection{conn1, conn2})
// XXX DB.Open with at on and +-1 δtail edges // XXX DB.Open with at on and +-1 δtail edges
......
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