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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
cd186bf8
Commit
cd186bf8
authored
Nov 09, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X fs1: switch error/EOF from (0, -1) -> (-1, 0)
parent
23870baf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
20 deletions
+20
-20
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+2
-2
go/zodb/storage/fs1/format.go
go/zodb/storage/fs1/format.go
+16
-16
go/zodb/storage/fs1/py/gen-testdata
go/zodb/storage/fs1/py/gen-testdata
+1
-1
go/zodb/storage/fs1/ztestdata_expect_test.go
go/zodb/storage/fs1/ztestdata_expect_test.go
+1
-1
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
cd186bf8
...
...
@@ -476,9 +476,9 @@ func open(path string) (_ *FileStorage, err error) {
// .LenPrev must be good or EOF backward
switch
fs
.
txnhMax
.
LenPrev
{
case
0
:
return
nil
,
fmt
.
Errorf
(
"%s: could not read LenPrev @%d (last transaction)"
,
f
.
Name
(),
fs
.
txnhMax
.
Pos
)
case
-
1
:
return
nil
,
fmt
.
Errorf
(
"%s: could not read LenPrev @%d (last transaction)"
,
f
.
Name
(),
fs
.
txnhMax
.
Pos
)
case
0
:
// ok - EOF backward
default
:
...
...
go/zodb/storage/fs1/format.go
View file @
cd186bf8
...
...
@@ -210,13 +210,13 @@ const (
//
// Rules for .Len/.LenPrev returns:
//
// .Len =
= 0
transaction header could not be read
// .Len =
= -1
EOF forward
// .Len >
= TxnHeaderFixSize
transaction was read normally
// .Len =
-1
transaction header could not be read
// .Len =
0
EOF forward
// .Len >
0
transaction was read normally
//
// .LenPrev =
= 0
prev record length could not be read
// .LenPrev =
= -1
EOF backward
// .LenPrev >
= TxnHeaderFixSize
LenPrev was read/checked normally
// .LenPrev =
-1
prev record length could not be read
// .LenPrev =
0
EOF backward
// .LenPrev >
0
LenPrev was read/checked normally
//
// For example when pos points to the end of file .Len will be returned = -1, but
// .LenPrev will be usually valid if file has at least 1 transaction.
...
...
@@ -227,8 +227,8 @@ func (txnh *TxnHeader) Load(r io.ReaderAt, pos int64, flags TxnLoadFlags) error
work
:=
txnh
.
workMem
[
:
txnXHeaderFixSize
]
txnh
.
Pos
=
pos
txnh
.
Len
=
0
// read error
txnh
.
LenPrev
=
0
// read error
txnh
.
Len
=
-
1
// read error
txnh
.
LenPrev
=
-
1
// read error
if
pos
<
txnValidFrom
{
bug
(
r
,
txnh
,
"Load() on invalid position"
)
...
...
@@ -258,13 +258,13 @@ func (txnh *TxnHeader) Load(r io.ReaderAt, pos int64, flags TxnLoadFlags) error
}
else
{
// read only current txn without previous record length
n
,
err
=
r
.
ReadAt
(
work
[
8
:
],
pos
)
txnh
.
LenPrev
=
-
1
// EOF backward
txnh
.
LenPrev
=
0
// EOF backward
}
if
err
!=
nil
{
if
err
==
io
.
EOF
&&
n
==
0
{
txnh
.
Len
=
-
1
// EOF forward
txnh
.
Len
=
0
// EOF forward
return
err
// end of stream
}
...
...
@@ -354,9 +354,9 @@ func (txnh *TxnHeader) loadStrings(r io.ReaderAt) error {
func
(
txnh
*
TxnHeader
)
LoadPrev
(
r
io
.
ReaderAt
,
flags
TxnLoadFlags
)
error
{
lenPrev
:=
txnh
.
LenPrev
switch
lenPrev
{
case
0
:
bug
(
r
,
txnh
,
"LoadPrev() when .LenPrev == error"
)
case
-
1
:
bug
(
r
,
txnh
,
"LoadPrev() when .LenPrev == error"
)
case
0
:
return
io
.
EOF
case
lenIterStart
:
...
...
@@ -364,7 +364,7 @@ func (txnh *TxnHeader) LoadPrev(r io.ReaderAt, flags TxnLoadFlags) error {
// read LenPrev @pos, then tail to LoadPrev
pos
:=
txnh
.
Pos
err
:=
txnh
.
Load
(
r
,
pos
,
flags
)
if
txnh
.
LenPrev
==
0
{
if
txnh
.
LenPrev
==
-
1
{
if
err
==
nil
{
panic
(
"nil err with txnh.LenPrev = error"
)
}
...
...
@@ -406,9 +406,9 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
lenCur
:=
txnh
.
Len
posCur
:=
txnh
.
Pos
switch
lenCur
{
case
0
:
bug
(
r
,
txnh
,
"LoadNext() when .Len == error"
)
case
-
1
:
bug
(
r
,
txnh
,
"LoadNext() when .Len == error"
)
case
0
:
return
io
.
EOF
case
lenIterStart
:
...
...
@@ -423,7 +423,7 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
// before checking loading error for next txn, let's first check redundant length
// NOTE also: err could be EOF
if
txnh
.
LenPrev
!
=
0
&&
txnh
.
LenPrev
!=
lenCur
{
if
txnh
.
LenPrev
>
=
0
&&
txnh
.
LenPrev
!=
lenCur
{
t
:=
&
TxnHeader
{
Pos
:
posCur
}
// txn for which we discovered problem
return
checkErr
(
r
,
t
,
"head/tail lengths mismatch: %v, %v"
,
lenCur
,
txnh
.
LenPrev
)
}
...
...
go/zodb/storage/fs1/py/gen-testdata
View file @
cd186bf8
...
...
@@ -59,7 +59,7 @@ def main():
# database records
emit
(
"
\
n
var _1fs_dbEntryv = [...]dbEntry{"
)
txnLenPrev
=
-
1
txnLenPrev
=
0
for
txn
in
stor
.
iterator
():
# txn is TransactionRecord
# txn.extension is already depickled dict - we want to put raw data from file
# also we need to access txn record length which is not provided by higher-level iterator
...
...
go/zodb/storage/fs1/ztestdata_expect_test.go
View file @
cd186bf8
...
...
@@ -21,7 +21,7 @@ var _1fs_dbEntryv = [...]dbEntry{
{
TxnHeader
{
Pos
:
4
,
LenPrev
:
-
1
,
LenPrev
:
0
,
Len
:
159
,
TxnInfo
:
zodb
.
TxnInfo
{
Tid
:
0x0285cbac258bf266
,
...
...
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