From fb618cb38524aba77196b2ca646375e14c7be01f Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Fri, 6 Mar 2015 11:31:13 -0800 Subject: [PATCH 1/3] Support control of Raft debug logging --- cmd/influxd/config.go | 1 + cmd/influxd/config_test.go | 1 + cmd/influxd/run.go | 3 +++ etc/config.sample.toml | 1 + messaging/broker.go | 5 +++++ 5 files changed, 11 insertions(+) diff --git a/cmd/influxd/config.go b/cmd/influxd/config.go index 7485dda0294..dbbdbde2bf3 100644 --- a/cmd/influxd/config.go +++ b/cmd/influxd/config.go @@ -98,6 +98,7 @@ type Config struct { Logging struct { File string `toml:"file"` WriteTraceEnabled bool `toml:"write-tracing"` + RaftTraceEnabled bool `toml:"raft-tracing"` } `toml:"logging"` ContinuousQuery struct { diff --git a/cmd/influxd/config_test.go b/cmd/influxd/config_test.go index 4e6b4ac88e2..625114d4ea5 100644 --- a/cmd/influxd/config_test.go +++ b/cmd/influxd/config_test.go @@ -175,6 +175,7 @@ enabled = true [logging] file = "influxdb.log" write-tracing = true +raft-tracing = true # Configure the admin server [admin] diff --git a/cmd/influxd/run.go b/cmd/influxd/run.go index 050a00e81b3..a879da5f7ab 100644 --- a/cmd/influxd/run.go +++ b/cmd/influxd/run.go @@ -53,6 +53,9 @@ func Run(config *Config, join, version string, logWriter *os.File) (*messaging.B // Open broker, initialize or join as necessary. b := openBroker(config.BrokerDir(), config.BrokerURL(), initBroker, joinURLs, logWriter) + // Configure debug of Raft module. + b.EnableRaftDebug(config.Logging.RaftTraceEnabled) + // Start the broker handler. var h *Handler if b != nil { diff --git a/etc/config.sample.toml b/etc/config.sample.toml index 28444afdc32..4b191899774 100644 --- a/etc/config.sample.toml +++ b/etc/config.sample.toml @@ -84,3 +84,4 @@ dir = "/tmp/influxdb/development/state" [logging] file = "/var/log/influxdb/influxd.log" # Leave blank to redirect logs to stderr. write-tracing = false # If true, enables detailed logging of the write system. +raft-tracing = false # If true, enables detailed logging of Raft consensus. diff --git a/messaging/broker.go b/messaging/broker.go index 7a4d11a3866..367d32a7cbe 100644 --- a/messaging/broker.go +++ b/messaging/broker.go @@ -75,6 +75,11 @@ func (b *Broker) SetLogOutput(w io.Writer) { b.log.SetLogOutput(w) } +// EnableRaftDebug controls debugging functionality in the Raft concensus module. +func (b *Broker) EnableRaftDebug(enable bool) { + b.log.DebugEnabled = enable +} + // Open initializes the log. // The broker then must be initialized or join a cluster before it can be used. func (b *Broker) Open(path string, u *url.URL) error { From 24fcdb787bef9d285aa4ed629e707a662e7c90d7 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Fri, 6 Mar 2015 11:34:56 -0800 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05e29b0e1fe..a8eda582fe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - [#1864](https://github.com/influxdb/influxdb/pull/1864): fix race in startStateLoop - [#1753](https://github.com/influxdb/influxdb/pull/1874): Do Not Panic on Missing Dirs +### Features +- [#1875](https://github.com/influxdb/influxdb/pull/1875): Support trace logging of Raft. + ## v0.9.0-rc9 [2015-03-06] ### Bugfixes From d80282994679b271cf8447b2d05230e45fb32734 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sat, 7 Mar 2015 22:55:23 -0800 Subject: [PATCH 3/3] Review feedback --- cmd/influxd/config.go | 6 +++--- cmd/influxd/run.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/influxd/config.go b/cmd/influxd/config.go index dbbdbde2bf3..134b87415fc 100644 --- a/cmd/influxd/config.go +++ b/cmd/influxd/config.go @@ -96,9 +96,9 @@ type Config struct { } `toml:"cluster"` Logging struct { - File string `toml:"file"` - WriteTraceEnabled bool `toml:"write-tracing"` - RaftTraceEnabled bool `toml:"raft-tracing"` + File string `toml:"file"` + WriteTracing bool `toml:"write-tracing"` + RaftTracing bool `toml:"raft-tracing"` } `toml:"logging"` ContinuousQuery struct { diff --git a/cmd/influxd/run.go b/cmd/influxd/run.go index a879da5f7ab..38605968b64 100644 --- a/cmd/influxd/run.go +++ b/cmd/influxd/run.go @@ -54,7 +54,7 @@ func Run(config *Config, join, version string, logWriter *os.File) (*messaging.B b := openBroker(config.BrokerDir(), config.BrokerURL(), initBroker, joinURLs, logWriter) // Configure debug of Raft module. - b.EnableRaftDebug(config.Logging.RaftTraceEnabled) + b.EnableRaftDebug(config.Logging.RaftTracing) // Start the broker handler. var h *Handler @@ -93,7 +93,7 @@ func Run(config *Config, join, version string, logWriter *os.File) (*messaging.B if s != nil { sh := httpd.NewHandler(s, config.Authentication.Enabled, version) sh.SetLogOutput(logWriter) - sh.WriteTrace = config.Logging.WriteTraceEnabled + sh.WriteTrace = config.Logging.WriteTracing if h != nil && config.BrokerAddr() == config.DataAddr() { h.serverHandler = sh @@ -270,7 +270,7 @@ func openServer(config *Config, b *influxdb.Broker, initServer, initBroker, conf // Create and open the server. s := influxdb.NewServer() s.SetLogOutput(w) - s.WriteTrace = config.Logging.WriteTraceEnabled + s.WriteTrace = config.Logging.WriteTracing s.RecomputePreviousN = config.ContinuousQuery.RecomputePreviousN s.RecomputeNoOlderThan = time.Duration(config.ContinuousQuery.RecomputeNoOlderThan) s.ComputeRunsPerInterval = config.ContinuousQuery.ComputeRunsPerInterval