Fix loading of persisted blocks
This commit is contained in:
parent
5876a3303c
commit
32c32013a6
7
db.go
7
db.go
|
@ -369,10 +369,7 @@ func (db *DB) reloadBlocks() error {
|
||||||
}
|
}
|
||||||
heads = append(heads, b.(*headBlock))
|
heads = append(heads, b.(*headBlock))
|
||||||
} else {
|
} else {
|
||||||
if ok && meta.ULID != b.Meta().ULID {
|
if !ok || meta.ULID != b.Meta().ULID {
|
||||||
if err := b.Close(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b, err = newPersistedBlock(dirs[i])
|
b, err = newPersistedBlock(dirs[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "open persisted block %s", dirs[i])
|
return errors.Wrapf(err, "open persisted block %s", dirs[i])
|
||||||
|
@ -385,7 +382,7 @@ func (db *DB) reloadBlocks() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for seq, b := range db.seqBlocks {
|
for seq, b := range db.seqBlocks {
|
||||||
if _, ok := seqBlocks[seq]; !ok {
|
if nb, ok := seqBlocks[seq]; !ok || nb != b {
|
||||||
if err := b.Close(); err != nil {
|
if err := b.Close(); err != nil {
|
||||||
return errors.Wrapf(err, "closing removed block %d", b.Meta().Sequence)
|
return errors.Wrapf(err, "closing removed block %d", b.Meta().Sequence)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue