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
Show 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
...
@@ -104,6 +104,7 @@ type FileStorage struct {
...
@@ -104,6 +104,7 @@ type FileStorage struct {
down
chan
struct
{}
// ready when storage is no longer operational
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
downOnce
sync
.
Once
// shutdown may be due to both Close and IO error in watcher
errClose
error
// error from .file.Close()
errClose
error
// error from .file.Close()
watchWg
sync
.
WaitGroup
// to wait for watcher finish
}
}
// IStorageDriver
// IStorageDriver
...
@@ -471,6 +472,7 @@ func (fs *FileStorage) Iterate(_ context.Context, tidMin, tidMax zodb.Tid) zodb.
...
@@ -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.
// 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
)
{
func
(
fs
*
FileStorage
)
watcher
(
w
*
fsnotify
.
Watcher
,
errFirstRead
chan
<-
error
)
{
defer
fs
.
watchWg
.
Done
()
defer
w
.
Close
()
// XXX lclose
defer
w
.
Close
()
// XXX lclose
err
:=
fs
.
_watcher
(
w
,
errFirstRead
)
err
:=
fs
.
_watcher
(
w
,
errFirstRead
)
// it is ok if we got read error due to file being closed
// it is ok if we got read error due to file being closed
...
@@ -692,7 +694,7 @@ func (fs *FileStorage) shutdown(reason error) {
...
@@ -692,7 +694,7 @@ func (fs *FileStorage) shutdown(reason error) {
func
(
fs
*
FileStorage
)
Close
()
error
{
func
(
fs
*
FileStorage
)
Close
()
error
{
fs
.
shutdown
(
fmt
.
Errorf
(
"closed"
))
fs
.
shutdown
(
fmt
.
Errorf
(
"closed"
))
// XXX wait for watcher?
fs
.
watchWg
.
Wait
()
if
fs
.
errClose
!=
nil
{
if
fs
.
errClose
!=
nil
{
return
fs
.
zerr
(
"close"
,
nil
,
fs
.
errClose
)
return
fs
.
zerr
(
"close"
,
nil
,
fs
.
errClose
)
...
@@ -819,6 +821,7 @@ func Open(ctx context.Context, path string, opt *zodb.DriverOptions) (_ *FileSto
...
@@ -819,6 +821,7 @@ func Open(ctx context.Context, path string, opt *zodb.DriverOptions) (_ *FileSto
errFirstRead
=
make
(
chan
error
,
1
)
errFirstRead
=
make
(
chan
error
,
1
)
}
}
fs
.
watchWg
.
Add
(
1
)
go
fs
.
watcher
(
w
,
errFirstRead
)
go
fs
.
watcher
(
w
,
errFirstRead
)
if
checkTailGarbage
{
if
checkTailGarbage
{
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
f7789b0e
...
@@ -476,13 +476,17 @@ func TestOpenRecovery(t *testing.T) {
...
@@ -476,13 +476,17 @@ func TestOpenRecovery(t *testing.T) {
workdir
:=
xworkdir
(
t
)
workdir
:=
xworkdir
(
t
)
ctx
:=
context
.
Background
()
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
))
{
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
)
tfs
:=
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
,
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
)
f
(
t
,
tfs
)
})
})
}
}
...
@@ -495,12 +499,13 @@ func TestOpenRecovery(t *testing.T) {
...
@@ -495,12 +499,13 @@ func TestOpenRecovery(t *testing.T) {
for
_
,
l
:=
range
lok
{
for
_
,
l
:=
range
lok
{
checkL
(
t
,
l
,
func
(
t
*
testing
.
T
,
tfs
string
)
{
checkL
(
t
,
l
,
func
(
t
*
testing
.
T
,
tfs
string
)
{
fs
:=
xfsopen
(
t
,
tfs
)
fs
:=
xfsopen
(
t
,
tfs
)
defer
func
()
{
err
=
fs
.
Close
();
X
(
err
)
}()
head
,
err
:=
fs
.
LastTid
(
ctx
);
X
(
err
)
head
,
err
:=
fs
.
LastTid
(
ctx
);
X
(
err
)
if
head
!=
lastTidOk
{
if
head
!=
lastTidOk
{
t
.
Fatalf
(
"last_tid: %s ; expected: %s"
,
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 {
...
@@ -442,13 +442,11 @@ type WatchEvent struct {
// Watcher allows to be notified of changes to database.
// Watcher allows to be notified of changes to database.
type
Watcher
interface
{
type
Watcher
interface
{
// Watch waits-for and returns next event corresponding to comitted transaction.
// Watch waits-for and returns next event corresponding to comitted transaction.
//
//
// XXX queue overflow -> special error?
// XXX queue overflow -> special error?
Watch
(
ctx
context
.
Context
)
(
WatchEvent
,
error
)
// XXX name -> Read? ReadEvent?
Watch
(
ctx
context
.
Context
)
(
WatchEvent
,
error
)
// XXX name -> Read? ReadEvent?
// Close stops the watcher.
// Close stops the watcher.
// err is always nil. XXX ok?
// err is always nil. XXX ok?
Close
()
error
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