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
d1054012
Commit
d1054012
authored
Jul 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2ef35dde
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
17 deletions
+45
-17
go/zodb/storage/fs1/fs1tools/index.go
go/zodb/storage/fs1/fs1tools/index.go
+1
-2
go/zodb/storage/fs1/fs1tools/main.go
go/zodb/storage/fs1/fs1tools/main.go
+1
-1
go/zodb/storage/fs1/index.go
go/zodb/storage/fs1/index.go
+43
-14
No files found.
go/zodb/storage/fs1/fs1tools/index.go
View file @
d1054012
...
...
@@ -81,7 +81,6 @@ func reindexMain(argv []string) {
// ----------------------------------------
// TODO verify-index
// TODO verify-index -quick (only small sanity check)
// VerifyIndexFor verifies that on-disk index for FileStorage file @ path is correct
...
...
@@ -108,6 +107,6 @@ func verifyIdxUsage(w io.Writer) {
panic
(
"TODO"
)
// XXX
}
func
verifyIdxMa
x
in
(
argv
[]
string
)
{
func
verifyIdxMain
(
argv
[]
string
)
{
panic
(
"TODO"
)
// XXX
}
go/zodb/storage/fs1/fs1tools/main.go
View file @
d1054012
...
...
@@ -28,7 +28,7 @@ var commands = zodbtools.CommandRegistry{
// + fsstats? (fsstats.py)
{
"reindex"
,
reindexSummary
,
reindexUsage
,
reindexMain
},
{
"verify-index"
,
verifyIdxSummary
,
verifyIdxUsage
,
verifyIdxMa
x
in
},
{
"verify-index"
,
verifyIdxSummary
,
verifyIdxUsage
,
verifyIdxMain
},
// recover (fsrecover.py)
// verify (fstest.py)
...
...
go/zodb/storage/fs1/index.go
View file @
d1054012
...
...
@@ -411,7 +411,7 @@ func treeEqual(a, b *fsb.Tree) bool {
return
true
}
// --- build
/verify
index from FileStorage data ---
// --- build index from FileStorage data ---
// Update updates in-memory index from r's FileStorage data in byte-range index.TopPos..topPos
//
...
...
@@ -536,21 +536,46 @@ func BuildIndexForFile(ctx context.Context, path string) (index *Index, err erro
return
BuildIndex
(
ctx
,
fSeq
)
}
// VerifyNTxn checks index correctness against several transactions of FileStorage data in r.
// --- verify index against data in FileStorage ---
// IndexCorrupyError is the error type returned by index verification routines
// when index was found to not match original FileStorage data.
type
IndexCorruptError
struct
{
DataFileName
string
Detail
string
}
func
(
e
*
IndexCorruptError
)
Error
()
string
{
return
fmt
.
Sprintf
(
"%s: verify index: %s"
,
e
.
DataFileName
,
e
.
Detail
)
}
func
indexCorrupt
(
r
io
.
ReaderAt
,
format
string
,
argv
...
interface
{})
*
IndexCorruptError
{
return
&
IndexCorruptError
{
DataFileName
:
xio
.
Name
(
r
),
Detail
:
fmt
.
Sprintf
(
format
,
argv
...
)}
}
// VerifyTail checks index correctness against several newest transactions of FileStorage data in r.
//
// For ntxn transactions starting from index.TopPos backwards it verifies
// For ntxn transactions starting from index.TopPos backwards
,
it verifies
// whether oid there have correct entries in the index.
//
// XXX return: ? (how calling code should distinguish IO error on main file from consistency check error)
// XXX naming?
func
(
index
*
Index
)
VerifyNTxn
(
ctx
context
.
Context
,
r
io
.
ReaderAt
,
ntxn
int
)
(
oidChecked
map
[
zodb
.
Oid
]
struct
{},
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"index quick check"
)
// XXX +main file
it
:=
Iterate
(
r
,
index
.
TopPos
,
IterBackward
)
// ntxn=-1 means data range to verify is till start of the file.
//
// Returned error is either:
// - of type *IndexCorruptError, when data in index was found not to match original data, or
// - any other error type representing e.g. IO error when reading original data or something else.
func
(
index
*
Index
)
VerifyTail
(
ctx
context
.
Context
,
r
io
.
ReaderAt
,
ntxn
int
)
(
oidChecked
map
[
zodb
.
Oid
]
struct
{},
err
error
)
{
defer
func
()
{
if
_
,
ok
:=
err
.
(
*
IndexCorruptError
);
ok
{
return
// leave it as is
}
xerr
.
Contextf
(
&
err
,
"%s: verify index @%v~{%v}"
,
xio
.
Name
(
r
),
index
.
TopPos
,
ntxn
)
}()
oidChecked
=
map
[
zodb
.
Oid
]
struct
{}{}
// Set<zodb.Oid>
// XXX ntxn=-1 - check all
for
i
:=
0
;
i
<
ntxn
;
i
++
{
it
:=
Iterate
(
r
,
index
.
TopPos
,
IterBackward
)
for
i
:=
0
;
ntxn
==
-
1
||
i
<
ntxn
;
i
++
{
// check ctx cancel once per transaction
select
{
case
<-
ctx
.
Done
()
:
...
...
@@ -582,11 +607,13 @@ func (index *Index) VerifyNTxn(ctx context.Context, r io.ReaderAt, ntxn int) (oi
dataPos
,
ok
:=
index
.
Get
(
it
.
Datah
.
Oid
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"oid %v @%v: no index entry"
,
it
.
Datah
.
Oid
,
it
.
Datah
.
Pos
)
return
nil
,
indexCorrupt
(
r
,
"oid %v @%v: no index entry"
,
it
.
Datah
.
Oid
,
it
.
Datah
.
Pos
)
}
if
dataPos
!=
it
.
Datah
.
Pos
{
return
nil
,
fmt
.
Errorf
(
"oid %v @%v: index has wrong pos (%v)"
,
it
.
Datah
.
Oid
,
it
.
Datah
.
Pos
,
dataPos
)
return
nil
,
indexCorrupt
(
r
,
"oid %v @%v: index has wrong pos (%v)"
,
it
.
Datah
.
Oid
,
it
.
Datah
.
Pos
,
dataPos
)
}
}
}
...
...
@@ -599,8 +626,10 @@ func (index *Index) VerifyNTxn(ctx context.Context, r io.ReaderAt, ntxn int) (oi
//
// it verifies whether index is exactly the same as if it was build anew for
// data in range ..index.TopPos .
//
// See VerifyTail for description about errors returned.
func
(
index
*
Index
)
Verify
(
ctx
context
.
Context
,
r
io
.
ReaderAt
)
error
{
oidChecked
,
err
:=
index
.
Verify
NTxn
(
ctx
,
r
,
-
1
)
oidChecked
,
err
:=
index
.
Verify
Tail
(
ctx
,
r
,
-
1
)
if
err
!=
nil
{
return
err
}
...
...
@@ -621,7 +650,7 @@ func (index *Index) Verify(ctx context.Context, r io.ReaderAt) error {
}
if
_
,
ok
:=
oidChecked
[
oid
];
!
ok
{
return
fmt
.
Errorf
(
"oid %v @%v: present in index but not in data"
,
oid
,
pos
)
return
indexCorrupt
(
r
,
"oid %v @%v: present in index but not in data"
,
oid
,
pos
)
}
}
...
...
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