|
|
@ -3,6 +3,7 @@ package snapshot
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"expvar"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
@ -19,6 +20,11 @@ import (
|
|
|
|
"github.com/rqlite/rqlite/db"
|
|
|
|
"github.com/rqlite/rqlite/db"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
|
|
stats = expvar.NewMap("snapshot")
|
|
|
|
|
|
|
|
ResetStats()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
|
minSnapshotRetain = 2
|
|
|
|
minSnapshotRetain = 2
|
|
|
|
|
|
|
|
|
|
|
@ -32,6 +38,10 @@ const (
|
|
|
|
tmpSuffix = ".tmp"
|
|
|
|
tmpSuffix = ".tmp"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
persistSize = "persist_size"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
// ErrRetainCountTooLow is returned when the retain count is too low.
|
|
|
|
// ErrRetainCountTooLow is returned when the retain count is too low.
|
|
|
|
ErrRetainCountTooLow = errors.New("retain count must be >= 2")
|
|
|
|
ErrRetainCountTooLow = errors.New("retain count must be >= 2")
|
|
|
@ -43,6 +53,15 @@ var (
|
|
|
|
ErrSnapshotBaseMissing = errors.New("snapshot base SQLite file missing")
|
|
|
|
ErrSnapshotBaseMissing = errors.New("snapshot base SQLite file missing")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// stats captures stats for the Store.
|
|
|
|
|
|
|
|
var stats *expvar.Map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ResetStats resets the expvar stats for this module. Mostly for test purposes.
|
|
|
|
|
|
|
|
func ResetStats() {
|
|
|
|
|
|
|
|
stats.Init()
|
|
|
|
|
|
|
|
stats.Add(persistSize, 0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Meta represents the metadata for a snapshot.
|
|
|
|
// Meta represents the metadata for a snapshot.
|
|
|
|
type Meta struct {
|
|
|
|
type Meta struct {
|
|
|
|
raft.SnapshotMeta
|
|
|
|
raft.SnapshotMeta
|
|
|
|