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
eae40f9e
Commit
eae40f9e
authored
Jul 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f53dc308
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
40 deletions
+35
-40
go/zodb/storage/fs1/fs1tools/index.go
go/zodb/storage/fs1/fs1tools/index.go
+35
-40
No files found.
go/zodb/storage/fs1/fs1tools/index.go
View file @
eae40f9e
...
@@ -73,7 +73,7 @@ func reindexMain(argv []string) {
...
@@ -73,7 +73,7 @@ func reindexMain(argv []string) {
}
}
storPath
:=
argv
[
0
]
storPath
:=
argv
[
0
]
err
:=
Reindex
(
storPath
)
err
:=
Reindex
(
context
.
Background
(),
storPath
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
...
@@ -81,58 +81,53 @@ func reindexMain(argv []string) {
...
@@ -81,58 +81,53 @@ func reindexMain(argv []string) {
// ----------------------------------------
// ----------------------------------------
// TODO verify-index -quick (only small sanity check)
// VerifyIndexFor verifies that on-disk index for FileStorage file @ path is correct
// VerifyIndexFor verifies that on-disk index for FileStorage file @ path is correct
func
VerifyIndexFor
(
ctx
context
.
Context
,
path
string
)
(
err
error
)
{
func
VerifyIndexFor
(
ctx
context
.
Context
,
path
string
)
(
err
error
)
{
// XXX lock path.lock ?
// XXX lock path.lock ?
inverify
:=
false
index
,
err
:=
fs1
.
LoadIndexFile
(
path
+
".index"
)
defer
func
()
{
if
inverify
{
return
// index.Verify provides all context in error
}
xerr
.
Contextf
(
&
err
,
"%s: verify index"
,
path
)
}
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
return
err
}
defer
func
()
{
err2
:=
f
.
Close
()
// XXX vs inverify
err
=
xerr
.
First
(
err
,
err2
)
}()
index
,
err
:=
LoadIndexFile
(
path
+
".index"
)
if
err
!=
nil
{
return
err
}
fi
,
err
:=
f
.
Stat
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
// XXX err ctx
}
topPos
:=
fi
.
Size
()
// XXX there might be last TxnInprogress transaction
if
index
.
TopPos
!=
topPos
{
return
fmt
.
Errorf
(
"topPos mismatch: data=%v index=%v"
,
topPos
,
index
.
TopPos
)
}
}
// XXX - better somehow not here?
err
=
index
.
VerifyForFile
(
context
.
Background
(),
path
)
fSeq
:=
xbufio
.
NewSeqReaderAt
(
f
)
inverify
=
true
err
=
index
.
Verify
(
ctx
,
fSeq
)
return
err
return
err
}
}
const
verifyIdxSummary
=
"verify database index"
const
verifyIdxSummary
=
"verify database index"
func
verifyIdxUsage
(
w
io
.
Writer
)
{
func
verifyIdxUsage
(
w
io
.
Writer
)
{
panic
(
"TODO"
)
// XXX
fmt
.
Fprintf
(
w
,
`Usage: fs1 verify-index [options] <storage>
Verify FileStorage index
<storage> is a path to FileStorage
options:
XXX leave quickcheck without <n> (10 by default)
XXX + -quick-limit
-quickcheck <n> only quickly check consistency by verifying against 10
last transactions.
-h --help this help text.
`
)
}
}
func
verifyIdxMain
(
argv
[]
string
)
{
func
verifyIdxMain
(
argv
[]
string
)
{
panic
(
"TODO"
)
// XXX
ntxn
:=
-
1
flags
:=
flag
.
FlagSet
{
Usage
:
func
()
{
verifyIdxUsage
(
os
.
Stderr
)
}}
flags
.
Init
(
""
,
flag
.
ExitOnError
)
flags
.
IntVar
(
&
ntxn
,
"quickcheck"
,
ntxn
,
"check consistency only wrt last <n> transactions"
)
flags
.
Parse
(
argv
[
1
:
])
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
err
:=
VerifyIndexFor
(
context
.
Background
(),
storPath
)
if
err
!=
nil
{
log
.
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