mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
Take snapshot only after closing the WAL (#9328)
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
parent
05a816bfb7
commit
30534e99d9
|
@ -1168,12 +1168,12 @@ func (h *Head) Close() error {
|
||||||
defer h.closedMtx.Unlock()
|
defer h.closedMtx.Unlock()
|
||||||
h.closed = true
|
h.closed = true
|
||||||
errs := tsdb_errors.NewMulti(h.chunkDiskMapper.Close())
|
errs := tsdb_errors.NewMulti(h.chunkDiskMapper.Close())
|
||||||
if errs.Err() == nil && h.opts.EnableMemorySnapshotOnShutdown {
|
|
||||||
errs.Add(h.performChunkSnapshot())
|
|
||||||
}
|
|
||||||
if h.wal != nil {
|
if h.wal != nil {
|
||||||
errs.Add(h.wal.Close())
|
errs.Add(h.wal.Close())
|
||||||
}
|
}
|
||||||
|
if errs.Err() == nil && h.opts.EnableMemorySnapshotOnShutdown {
|
||||||
|
errs.Add(h.performChunkSnapshot())
|
||||||
|
}
|
||||||
return errs.Err()
|
return errs.Err()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2659,6 +2659,10 @@ func TestChunkSnapshot(t *testing.T) {
|
||||||
// These references should be the ones used for the snapshot.
|
// These references should be the ones used for the snapshot.
|
||||||
wlast, woffset, err = head.wal.LastSegmentAndOffset()
|
wlast, woffset, err = head.wal.LastSegmentAndOffset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
if woffset != 0 && woffset < 32*1024 {
|
||||||
|
// The page is always filled before taking the snapshot.
|
||||||
|
woffset = 32 * 1024
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Creating snapshot and verifying it.
|
// Creating snapshot and verifying it.
|
||||||
|
@ -2725,6 +2729,10 @@ func TestChunkSnapshot(t *testing.T) {
|
||||||
// Creating another snapshot should delete the older snapshot and replay still works fine.
|
// Creating another snapshot should delete the older snapshot and replay still works fine.
|
||||||
wlast, woffset, err = head.wal.LastSegmentAndOffset()
|
wlast, woffset, err = head.wal.LastSegmentAndOffset()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
if woffset != 0 && woffset < 32*1024 {
|
||||||
|
// The page is always filled before taking the snapshot.
|
||||||
|
woffset = 32 * 1024
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Close Head and verify that new snapshot was created.
|
// Close Head and verify that new snapshot was created.
|
||||||
|
|
Loading…
Reference in a new issue