From 2982058a81bf5821dcab814d882d29d3afa3e94c Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sun, 29 May 2016 14:02:49 -0700 Subject: [PATCH] Support setting Raft heartbeat timeout --- CHANGELOG.md | 1 + cmd/rqlited/main.go | 6 ++++++ store/store.go | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b6bccc4..21d90ff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## 3.3.0 (unreleased) +- [PR #151](https://github.com/rqlite/rqlite/pull/151): Support configurable Raft heartbeat timeout. - [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. diff --git a/cmd/rqlited/main.go b/cmd/rqlited/main.go index 9fae7da8..c69ce7dc 100644 --- a/cmd/rqlited/main.go +++ b/cmd/rqlited/main.go @@ -78,6 +78,7 @@ var dsn string var onDisk bool var noVerifySelect bool var raftSnapThreshold uint64 +var raftHeartbeatTimeout string var showVersion bool var cpuprofile string @@ -99,6 +100,7 @@ func init() { 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(&showVersion, "version", false, "Show version information and exit") + flag.StringVar(&raftHeartbeatTimeout, "rafttimeout", "1s", "Raft heartbeat timeout") flag.Uint64Var(&raftSnapThreshold, "raftsnap", 8192, "Number of outstanding log entries to trigger snapshot") flag.StringVar(&cpuprofile, "cpuprofile", "", "Write CPU profile to file") flag.Usage = func() { @@ -189,6 +191,10 @@ func main() { log.Fatalf("failed to open store: %s", err.Error()) } store.SnapshotThreshold = raftSnapThreshold + store.HeartbeatTimeout, err = time.ParseDuration(raftHeartbeatTimeout) + if err != nil { + log.Fatalf("failed to parse Raft heartbeat timeout %s: %s", raftHeartbeatTimeout, err.Error()) + } // Create and configure cluster service. tn := mux.Listen(muxMetaHeader) diff --git a/store/store.go b/store/store.go index c266d429..aaeb6fca 100644 --- a/store/store.go +++ b/store/store.go @@ -165,6 +165,7 @@ type Store struct { logger *log.Logger SnapshotThreshold uint64 + HeartbeatTimeout time.Duration } // New returns a new Store. @@ -213,6 +214,9 @@ func (s *Store) Open(enableSingle bool) error { if s.SnapshotThreshold != 0 { config.SnapshotThreshold = s.SnapshotThreshold } + if s.HeartbeatTimeout != 0 { + config.HeartbeatTimeout = s.HeartbeatTimeout + } // Check for any existing peers. peers, err := readPeersJSON(filepath.Join(s.raftDir, "peers.json"))