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
ef4fc1b4
Commit
ef4fc1b4
authored
Jan 28, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8693a253
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
18 deletions
+41
-18
go/zodb/db.go
go/zodb/db.go
+41
-18
No files found.
go/zodb/db.go
View file @
ef4fc1b4
...
...
@@ -260,7 +260,7 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
at
=
head
}
db
.
mu
.
Lock
()
db
.
mu
.
Lock
()
// XXX no - back to resync
defer
db
.
mu
.
Unlock
()
conn
,
err
:=
db
.
open
(
ctx
,
at
,
opt
.
NoPool
)
...
...
@@ -320,6 +320,7 @@ retry:
select
{
case
<-
ctx
.
Done
()
:
// XXX double unlock
return
nil
,
ctx
.
Err
()
case
<-
δready
:
...
...
@@ -358,9 +359,6 @@ func (conn *Connection) Resync(txn transaction.Transaction, at Tid) {
if
!
conn
.
noPool
{
panic
(
"Conn.Resync: connection was opened without NoPool flag"
)
}
if
conn
.
txn
!=
nil
{
panic
(
"Conn.Resync: previous transaction is not yet complete"
)
}
if
at
==
0
{
panic
(
"Conn.Resync: resync to at=0 (auto-mode is valid only for DB.Open)"
)
}
...
...
@@ -372,15 +370,25 @@ func (conn *Connection) Resync(txn transaction.Transaction, at Tid) {
}
// resync serves Connection.resync and DB.Open .
//
// must be called with conn.db.mu locked.
func
(
conn
*
Connection
)
resync
(
txn
transaction
.
Transaction
,
at
Tid
)
{
// XXX conn.cache.Lock ? - yes (e.g. if user also checks it from outside, right?)
// XXX assert conn.txn == nil
if
conn
.
txn
!=
nil
{
panic
(
"Conn.resync: previous transaction is not yet complete"
)
}
δtail
:=
db
.
δtail
defer
func
()
{
conn
.
at
=
at
conn
.
txn
=
txn
txn
.
RegisterSync
((
*
connTxnSync
)(
conn
))
}()
// XXX conn.at == at - do nothing (even if out of δtail coverave)
// conn.at == at - nothing to do (even if out of δtail coverage)
if
conn
.
at
==
at
{
return
}
δtail
:=
db
.
δtail
δobj
:=
make
(
map
[
Oid
]
struct
{})
// what to invalidate
δall
:=
false
// if we have to invalidate all objects
// both conn.at and at are covered by δtail - we can invalidate selectively
if
(
δtail
.
Tail
()
<
conn
.
at
&&
conn
.
at
<=
δtail
.
Head
())
&&
...
...
@@ -395,16 +403,23 @@ func (conn *Connection) resync(txn transaction.Transaction, at Tid) {
for
_
,
δ
:=
range
δv
{
for
_
,
oid
:=
range
δ
.
changev
{
obj
:=
conn
.
cache
.
Get
(
oid
)
if
obj
!=
nil
{
obj
.
PInvalidate
()
}
δobj
[
oid
]
=
struct
{}{}
}
}
// some of conn.at or at is outside δtail coverage - invalidate all
// objects, but keep the objects present in live cache.
}
else
{
δall
=
true
}
// XXX unlock db before txn.RegisterSync (it locks txn.mu)
db
.
mu
.
Unlock
()
conn
.
cache
.
Lock
()
defer
conn
.
cache
.
Unlock
()
if
δall
{
// XXX keep synced with LiveCache details
// XXX -> conn.cache.forEach?
// XXX should we wait for db.stor.head to cover at?
...
...
@@ -415,13 +430,21 @@ func (conn *Connection) resync(txn transaction.Transaction, at Tid) {
obj
.
PInvalidate
()
}
}
}
else
{
for
oid
:=
range
δobj
{
obj
:=
conn
.
cache
.
Get
(
oid
)
if
obj
!=
nil
{
obj
.
PInvalidate
()
}
}
}
// XXX unlock db before txn.RegisterSync (it locks txn.mu)
// all done
return
conn
.
at
=
at
conn
.
txn
=
txn
txn
.
RegisterSync
((
*
connTxnSync
)(
conn
))
//
conn.at = at
//
conn.txn = txn
//
txn.RegisterSync((*connTxnSync)(conn))
}
// get returns connection from db pool most close to at.
...
...
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