Commit 4c999c89 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 0b792ca5
...@@ -385,7 +385,15 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er ...@@ -385,7 +385,15 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
// Must be called with at ≤ db.Head . // Must be called with at ≤ db.Head .
// Must be called with db.mu locked. // Must be called with db.mu locked.
func (db *DB) open(at Tid, noPool bool) *Connection { func (db *DB) open(at Tid, noPool bool) *Connection {
fmt.Printf("db.open @%s nopool=%v\t; δtail (%s, %s]\n", at, noPool, db.δtail.Tail(), db.δtail.Head()) δtail := db.δtail.
fmt.Printf("db.open @%s nopool=%v\t; δtail (%s, %s]\n", at, noPool, δtail.Tail(), δtail.Head())
// at should be ≤ head (caller waited for it before invoking us)
if head := δtail.Head(); at > head {
panic(fmt.Sprintf("open: at (%s) > head (%s)", at, head))
}
// NoPool connection - create one anew // NoPool connection - create one anew
if noPool { if noPool {
conn := newConnection(db, at) conn := newConnection(db, at)
...@@ -400,7 +408,6 @@ func (db *DB) open(at Tid, noPool bool) *Connection { ...@@ -400,7 +408,6 @@ func (db *DB) open(at Tid, noPool bool) *Connection {
} }
// no exact match - let's try to find nearest // no exact match - let's try to find nearest
δtail := db.δtail
// too far in the past, and we know there is no exact match // too far in the past, and we know there is no exact match
// -> new historic connection. // -> new historic connection.
...@@ -408,11 +415,6 @@ func (db *DB) open(at Tid, noPool bool) *Connection { ...@@ -408,11 +415,6 @@ func (db *DB) open(at Tid, noPool bool) *Connection {
return newConnection(db, at) return newConnection(db, at)
} }
// at should be ≤ head (caller waited for it before invoking us)
if head := δtail.Head(); at > head {
panic(fmt.Sprintf("open: at (%s) > head (%s)", at, head))
}
// at ∈ (δtail, δhead] ; try to get nearby idle connection or make a new one // at ∈ (δtail, δhead] ; try to get nearby idle connection or make a new one
conn = db.get(δtail.Tail(), at) conn = db.get(δtail.Tail(), at)
if conn == nil { if conn == nil {
......
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