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
0d6b8ad3
Commit
0d6b8ad3
authored
Jan 28, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1ea124ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
1 deletion
+60
-1
go/zodb/db.go
go/zodb/db.go
+60
-1
No files found.
go/zodb/db.go
View file @
0d6b8ad3
...
...
@@ -349,7 +349,66 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
return
conn
,
nil
}
//func (conn *Connection) resync(at Tid
// Resync resyncs the connection onto different database view.
//
// XXX previous conn's txn must be already complete.
// XXX must be run under transaction.
// XXX objects are guaranteed to stay in live cache, even if in ghost state.
// XXX Resync allowed only for connections opened with NoPool flag.
// XXX contrary to DB.Open at cannot be 0.
// XXX new at can be both higher and lower than previous at.
func
(
conn
*
Connection
)
Resync
(
ctx
context
.
Context
,
at
Tid
)
{
// XXX assert conn.noPool == true
// XXX assert conn.txn == nil
// XXX assert at != 0
// XXX conn.cache.Lock ? - yes (e.g. if user also checks it from outside, right?)
txn
:=
transaction
.
Current
(
ctx
)
db
:=
conn
.
db
db
.
mu
.
Lock
()
defer
db
.
mu
.
Unlock
()
δtail
:=
db
.
δtail
// both conn.at and at are covered by δtail - we can invalidate selectively
if
(
δtail
.
Tail
()
<
conn
.
at
&&
conn
.
at
<=
δtail
.
Head
())
&&
(
δtail
.
Tail
()
<
at
&&
at
<=
δtail
.
Head
())
{
var
δv
[]
δRevEntry
if
conn
.
at
<=
at
{
δv
=
δtail
.
SliceByRev
(
conn
.
at
,
at
)
}
else
{
// at < conn.at
δv
=
δtail
.
SliceByRev
(
at
-
1
,
conn
.
at
-
1
)
}
for
_
,
δ
:=
range
δv
{
for
_
,
oid
:=
range
δ
.
changev
{
obj
:=
conn
.
cache
.
Get
(
oid
)
if
obj
!=
nil
{
obj
.
PInvalidate
()
}
}
}
// some of conn.at or at is outside δtail coverage - invalidate all
// objects, but keep the objects present in live cache.
}
else
{
// XXX keep synced with LiveCache details
// XXX -> conn.cache.forEach?
// XXX should we wait for db.stor.head to cover at?
// or leave this wait till load time?
for
_
,
wobj
:=
range
conn
.
cache
.
objtab
{
obj
,
_
:=
wobj
.
Get
()
.
(
IPersistent
)
if
obj
!=
nil
{
obj
.
PInvalidate
()
}
}
}
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