1
0
Fork 0

Merge pull request #149 from rqlite/config_raft

Support configurable snapshot thresholds
master
Philip O'Toole 8 years ago
commit 63966d207a

@ -1,4 +1,5 @@
## 3.3.0 (unreleased) ## 3.3.0 (unreleased)
- [PR #149](https://github.com/rqlite/rqlite/pull/149): Support configurable Raft snapshot thresholds.
- [PR #148](https://github.com/rqlite/rqlite/pull/148): Support pprof information over HTTP. - [PR #148](https://github.com/rqlite/rqlite/pull/148): Support pprof information over HTTP.
## 3.2.1 (May 22nd 2016) ## 3.2.1 (May 22nd 2016)

@ -77,6 +77,7 @@ var pprofEnabled bool
var dsn string var dsn string
var onDisk bool var onDisk bool
var noVerifySelect bool var noVerifySelect bool
var raftSnapThreshold uint64
var showVersion bool var showVersion bool
var cpuprofile string var cpuprofile string
@ -98,6 +99,7 @@ func init() {
flag.BoolVar(&onDisk, "ondisk", false, "Use an on-disk SQLite database") flag.BoolVar(&onDisk, "ondisk", false, "Use an on-disk SQLite database")
flag.BoolVar(&noVerifySelect, "nosel", false, "Don't verify that all queries begin with SELECT") flag.BoolVar(&noVerifySelect, "nosel", false, "Don't verify that all queries begin with SELECT")
flag.BoolVar(&showVersion, "version", false, "Show version information and exit") flag.BoolVar(&showVersion, "version", false, "Show version information and exit")
flag.Uint64Var(&raftSnapThreshold, "raftsnap", 8192, "Number of outstanding log entries to trigger snapshot")
flag.StringVar(&cpuprofile, "cpuprofile", "", "Write CPU profile to file") flag.StringVar(&cpuprofile, "cpuprofile", "", "Write CPU profile to file")
flag.Usage = func() { flag.Usage = func() {
fmt.Fprintf(os.Stderr, "\n%s\n\n", desc) fmt.Fprintf(os.Stderr, "\n%s\n\n", desc)
@ -186,6 +188,7 @@ func main() {
if err := store.Open(joinAddr == ""); err != nil { if err := store.Open(joinAddr == ""); err != nil {
log.Fatalf("failed to open store: %s", err.Error()) log.Fatalf("failed to open store: %s", err.Error())
} }
store.SnapshotThreshold = raftSnapThreshold
// Create and configure cluster service. // Create and configure cluster service.
tn := mux.Listen(muxMetaHeader) tn := mux.Listen(muxMetaHeader)

@ -28,4 +28,4 @@ The diagram below shows a high-level view of a rqlite node.
└───────────────────────────────────────────────┘ └───────────────────────────────────────────────┘
## Log Compaction ## Log Compaction
rqlite automatically performs log compaction. After a fixed number of changes rqlite snapshots the SQLite database, and truncates the Raft log. This is a technical feature of the Raft consensus system, and most users of rqlite need not be concerned with this. rqlite automatically performs log compaction. After a configurable number of changes rqlite snapshots the SQLite database, and truncates the Raft log. This is a technical feature of the Raft consensus system, and most users of rqlite need not be concerned with this.

@ -163,6 +163,8 @@ type Store struct {
meta *clusterMeta meta *clusterMeta
logger *log.Logger logger *log.Logger
SnapshotThreshold uint64
} }
// New returns a new Store. // New returns a new Store.
@ -208,6 +210,9 @@ func (s *Store) Open(enableSingle bool) error {
// Setup Raft configuration. // Setup Raft configuration.
config := raft.DefaultConfig() config := raft.DefaultConfig()
if s.SnapshotThreshold != 0 {
config.SnapshotThreshold = s.SnapshotThreshold
}
// Check for any existing peers. // Check for any existing peers.
peers, err := readPeersJSON(filepath.Join(s.raftDir, "peers.json")) peers, err := readPeersJSON(filepath.Join(s.raftDir, "peers.json"))

Loading…
Cancel
Save