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
aa4b6f46
Commit
aa4b6f46
authored
May 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a51a0274
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
go/zodb/persistent.go
go/zodb/persistent.go
+7
-7
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+10
-10
No files found.
go/zodb/persistent.go
View file @
aa4b6f46
...
@@ -208,10 +208,10 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
...
@@ -208,10 +208,10 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
"%v (want %v); .loading = %p (want %p)"
,
s
,
GHOST
,
l
,
loading
))
"%v (want %v); .loading = %p (want %p)"
,
s
,
GHOST
,
l
,
loading
))
}
}
obj
.
serial
=
serial
// try to pass loaded state to object
// try to pass loaded state to object
if
err
==
nil
{
if
err
==
nil
{
obj
.
serial
=
serial
switch
istate
:=
obj
.
istate
()
.
(
type
)
{
switch
istate
:=
obj
.
istate
()
.
(
type
)
{
case
Stateful
:
case
Stateful
:
err
=
istate
.
SetState
(
state
)
err
=
istate
.
SetState
(
state
)
...
@@ -229,15 +229,15 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
...
@@ -229,15 +229,15 @@ func (obj *Persistent) PActivate(ctx context.Context) (err error) {
if
err
==
nil
{
if
err
==
nil
{
obj
.
state
=
UPTODATE
obj
.
state
=
UPTODATE
}
}
}
loading
.
err
=
err
// force reload on next activate if it was an error
}
else
{
if
err
!=
nil
{
obj
.
serial
=
InvalidTid
// force reload on next activate if it was an error
obj
.
loading
=
nil
obj
.
loading
=
nil
}
}
loading
.
err
=
err
obj
.
mu
.
Unlock
()
obj
.
mu
.
Unlock
()
close
(
loading
.
ready
)
close
(
loading
.
ready
)
...
...
go/zodb/persistent_test.go
View file @
aa4b6f46
...
@@ -487,13 +487,11 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -487,13 +487,11 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
tdb
.
Add
(
101
,
"bonjour"
)
tdb
.
Add
(
101
,
"bonjour"
)
tdb
.
Add
(
102
,
"monde"
)
tdb
.
Add
(
102
,
"monde"
)
tdb
.
Commit
()
at0
:=
tdb
.
Commit
()
at0
:=
tdb
.
head
tdb
.
Add
(
101
,
"hello"
)
tdb
.
Add
(
101
,
"hello"
)
tdb
.
Add
(
102
,
"world"
)
tdb
.
Add
(
102
,
"world"
)
tdb
.
Commit
()
at1
:=
tdb
.
Commit
()
at1
:=
tdb
.
head
tdb
.
Reopen
()
// so that at0 is not covered by db.δtail
tdb
.
Reopen
()
// so that at0 is not covered by db.δtail
db
:=
tdb
.
db
db
:=
tdb
.
db
...
@@ -555,8 +553,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -555,8 +553,7 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
// commit change to obj2 from external process
// commit change to obj2 from external process
tdb
.
Add
(
102
,
"kitty"
)
tdb
.
Add
(
102
,
"kitty"
)
tdb
.
Commit
()
at2
:=
tdb
.
Commit
()
at2
:=
tdb
.
head
// new db connection should see the change
// new db connection should see the change
t2
:=
tdb
.
Open
(
&
ConnOptions
{})
t2
:=
tdb
.
Open
(
&
ConnOptions
{})
...
@@ -733,6 +730,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -733,6 +730,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t
.
checkObj
(
robj2
,
102
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
robj2
,
102
,
InvalidTid
,
GHOST
,
0
)
}
}
// Verify that PActivate works correctly after hitting an error from the storage.
// In this test the error is "object was deleted".
func
TestActivateAfterDelete
(
t0
*
testing
.
T
)
{
func
TestActivateAfterDelete
(
t0
*
testing
.
T
)
{
assert
:=
assert
.
New
(
t0
)
assert
:=
assert
.
New
(
t0
)
...
@@ -768,7 +767,7 @@ func TestActivateAfterDelete(t0 *testing.T) {
...
@@ -768,7 +767,7 @@ func TestActivateAfterDelete(t0 *testing.T) {
// conn stays at older view with obj pinned into the cache
// conn stays at older view with obj pinned into the cache
t
.
checkObj
(
obj
,
101
,
at0
,
UPTODATE
,
0
,
"object"
)
t
.
checkObj
(
obj
,
101
,
at0
,
UPTODATE
,
0
,
"object"
)
// finish transaction and reopen new connection - it should be conn
// finish transaction and reopen new connection - it should be
the same
conn
t
.
Abort
()
t
.
Abort
()
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
t
.
conn
})
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
{
t
.
conn
})
t_
:=
tdb
.
Open
(
&
ConnOptions
{})
t_
:=
tdb
.
Open
(
&
ConnOptions
{})
...
@@ -780,7 +779,7 @@ func TestActivateAfterDelete(t0 *testing.T) {
...
@@ -780,7 +779,7 @@ func TestActivateAfterDelete(t0 *testing.T) {
t
.
checkObj
(
obj
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj
,
101
,
InvalidTid
,
GHOST
,
0
)
// activating obj should give "no data" error
// activating obj should give "no data" error
//
(loop because second activate used to panic)
//
loop because second activate used to panic
for
i
:=
0
;
i
<
10
;
i
++
{
for
i
:=
0
;
i
<
10
;
i
++
{
err
:=
obj
.
PActivate
(
t
.
ctx
)
err
:=
obj
.
PActivate
(
t
.
ctx
)
eok
:=
&
NoDataError
{
Oid
:
obj
.
POid
(),
DeletedAt
:
at1
}
eok
:=
&
NoDataError
{
Oid
:
obj
.
POid
(),
DeletedAt
:
at1
}
...
@@ -789,6 +788,8 @@ func TestActivateAfterDelete(t0 *testing.T) {
...
@@ -789,6 +788,8 @@ func TestActivateAfterDelete(t0 *testing.T) {
if
!
reflect
.
DeepEqual
(
e
,
eok
)
{
if
!
reflect
.
DeepEqual
(
e
,
eok
)
{
t
.
Fatalf
(
"(%d) after delete: err:
\n
have: %s
\n
want cause: %s"
,
i
,
err
,
eok
)
t
.
Fatalf
(
"(%d) after delete: err:
\n
have: %s
\n
want cause: %s"
,
i
,
err
,
eok
)
}
}
// obj should stay in the cache in ghost state
t
.
checkObj
(
obj
,
101
,
InvalidTid
,
GHOST
,
0
)
}
}
}
}
...
@@ -805,8 +806,7 @@ func TestLiveCache(t0 *testing.T) {
...
@@ -805,8 +806,7 @@ func TestLiveCache(t0 *testing.T) {
tdb
.
Add
(
102
,
"труд"
)
tdb
.
Add
(
102
,
"труд"
)
tdb
.
Add
(
103
,
"май"
)
tdb
.
Add
(
103
,
"май"
)
tdb
.
Add
(
104
,
"весна"
)
tdb
.
Add
(
104
,
"весна"
)
tdb
.
Commit
()
at1
:=
tdb
.
Commit
()
at1
:=
tdb
.
head
zcc
:=
&
zcacheControl
{
map
[
Oid
]
PCachePolicy
{
zcc
:=
&
zcacheControl
{
map
[
Oid
]
PCachePolicy
{
// obj1 - default (currently: don't pin and don't keep state)
// obj1 - default (currently: don't pin and don't keep state)
...
...
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