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
7d1ae1a1
Commit
7d1ae1a1
authored
Dec 18, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
731e6b32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
20 deletions
+15
-20
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+4
-2
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+6
-16
go/zodb/storage/fs1/index.go
go/zodb/storage/fs1/index.go
+5
-2
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
7d1ae1a1
...
...
@@ -452,6 +452,7 @@ func (fs *FileStorage) watcher(w *fsnotify.Watcher) {
defer
w
.
Close
()
// XXX lclose
err
:=
fs
.
_watcher
(
w
)
// it is ok if we got read error due to file being closed
// XXX it can also be ErrFileClosing which is internal
if
e
,
_
:=
errors
.
Cause
(
err
)
.
(
*
os
.
PathError
);
e
!=
nil
&&
e
.
Err
==
os
.
ErrClosed
{
select
{
case
<-
fs
.
down
:
...
...
@@ -646,9 +647,8 @@ func (fs *FileStorage) Close() error {
}
// Open opens FileStorage @path.
//
// TODO read-write support
func
Open
(
ctx
context
.
Context
,
path
string
,
opt
*
zodb
.
DriverOptions
)
(
_
*
FileStorage
,
err
error
)
{
// TODO read-write support
if
!
opt
.
ReadOnly
{
return
nil
,
fmt
.
Errorf
(
"fs1: %s: TODO write mode not implemented"
,
path
)
}
...
...
@@ -693,6 +693,8 @@ func Open(ctx context.Context, path string, opt *zodb.DriverOptions) (_ *FileSto
log
.
Print
(
err
)
log
.
Printf
(
"%s: index rebuild..."
,
path
)
index
,
err
=
BuildIndex
(
ctx
,
fseq
,
nil
/*no progress; XXX log it? */
)
// XXX cause=ErrUnexpectedEOF -> let watcher decide what was
// it: garbage or in-progress transaction
if
err
!=
nil
{
return
nil
,
err
}
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
7d1ae1a1
...
...
@@ -367,6 +367,8 @@ func BenchmarkIterate(b *testing.B) {
func
TestWatch
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
//xtesting.NeedPy(t, "zodbtools")
needZODBPy
(
t
)
workdir
:=
xworkdir
(
t
)
...
...
@@ -398,10 +400,7 @@ func TestWatch(t *testing.T) {
cmd
:=
exec
.
Command
(
"python2"
,
"-m"
,
"zodbtools.zodb"
,
"commit"
,
tfs
,
at
.
String
())
cmd
.
Stdin
=
zin
cmd
.
Stderr
=
os
.
Stderr
out
,
err
:=
cmd
.
Output
()
if
err
!=
nil
{
return
zodb
.
InvalidTid
,
err
}
out
,
err
:=
cmd
.
Output
();
X
(
err
)
out
=
bytes
.
TrimSuffix
(
out
,
[]
byte
(
"
\n
"
))
tid
,
err
:=
zodb
.
ParseTid
(
string
(
out
))
...
...
@@ -416,10 +415,7 @@ func TestWatch(t *testing.T) {
//tracef("-> xcommit %s", at)
//defer tracef("<- xcommit")
t
.
Helper
()
tid
,
err
:=
zcommit
(
at
,
objv
...
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
tid
,
err
:=
zcommit
(
at
,
objv
...
);
X
(
err
)
return
tid
}
...
...
@@ -432,10 +428,7 @@ func TestWatch(t *testing.T) {
checkLastTid
:=
func
(
lastOk
zodb
.
Tid
)
{
t
.
Helper
()
head
,
err
:=
fs
.
LastTid
(
ctx
)
if
err
!=
nil
{
t
.
Fatalf
(
"check last_tid: %s"
,
err
)
}
head
,
err
:=
fs
.
LastTid
(
ctx
);
X
(
err
)
if
head
!=
lastOk
{
t
.
Fatalf
(
"check last_tid: got %s; want %s"
,
head
,
lastOk
)
}
...
...
@@ -467,10 +460,7 @@ func TestWatch(t *testing.T) {
checkLastTid
(
at
)
}
err
:=
fs
.
Close
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
:=
fs
.
Close
();
X
(
err
)
e
,
ok
:=
<-
watchq
if
ok
{
...
...
go/zodb/storage/fs1/index.go
View file @
7d1ae1a1
...
...
@@ -453,7 +453,10 @@ func (index *Index) Update(ctx context.Context, r io.ReaderAt, topPos int64, pro
return
err
}
// XXX check txnh.Status != TxnInprogress
// this transaction was only voted, not fully committed yet.
if
it
.
Txnh
.
Status
==
zodb
.
TxnInprogress
{
return
nil
}
// check for topPos overlapping txn & whether we are done.
// topPos=-1 will never match here
...
...
@@ -693,7 +696,7 @@ func (index *Index) VerifyForFile(ctx context.Context, path string, ntxn int, pr
return
nil
,
err
}
topPos
:=
fi
.
Size
()
// XXX there might be last TxnInprogress transaction
XXX
topPos
:=
fi
.
Size
()
// XXX there might be last TxnInprogress transaction
XXX
if
index
.
TopPos
!=
topPos
{
return
nil
,
indexCorrupt
(
f
,
"topPos mismatch: data=%v index=%v"
,
topPos
,
index
.
TopPos
)
}
...
...
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