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
f7789b0e
Commit
f7789b0e
authored
Dec 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0c484705
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
13 deletions
+19
-13
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+7
-4
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+12
-7
go/zodb/zodb.go
go/zodb/zodb.go
+0
-2
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
f7789b0e
...
...
@@ -101,9 +101,10 @@ type FileStorage struct {
// driver client <- watcher: database commits.
watchq
chan
<-
zodb
.
WatchEvent
down
chan
struct
{}
// ready when storage is no longer operational
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
errClose
error
// error from .file.Close()
down
chan
struct
{}
// ready when storage is no longer operational
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
errClose
error
// error from .file.Close()
watchWg
sync
.
WaitGroup
// to wait for watcher finish
}
// IStorageDriver
...
...
@@ -471,6 +472,7 @@ func (fs *FileStorage) Iterate(_ context.Context, tidMin, tidMax zodb.Tid) zodb.
//
// if errFirstRead is !nil, the error of reading first transaction header is sent to it.
func
(
fs
*
FileStorage
)
watcher
(
w
*
fsnotify
.
Watcher
,
errFirstRead
chan
<-
error
)
{
defer
fs
.
watchWg
.
Done
()
defer
w
.
Close
()
// XXX lclose
err
:=
fs
.
_watcher
(
w
,
errFirstRead
)
// it is ok if we got read error due to file being closed
...
...
@@ -692,7 +694,7 @@ func (fs *FileStorage) shutdown(reason error) {
func
(
fs
*
FileStorage
)
Close
()
error
{
fs
.
shutdown
(
fmt
.
Errorf
(
"closed"
))
// XXX wait for watcher?
fs
.
watchWg
.
Wait
()
if
fs
.
errClose
!=
nil
{
return
fs
.
zerr
(
"close"
,
nil
,
fs
.
errClose
)
...
...
@@ -819,6 +821,7 @@ func Open(ctx context.Context, path string, opt *zodb.DriverOptions) (_ *FileSto
errFirstRead
=
make
(
chan
error
,
1
)
}
fs
.
watchWg
.
Add
(
1
)
go
fs
.
watcher
(
w
,
errFirstRead
)
if
checkTailGarbage
{
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
f7789b0e
...
...
@@ -476,13 +476,17 @@ func TestOpenRecovery(t *testing.T) {
workdir
:=
xworkdir
(
t
)
ctx
:=
context
.
Background
()
// checkL runs f on main + voteTail[:l]
// checkL runs f on main + voteTail[:l] . Two cases are verified:
// 1) when index is already present, and
// 2) when initially there is no index.
checkL
:=
func
(
t
*
testing
.
T
,
l
int
,
f
func
(
t
*
testing
.
T
,
tfs
string
))
{
t
.
Run
(
fmt
.
Sprintf
(
"tail=+vote%d"
,
l
),
func
(
t
*
testing
.
T
)
{
tfs
:=
fmt
.
Sprintf
(
"%s/1+vote%d.fs"
,
workdir
,
l
)
t
fs
:=
fmt
.
Sprintf
(
"%s/1+vote%d.fs"
,
workdir
,
l
)
t
.
Run
(
fmt
.
Sprintf
(
"oldindex=n/tail=+vote%d"
,
l
),
func
(
t
*
testing
.
T
)
{
err
:=
ioutil
.
WriteFile
(
tfs
,
append
(
main
,
voteTail
[
:
l
]
...
),
0600
);
X
(
err
)
err
=
ioutil
.
WriteFile
(
tfs
+
".index"
,
index
,
0600
);
X
(
err
)
f
(
t
,
tfs
)
})
t
.
Run
(
fmt
.
Sprintf
(
"oldindex=y/tail=+vote%d"
,
l
),
func
(
t
*
testing
.
T
)
{
err
:=
ioutil
.
WriteFile
(
tfs
+
".index"
,
index
,
0600
);
X
(
err
)
f
(
t
,
tfs
)
})
}
...
...
@@ -495,12 +499,13 @@ func TestOpenRecovery(t *testing.T) {
for
_
,
l
:=
range
lok
{
checkL
(
t
,
l
,
func
(
t
*
testing
.
T
,
tfs
string
)
{
fs
:=
xfsopen
(
t
,
tfs
)
defer
func
()
{
err
=
fs
.
Close
();
X
(
err
)
}()
head
,
err
:=
fs
.
LastTid
(
ctx
);
X
(
err
)
if
head
!=
lastTidOk
{
t
.
Fatalf
(
"last_tid: %s ; expected: %s"
,
head
,
lastTidOk
)
}
err
=
fs
.
Close
();
X
(
err
)
})
}
...
...
go/zodb/zodb.go
View file @
f7789b0e
...
...
@@ -442,13 +442,11 @@ type WatchEvent struct {
// Watcher allows to be notified of changes to database.
type
Watcher
interface
{
// Watch waits-for and returns next event corresponding to comitted transaction.
//
// XXX queue overflow -> special error?
Watch
(
ctx
context
.
Context
)
(
WatchEvent
,
error
)
// XXX name -> Read? ReadEvent?
// Close stops the watcher.
// err is always nil. XXX ok?
Close
()
error
...
...
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