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
6f377311
Commit
6f377311
authored
Feb 01, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2d12146a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
25 deletions
+9
-25
go/zodb/db.go
go/zodb/db.go
+8
-25
go/zodb/zodb.go
go/zodb/zodb.go
+1
-0
No files found.
go/zodb/db.go
View file @
6f377311
...
...
@@ -124,7 +124,7 @@ func NewDB(stor IStorage) *DB {
watchq
:=
make
(
chan
CommitEvent
)
at0
:=
stor
.
AddWatch
(
watchq
)
db
.
δtail
=
NewΔTail
(
at0
)
// init
δtail
to (at0, at0]
db
.
δtail
=
NewΔTail
(
at0
)
// init to (at0, at0]
go
db
.
watcher
(
watchq
)
// XXX DelWatch? in db.Close() ?
...
...
@@ -243,36 +243,29 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
// find out db state we should open at
at
:=
opt
.
At
if
at
==
0
{
head
:=
Tid
(
0
)
if
opt
.
NoSync
{
db
.
mu
.
Lock
()
head
=
db
.
δtail
.
Head
()
// = 0 if δtail was not yet initialized with first event
at
=
db
.
δtail
.
Head
()
db
.
mu
.
Unlock
()
}
// !NoSync or δtail !initialized
// sync storage for lastTid
if
head
==
0
{
}
else
{
// sync storage for lastTid
var
err
error
// XXX stor.LastTid returns last_tid storage itself
// received on server, not last_tid on server.
// -> add stor.Sync() ?
head
,
err
=
db
.
stor
.
LastTid
(
ctx
)
at
,
err
=
db
.
stor
.
LastTid
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
}
at
=
head
}
// proceed to open(at)
db
.
mu
.
Lock
()
// unlocked in *DBUnlock
/*
err := db.needHeadOrDBUnlock(ctx, at)
// XXX what if δtail !init yet?
err := db.needHeadOrDBUnlock(ctx, at)
if err != nil {
return nil, err
}
...
...
@@ -313,23 +306,15 @@ retry:
// no exact match - let's try to find nearest
δtail
:=
db
.
δtail
δhead
:=
db
.
δtail
.
Head
()
// too far in the past, and we know there is no exact match
// -> new historic connection.
if
at
<=
db
.
δtail
.
Tail
()
{
return
newConnection
(
db
,
at
),
nil
}
// δtail !initialized yet
if
db
.
δtail
.
Head
()
==
0
{
// XXX δtail could be not yet initialized, but e.g. last_tid changed
// -> we have to wait for δtail not to loose just-released live cache
if
at
<=
δtail
.
Tail
()
{
return
newConnection
(
db
,
at
),
nil
}
// we have some δtail coverage, but at is ahead of that.
if
at
>
δ
head
{
if
at
>
δ
tail
.
Head
()
{
// wait till δtail.head is up to date covering ≥ at,
// and retry the loop (δtail.tail might go over at while we are waiting)
δready
:=
make
(
chan
struct
{})
...
...
@@ -348,8 +333,6 @@ retry:
}
}
// XXX note: vvv at start δtail.Tail is not covering first committed txn
// at ∈ (δtail, δhead] ; try to get nearby idle connection or make a new one
conn
=
db
.
get
(
δtail
.
Tail
(),
at
)
if
conn
==
nil
{
...
...
go/zodb/zodb.go
View file @
6f377311
...
...
@@ -451,6 +451,7 @@ type Watcher interface {
//
// Multiple AddWatch calls with the same watchq register watchq only once. XXX
//
// XXX ↑ guaranteed
// XXX watchq closed when stor.watchq closed?
AddWatch
(
watchq
chan
<-
CommitEvent
)
(
at0
Tid
)
...
...
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