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
2fa12536
Commit
2fa12536
authored
Jul 22, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c2d692af
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
6 deletions
+100
-6
go/zodb/storage/fs1/filestorage.go
go/zodb/storage/fs1/filestorage.go
+75
-3
go/zodb/storage/fs1/fs1tools/reindex.go
go/zodb/storage/fs1/fs1tools/reindex.go
+25
-3
No files found.
go/zodb/storage/fs1/filestorage.go
View file @
2fa12536
...
...
@@ -1046,9 +1046,9 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.IStorageIterator {
return
&
Iter
}
//
ComputeIndex from scratch
builds new in-memory index for FileStorage
//
computeIndex
builds new in-memory index for FileStorage
// XXX naming
func
(
fs
*
FileStorage
)
C
omputeIndex
(
ctx
context
.
Context
)
(
index
*
Index
,
err
error
)
{
func
(
fs
*
FileStorage
)
c
omputeIndex
(
ctx
context
.
Context
)
(
index
*
Index
,
err
error
)
{
// TODO err ctx <file>: <reindex>:
// XXX handle ctx cancel
...
...
@@ -1066,7 +1066,7 @@ func (fs *FileStorage) ComputeIndex(ctx context.Context) (index *Index, err erro
loop
:
for
{
// XXX merge logic in
fot
LoadNext/LoadPrev
// XXX merge logic in
to
LoadNext/LoadPrev
switch
txnh
.
Len
{
case
-
2
:
err
=
txnh
.
Load
(
fsSeq
,
txnh
.
Pos
,
LoadNoStrings
)
...
...
@@ -1104,3 +1104,75 @@ loop:
}
return
index
,
nil
}
// loadIndex loads on-disk index to RAM
func
(
fs
*
FileStorage
)
loadIndex
()
error
{
// XXX lock?
index
,
err
:=
LoadIndexFile
(
fs
.
file
.
Name
()
+
".index"
)
if
err
!=
nil
{
return
err
// XXX err ctx
}
// XXX here?
// TODO verify index sane / topPos matches
if
index
.
TopPos
!=
fs
.
txnhMax
.
Pos
+
fs
.
txnhMax
.
Len
{
panic
(
"inconsistent index topPos"
)
// XXX
}
fs
.
index
=
index
}
// saveIndex flushes in-RAM index to disk
func
(
fs
*
FileStorage
)
saveIndex
()
error
{
// XXX lock?
err
=
fs
.
index
.
SaveFile
(
fs
.
file
.
Name
()
+
".index"
)
return
err
}
// IndexCorruptError is the error returned when index verification fails
// XXX but io errors during verification return not this
type
IndexCorruptError
struct
{
index
*
Index
indexOk
*
Index
}
func
(
e
*
IndexCorruptError
)
Error
()
string
{
// TODO show delta ?
return
"index corrupt"
}
// VerifyIndex verifies that index is correct
func
(
fs
*
FileStorage
)
VerifyIndex
(
ctx
context
.
Context
)
error
{
// XXX lock appends?
// XXX if .index is not yet loaded - load it
indexOk
,
err
:=
fs
.
computeIndex
(
ctx
)
if
err
!=
nil
{
return
err
// XXX err ctx
}
if
!
indexOk
.
Equal
(
fs
.
index
)
{
err
=
&
ErrIndexCorrupt
{
index
:
fs
.
index
,
indexOk
:
indexOk
}
}
return
err
}
// Reindex rebuilds the index
func
(
fs
*
FileStorage
)
Reindex
(
ctx
context
.
Context
)
error
{
// XXX lock appends?
index
,
err
:=
fs
.
computeIndex
(
ctx
)
if
err
!=
nil
{
return
err
}
fs
.
index
=
index
err
=
fs
.
saveIndex
()
return
err
// XXX ok?
}
go/zodb/storage/fs1/fs1tools/reindex.go
View file @
2fa12536
...
...
@@ -27,10 +27,32 @@ import (
"log"
)
//
XXX text
//
Reindex rebuilds index for FileStorage file @ path
func
Reindex
(
path
string
)
error
{
// TODO
return
nil
// XXX open read-only
fs
,
err
:=
fs1
.
Open
(
contex
.
Background
(),
path
,
fs1
.
OpenWithoutIndex
)
if
err
!=
nil
{
return
nil
// XXX err ctx
}
defer
fs
.
Close
()
// XXX err
err
=
fs
.
Reindex
()
return
err
// XXX ok?
}
// VerifyIndexFor verifies that on-disk index for FileStorage file @ path is correct
func
VerifyIndexFor
(
path
string
)
error
{
// XXX open read-only
fs
,
err
:=
fs1
.
Open
(
contex
.
Background
(),
path
,
0
)
if
err
!=
nil
{
return
nil
// XXX err ctx
}
defer
fs
.
Close
()
// XXX err
err
=
fs
.
VerifyIndex
()
return
err
//fs.Index()
//fs.ComputeIndex
}
// ----------------------------------------
...
...
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