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
9d13ca2c
Commit
9d13ca2c
authored
Dec 19, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9d8e264f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+1
-1
go/zodb/storage/fs1/filestorage_test.go
go/zodb/storage/fs1/filestorage_test.go
+27
-1
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
9d13ca2c
...
...
@@ -814,7 +814,7 @@ func Open(ctx context.Context, path string, opt *zodb.DriverOptions) (_ *FileSto
var
errFirstRead
chan
error
if
checkTailGarbage
{
defer
xerr
.
Contextf
(
&
err
,
"open %s: checking whether it is garbage
at
@%d"
,
path
,
index
.
TopPos
)
defer
xerr
.
Contextf
(
&
err
,
"open %s: checking whether it is garbage @%d"
,
path
,
index
.
TopPos
)
errFirstRead
=
make
(
chan
error
,
1
)
}
...
...
go/zodb/storage/fs1/filestorage_test.go
View file @
9d13ca2c
...
...
@@ -482,17 +482,27 @@ func TestOpenRecovery(t *testing.T) {
main
,
err
:=
ioutil
.
ReadFile
(
"testdata/1.fs"
);
X
(
err
)
index
,
err
:=
ioutil
.
ReadFile
(
"testdata/1.fs.index"
);
X
(
err
)
lastTidOk
:=
_1fs_dbEntryv
[
len
(
_1fs_dbEntryv
)
-
1
]
.
Header
.
Tid
topPos
:=
int64
(
_1fs_indexTopPos
)
voteTail
,
err
:=
ioutil
.
ReadFile
(
"testdata/1voted.tail"
);
X
(
err
)
workdir
:=
xworkdir
(
t
)
ctx
:=
context
.
Background
()
for
l
:=
len
(
voteTail
);
l
>=
0
;
l
--
{
// checkL runs f on main + voteTail[:l]
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
)
err
:=
ioutil
.
WriteFile
(
tfs
,
append
(
main
,
voteTail
[
:
l
]
...
),
0600
);
X
(
err
)
err
=
ioutil
.
WriteFile
(
tfs
+
".index"
,
index
,
0600
);
X
(
err
)
f
(
t
,
tfs
)
})
}
// if txn header can be fully read - it should be all ok
// XXX also test +0?
for
l
:=
len
(
voteTail
);
l
>=
TxnHeaderFixSize
;
l
--
{
checkL
(
t
,
l
,
func
(
t
*
testing
.
T
,
tfs
string
)
{
fs
:=
xfsopen
(
t
,
tfs
)
head
,
err
:=
fs
.
LastTid
(
ctx
);
X
(
err
)
if
head
!=
lastTidOk
{
...
...
@@ -502,4 +512,20 @@ func TestOpenRecovery(t *testing.T) {
err
=
fs
.
Close
();
X
(
err
)
})
}
// if txn header is not complete - open should fail
for
_
,
l
:=
range
[]
int
{
TxnHeaderFixSize
-
1
,
1
}
{
checkL
(
t
,
l
,
func
(
t
*
testing
.
T
,
tfs
string
)
{
_
,
err
:=
Open
(
ctx
,
tfs
,
&
zodb
.
DriverOptions
{
ReadOnly
:
true
})
estr
:=
""
if
err
!=
nil
{
estr
=
err
.
Error
()
}
ewant
:=
fmt
.
Sprintf
(
"open %s: checking whether it is garbage @%d: %s"
,
tfs
,
topPos
,
&
RecordError
{
tfs
,
"transaction record"
,
topPos
,
"read"
,
io
.
ErrUnexpectedEOF
})
if
estr
!=
ewant
{
t
.
Fatalf
(
"unexpected error:
\n
have: %q
\n
want: %q"
,
estr
,
ewant
)
}
})
}
}
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