mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
fix windows tests
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
parent
1603222bbc
commit
315de4c782
20
block.go
20
block.go
|
@ -269,7 +269,7 @@ type Block struct {
|
||||||
|
|
||||||
// OpenBlock opens the block in the directory. It can be passed a chunk pool, which is used
|
// OpenBlock opens the block in the directory. It can be passed a chunk pool, which is used
|
||||||
// to instantiate chunk structs.
|
// to instantiate chunk structs.
|
||||||
func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (*Block, error) {
|
func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (pb *Block, err error) {
|
||||||
if logger == nil {
|
if logger == nil {
|
||||||
logger = log.NewNopLogger()
|
logger = log.NewNopLogger()
|
||||||
}
|
}
|
||||||
|
@ -282,15 +282,31 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (*Block, error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
cr.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
ir, err := index.NewFileReader(filepath.Join(dir, indexFilename))
|
ir, err := index.NewFileReader(filepath.Join(dir, indexFilename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
ir.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
tr, tsr, err := readTombstones(dir)
|
tr, tsr, err := readTombstones(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
tr.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// TODO refactor to set this at block creation time as
|
// TODO refactor to set this at block creation time as
|
||||||
// that would be the logical place for a block size to be calculated.
|
// that would be the logical place for a block size to be calculated.
|
||||||
|
@ -301,7 +317,7 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (*Block, error
|
||||||
level.Warn(logger).Log("msg", "couldn't write the meta file for the block size", "block", dir, "err", err)
|
level.Warn(logger).Log("msg", "couldn't write the meta file for the block size", "block", dir, "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pb := &Block{
|
pb = &Block{
|
||||||
dir: dir,
|
dir: dir,
|
||||||
meta: *meta,
|
meta: *meta,
|
||||||
chunkr: cr,
|
chunkr: cr,
|
||||||
|
|
6
db.go
6
db.go
|
@ -512,6 +512,12 @@ func (db *DB) reload() (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(corrupted) > 0 {
|
if len(corrupted) > 0 {
|
||||||
|
// Close all new blocks to release the lock for windows.
|
||||||
|
for _, block := range loadable {
|
||||||
|
if _, loaded := db.getBlock(block.Meta().ULID); !loaded {
|
||||||
|
block.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
return fmt.Errorf("unexpected corrupted block:%v", corrupted)
|
return fmt.Errorf("unexpected corrupted block:%v", corrupted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue