Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
80b82f0a
Commit
80b82f0a
authored
Mar 06, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1cfa529e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
go/zodb/db.go
go/zodb/db.go
+19
-21
No files found.
go/zodb/db.go
View file @
80b82f0a
...
...
@@ -190,13 +190,13 @@ func (opt *ConnOptions) String() string {
s
+=
", "
if
opt
.
NoSync
{
s
+=
"
no
"
s
+=
"
!
"
}
s
+=
"sync"
s
+=
", "
if
opt
.
NoPool
{
s
+=
"
no
"
s
+=
"
!
"
}
s
+=
"pool"
...
...
@@ -286,11 +286,16 @@ type hwaiter struct {
//
// Must be called db.mu released.
//
// XXX -> waitHead?
// XXX -> waitHead?
needHead? waitHeadAfter? ensureAt?
func
(
db
*
DB
)
headWait
(
ctx
context
.
Context
,
at
Tid
)
(
err
error
)
{
db
.
mu
.
Lock
()
// XXX check if db is already down -> error even if at is under coverage?
// XXX under mu - ok?
// XXX err ctx
if
ready
(
db
.
down
)
{
return
db
.
downErr
}
if
at
<=
db
.
δtail
.
Head
()
{
db
.
mu
.
Unlock
()
...
...
@@ -343,12 +348,6 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
}
}()
// check db is already down/closed
// XXX -> headWait?
if
ready
(
db
.
down
)
{
return
nil
,
db
.
downErr
}
// find out db state we should open at
at
:=
opt
.
At
if
at
==
0
{
...
...
@@ -357,6 +356,11 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
at
=
db
.
δtail
.
Head
()
db
.
mu
.
Unlock
()
}
else
{
// don't bother to sync to storage if db is down
if
ready
(
db
.
down
)
{
return
nil
,
db
.
downErr
}
// sync storage for lastTid
var
err
error
...
...
@@ -370,14 +374,13 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
}
}
// proceed to open(at)
// wait for db.Head ≥ at
err
=
db
.
headWait
(
ctx
,
at
)
if
err
!=
nil
{
return
nil
,
err
}
// open(at)
conn
:=
db
.
open
(
at
,
opt
.
NoPool
)
conn
.
resync
(
ctx
,
at
)
return
conn
,
nil
...
...
@@ -462,13 +465,8 @@ func (conn *Connection) Resync(ctx context.Context, at Tid) error {
// XXX err ctx? ("resync @at -> @at")
db
:=
conn
.
db
// XXX check db is already down/closed
// XXX or -> headWait?
// wait for db.Head ≥ at
err
:=
db
.
headWait
(
ctx
,
at
)
err
:=
conn
.
db
.
headWait
(
ctx
,
at
)
if
err
!=
nil
{
return
err
}
...
...
@@ -483,7 +481,6 @@ func (conn *Connection) Resync(ctx context.Context, at Tid) error {
// Must be called with conn.db released.
func
(
conn
*
Connection
)
resync
(
ctx
context
.
Context
,
at
Tid
)
{
txn
:=
transaction
.
Current
(
ctx
)
conn
.
resync1
(
at
)
// upon exit, with all locks released, register conn to txn.
...
...
@@ -493,6 +490,8 @@ func (conn *Connection) resync(ctx context.Context, at Tid) {
}
// resync1 serves resync.
//
// it computes δ(conn.at, at) and invalidates objects ∈ δ in conn cache.
func
(
conn
*
Connection
)
resync1
(
at
Tid
)
{
if
conn
.
txn
!=
nil
{
panic
(
"Conn.resync: previous transaction is not yet complete"
)
...
...
@@ -551,7 +550,6 @@ func (conn *Connection) resync1(at Tid) {
if
δall
{
// XXX keep synced with LiveCache details
// XXX -> conn.cache.forEach?
// or leave this wait till .Load() time?
for
_
,
wobj
:=
range
conn
.
cache
.
objtab
{
obj
,
_
:=
wobj
.
Get
()
.
(
IPersistent
)
if
obj
!=
nil
{
...
...
@@ -575,8 +573,8 @@ func (conn *Connection) resync1(at Tid) {
//
// XXX recheck [atMin or (atMin -- see "= δtail.Tail" in resync.
//
//
i
f there is no such connection in the pool - nil is returned.
//
m
ust be called with db.mu locked.
//
I
f there is no such connection in the pool - nil is returned.
//
M
ust be called with db.mu locked.
func
(
db
*
DB
)
get
(
atMin
,
at
Tid
)
*
Connection
{
l
:=
len
(
db
.
pool
)
...
...
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