mirror of
https://github.com/prometheus/prometheus
synced 2024-12-25 07:52:28 +00:00
Close Head in DBReadOnly.FlushWAL (#7022)
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
This commit is contained in:
parent
e813f60fd6
commit
e64a149984
@ -294,7 +294,7 @@ func OpenDBReadOnly(dir string, l log.Logger) (*DBReadOnly, error) {
|
||||
// Samples that are in existing blocks will not be written to the new block.
|
||||
// Note that if the read only database is running concurrently with a
|
||||
// writable database then writing the WAL to the database directory can race.
|
||||
func (db *DBReadOnly) FlushWAL(dir string) error {
|
||||
func (db *DBReadOnly) FlushWAL(dir string) (returnErr error) {
|
||||
blockReaders, err := db.Blocks()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "read blocks")
|
||||
@ -311,6 +311,12 @@ func (db *DBReadOnly) FlushWAL(dir string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
var merr tsdb_errors.MultiError
|
||||
merr.Add(returnErr)
|
||||
merr.Add(errors.Wrap(head.Close(), "closing Head"))
|
||||
returnErr = merr.Err()
|
||||
}()
|
||||
// Set the min valid time for the ingested wal samples
|
||||
// to be no lower than the maxt of the last block.
|
||||
if err := head.Init(maxBlockTime); err != nil {
|
||||
|
@ -730,6 +730,11 @@ func (w *WAL) Close() (err error) {
|
||||
return errors.New("wal already closed")
|
||||
}
|
||||
|
||||
if w.segment == nil {
|
||||
w.closed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
// Flush the last page and zero out all its remaining size.
|
||||
// We must not flush an empty page as it would falsely signal
|
||||
// the segment is done if we start writing to it again after opening.
|
||||
|
Loading…
Reference in New Issue
Block a user