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
518e6750
Commit
518e6750
authored
Feb 01, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9baafc82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
20 deletions
+10
-20
go/zodb/db.go
go/zodb/db.go
+4
-4
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+6
-16
No files found.
go/zodb/db.go
View file @
518e6750
...
...
@@ -200,9 +200,9 @@ func (db *DB) watcher(watchq <-chan CommitEvent) { // XXX err ?
}
// forget older δtail entries
fmt
.
Println
()
fmt
.
Printf
(
"%s
\n
"
,
db
.
δtail
.
Head
()
.
Time
()
.
Time
)
fmt
.
Printf
(
"%s
\n
"
,
db
.
δtail
.
Head
()
.
Time
()
.
Add
(
-
db
.
tδkeep
))
//
fmt.Println()
//
fmt.Printf("%s\n", db.δtail.Head().Time().Time)
//
fmt.Printf("%s\n", db.δtail.Head().Time().Add(-db.tδkeep))
tcut
:=
db
.
δtail
.
Head
()
.
Time
()
.
Add
(
-
db
.
tδkeep
)
δcut
:=
TidFromTime
(
tcut
)
...
...
@@ -294,7 +294,7 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
// must be called with db.mu locked.
// db.mu is unlocked on error.
func
(
db
*
DB
)
openOrDBUnlock
(
ctx
context
.
Context
,
at
Tid
,
noPool
bool
)
(
*
Connection
,
error
)
{
fmt
.
Printf
(
"db.openx %s %v
\t
; δtail (%s, %s]
\n
"
,
at
,
noPool
,
db
.
δtail
.
Tail
(),
db
.
δtail
.
Head
())
fmt
.
Printf
(
"db.openx %s
nopool=
%v
\t
; δtail (%s, %s]
\n
"
,
at
,
noPool
,
db
.
δtail
.
Tail
(),
db
.
δtail
.
Head
())
// NoPool connection - create one anew
if
noPool
{
// XXX wait for at to be covered
...
...
go/zodb/persistent_test.go
View file @
518e6750
...
...
@@ -191,7 +191,6 @@ func (cc *zcacheControl) WantEvict(obj IPersistent) bool {
// XXX test for cache=y/n (raw data cache)
// XXX test both txn.Abort() and conn.Resync()
func
TestPersistentDB
(
t
*
testing
.
T
)
{
println
(
"111"
)
X
:=
exc
.
Raiseif
assert
:=
require
.
New
(
t
)
checkObj
:=
tCheckObj
(
t
)
...
...
@@ -208,19 +207,14 @@ func TestPersistentDB(t *testing.T) {
_obj1
:=
NewMyObject
(
nil
);
_obj1
.
oid
=
101
;
_obj1
.
value
=
"hello"
_obj2
:=
NewMyObject
(
nil
);
_obj2
.
oid
=
102
;
_obj2
.
value
=
"world"
at1
,
err
:=
ZPyCommit
(
zurl
,
0
,
_obj1
,
_obj2
);
X
(
err
)
println
(
"222"
)
// open connection to it via zodb/go
ctx
:=
context
.
Background
()
stor
,
err
:=
OpenStorage
(
ctx
,
zurl
,
&
OpenOptions
{
ReadOnly
:
true
});
X
(
err
)
println
(
"333"
)
db
:=
NewDB
(
stor
)
println
(
"444"
)
txn1
,
ctx1
:=
transaction
.
New
(
ctx
)
println
(
"444b"
)
conn1
,
err
:=
db
.
Open
(
ctx1
,
&
ConnOptions
{});
X
(
err
)
println
(
"555"
)
assert
.
Equal
(
conn1
.
At
(),
at1
)
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
(
nil
))
assert
.
Equal
(
conn1
.
db
,
db
)
...
...
@@ -240,7 +234,6 @@ func TestPersistentDB(t *testing.T) {
assert
.
Equal
(
ClassOf
(
xobj2
),
"t.zodb.MyObject"
)
// XXX objX -> c1objX
println
(
"ZZZ"
)
obj1
:=
xobj1
.
(
*
MyObject
)
obj2
:=
xobj2
.
(
*
MyObject
)
...
...
@@ -284,8 +277,6 @@ func TestPersistentDB(t *testing.T) {
_obj2
.
value
=
"kitty"
at2
,
err
:=
ZPyCommit
(
zurl
,
at1
,
_obj2
);
X
(
err
)
println
(
"000"
)
// new db connection should see the change
// XXX currently there is a race because db.Open does not do proper Sync
txn2
,
ctx2
:=
transaction
.
New
(
ctx
)
...
...
@@ -328,15 +319,13 @@ func TestPersistentDB(t *testing.T) {
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
at1
,
UPTODATE
,
0
,
nil
)
println
(
"AAA"
)
// txn1 completes - conn1 goes back to db pool
assert
.
Equal
(
conn1
.
txn
,
txn1
)
txn1
.
Abort
()
assert
.
Equal
(
conn1
.
txn
,
nil
)
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
conn1
})
println
(
"
\n\n
BBB
"
)
println
(
"
\n\n
CONN3
"
)
// open new connection - it should be conn1 but at updated database view
txn3
,
ctx3
:=
transaction
.
New
(
ctx
)
...
...
@@ -347,13 +336,12 @@ func TestPersistentDB(t *testing.T) {
assert
.
Equal
(
conn1
.
db
,
db
)
assert
.
Equal
(
conn1
.
txn
,
txn3
)
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{})
// XXX ctx1 = ctx3 (not to use 3 below) ?
println
(
"CCC"
)
ctx1
=
ctx3
// not to use ctx3 below
ctx3
=
nil
// obj2 should be invalidated
assert
.
Equal
(
conn1
.
Cache
()
.
Get
(
101
),
obj1
)
// XXX is
assert
.
Equal
(
conn1
.
Cache
()
.
Get
(
10
1
),
obj2
)
// XXX is
assert
.
Equal
(
conn1
.
Cache
()
.
Get
(
10
2
),
obj2
)
// XXX is
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
InvalidTid
,
GHOST
,
0
,
nil
)
...
...
@@ -379,6 +367,8 @@ func TestPersistentDB(t *testing.T) {
// TODO Resync (without δtail coverage)
// XXX cache dropping entries after GC
// XXX Get(txn = different) -> panic
}
...
...
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