Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
670bd87a
Commit
670bd87a
authored
Jan 28, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
841d1a73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
go/zodb/db.go
go/zodb/db.go
+13
-14
No files found.
go/zodb/db.go
View file @
670bd87a
...
@@ -455,7 +455,9 @@ func (conn *Connection) resyncAndDBUnlock(txn transaction.Transaction, at Tid) {
...
@@ -455,7 +455,9 @@ func (conn *Connection) resyncAndDBUnlock(txn transaction.Transaction, at Tid) {
return
return
}
}
// get returns connection from db pool most close to at with conn.at ∈ (atMin, at].
// get returns connection from db pool most close to at with conn.at ∈ [atMin, at].
//
// XXX recheck [atMin or (atMin
//
//
// if there is no such connection in the pool - nil is returned.
// if there is no such connection in the pool - nil is returned.
// must be called with db.mu locked.
// must be called with db.mu locked.
...
@@ -469,30 +471,31 @@ func (db *DB) get(atMin, at Tid) *Connection {
...
@@ -469,30 +471,31 @@ func (db *DB) get(atMin, at Tid) *Connection {
})
})
// search through window of X previous connections and find out the one
// search through window of X previous connections and find out the one
// with minimal distance to get to state @at. If all connections are too
// with minimal distance to get to state @at that fits into requested range.
// distant - create connection anew. // XXX no -> nil
//
//
// XXX search not only previous, but future too? (we can get back to
// XXX search not only previous, but future too? (we can get back to
// past by invalidating what was later changed) (but likely it will
// past by invalidating what was later changed) (but likely it will
// hurt by destroying cache of more recent connection)
// hurt by destroying cache of more recent connection)
.
const
X
=
10
// XXX hardcoded
const
X
=
10
// XXX
search window size:
hardcoded
jδmin
:=
-
1
jδmin
:=
-
1
for
j
:=
i
-
X
;
j
<
i
;
j
++
{
for
j
:=
i
-
X
;
j
<
i
;
j
++
{
if
j
<
0
{
if
j
<
0
{
continue
continue
}
}
if
db
.
pool
[
j
]
.
at
<
atMin
{
continue
}
// TODO search for max N(live) - N(live, that will need to be invalidated)
// TODO search for max N(live) - N(live, that will need to be invalidated)
jδmin
=
j
// XXX stub (using rightmost j)
jδmin
=
j
// XXX stub (using rightmost j)
}
}
// nothing found or too distant
// nothing found
const
Tnear
=
10
*
time
.
Minute
// XXX hardcoded
if
jδmin
<
0
{
if
jδmin
<
0
||
tabs
(
δtid
(
at
,
db
.
pool
[
jδmin
]
.
at
))
>
Tnear
{
return
nil
return
newConnection
(
db
,
at
)
// XXX no -> nil
}
}
// reuse the connection
//
found -
reuse the connection
conn
:=
db
.
pool
[
jδmin
]
conn
:=
db
.
pool
[
jδmin
]
copy
(
db
.
pool
[
jδmin
:
],
db
.
pool
[
jδmin
+
1
:
])
copy
(
db
.
pool
[
jδmin
:
],
db
.
pool
[
jδmin
+
1
:
])
db
.
pool
[
l
-
1
]
=
nil
db
.
pool
[
l
-
1
]
=
nil
...
@@ -505,10 +508,6 @@ func (db *DB) get(atMin, at Tid) *Connection {
...
@@ -505,10 +508,6 @@ func (db *DB) get(atMin, at Tid) *Connection {
panic
(
"DB.get: live connection in the pool"
)
panic
(
"DB.get: live connection in the pool"
)
}
}
if
conn
.
at
!=
at
{
panic
(
"DB.get: TODO: invalidations"
)
// XXX
}
return
conn
return
conn
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment