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
24ab091c
Commit
24ab091c
authored
May 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
48b8fcaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
4 deletions
+46
-4
go/zodb/storage/fs1/fs1tools/verify.go
go/zodb/storage/fs1/fs1tools/verify.go
+46
-4
No files found.
go/zodb/storage/fs1/fs1tools/verify.go
View file @
24ab091c
...
...
@@ -28,6 +28,7 @@ import (
"fmt"
"io"
"os"
"time"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1"
...
...
@@ -40,10 +41,38 @@ import (
//
// Only data part of the data base is verified (the *.fs file). Use
// VerifyIndexFor to verify the index part (*.fs.index).
func
Verify
(
w
io
.
Writer
,
path
string
,
verbose
int
)
(
err
error
)
{
func
Verify
(
w
io
.
Writer
,
path
string
,
verbose
int
,
progress
bool
)
(
err
error
)
{
// just iterate through the file and emit progress.
// the FileStorage driver implements all consistency checks by itself.
fi
,
err
:=
os
.
Stat
(
path
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"verify: %s: %s"
,
path
,
err
)
}
fsize
:=
fi
.
Size
()
v
:=
&
Verifier
{
verbose
:
verbose
}
// display progress updates once per tick
if
progress
{
tick
:=
time
.
NewTicker
(
time
.
Second
/
4
)
defer
tick
.
Stop
()
v
.
progress
=
func
(
pos
int64
)
error
{
select
{
case
<-
tick
.
C
:
default
:
return
nil
}
_
,
err
:=
fmt
.
Fprintf
(
w
,
"
\r
Verified data bytes: %.1f%% (%d/%d); #txn: %d"
,
100
*
float64
(
pos
)
/
float64
(
fsize
),
pos
,
fsize
,
v
.
ntxn
)
return
err
}
}
return
Dump
(
w
,
path
,
fs1
.
IterForward
,
v
)
}
...
...
@@ -54,6 +83,8 @@ type Verifier struct {
// for loading data
dhLoading
fs1
.
DataHeader
progress
func
(
pos
int64
)
error
}
func
(
v
*
Verifier
)
DumperName
()
string
{
...
...
@@ -86,17 +117,25 @@ func (v *Verifier) DumpTxn(buf *xfmt.Buffer, it *fs1.Iter) error {
}
if
v
.
verbose
>=
2
{
buf
.
S
(
fmt
.
Sprintf
(
"%10d: object oid %s #%d
\n
"
,
dh
.
Pos
,
dh
.
Oid
,
i
))
buf
.
S
(
fmt
.
Sprintf
(
"%10d: object oid
0x
%s #%d
\n
"
,
dh
.
Pos
,
dh
.
Oid
,
i
))
}
dbuf
.
Release
()
}
if
v
.
verbose
>=
1
{
buf
.
S
(
fmt
.
Sprintf
(
"%10d: transaction tid %s #%d
\n
"
,
txnh
.
Pos
,
txnh
.
Tid
,
v
.
ntxn
))
buf
.
S
(
fmt
.
Sprintf
(
"%10d: transaction tid
0x
%s #%d
\n
"
,
txnh
.
Pos
,
txnh
.
Tid
,
v
.
ntxn
))
}
v
.
ntxn
++
if
v
.
progress
!=
nil
{
err
:=
v
.
progress
(
txnh
.
Pos
)
if
err
!=
nil
{
return
err
}
}
return
nil
}
...
...
@@ -122,14 +161,17 @@ Dump transactions from a FileStorage XXX
-h --help this help text.
-v increase verbosity.
-p display total progress.
`
)
}
func
verifyMain
(
argv
[]
string
)
{
verbose
:=
0
var
progress
bool
flags
:=
flag
.
FlagSet
{
Usage
:
func
()
{
verifyUsage
(
os
.
Stderr
)
}}
flags
.
Init
(
""
,
flag
.
ExitOnError
)
flags
.
Var
((
*
xflag
.
Count
)(
&
verbose
),
"v"
,
"verbosity level"
)
flags
.
BoolVar
(
&
progress
,
"p"
,
false
,
"display total progress"
)
flags
.
Parse
(
argv
[
1
:
])
argv
=
flags
.
Args
()
...
...
@@ -139,7 +181,7 @@ func verifyMain(argv []string) {
}
storPath
:=
argv
[
0
]
err
:=
Verify
(
os
.
Stdout
,
storPath
,
verbose
)
err
:=
Verify
(
os
.
Stdout
,
storPath
,
verbose
,
progress
)
if
err
!=
nil
{
prog
.
Fatal
(
err
)
}
...
...
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