From 30fd0d25a57c87b82fc96584d3db905d916e63ea Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Thu, 24 Aug 2017 16:44:05 -0500 Subject: [PATCH] Update raft library for windows snapshot fsync fixes. This fixes #3409 --- vendor/github.com/hashicorp/raft/Makefile | 7 ++++-- .../hashicorp/raft/file_snapshot.go | 22 ++++++++++--------- vendor/github.com/hashicorp/raft/observer.go | 10 +++++---- vendor/github.com/hashicorp/raft/state.go | 4 ++++ vendor/vendor.json | 2 +- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/vendor/github.com/hashicorp/raft/Makefile b/vendor/github.com/hashicorp/raft/Makefile index 0910e2ceb2..75d947f13d 100644 --- a/vendor/github.com/hashicorp/raft/Makefile +++ b/vendor/github.com/hashicorp/raft/Makefile @@ -1,11 +1,14 @@ DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) test: - go test -timeout=60s ./... + go test -timeout=60s . integ: test - INTEG_TESTS=yes go test -timeout=25s -run=Integ ./... + INTEG_TESTS=yes go test -timeout=25s -run=Integ . +fuzz: + go test -timeout=300s ./fuzzy + deps: go get -d -v ./... echo $(DEPS) | xargs -n1 go get -d diff --git a/vendor/github.com/hashicorp/raft/file_snapshot.go b/vendor/github.com/hashicorp/raft/file_snapshot.go index 119bfd308d..ffc9414542 100644 --- a/vendor/github.com/hashicorp/raft/file_snapshot.go +++ b/vendor/github.com/hashicorp/raft/file_snapshot.go @@ -12,6 +12,7 @@ import ( "log" "os" "path/filepath" + "runtime" "sort" "strings" "time" @@ -406,17 +407,18 @@ func (s *FileSnapshotSink) Close() error { return err } - // fsync the parent directory, to sync directory edits to disk - parentFH, err := os.Open(s.parentDir) - defer parentFH.Close() - if err != nil { - s.logger.Printf("[ERR] snapshot: Failed to open snapshot parent directory %v, error: %v", s.parentDir, err) - return err - } + if runtime.GOOS != "windows" { //skipping fsync for directory entry edits on Windows, only needed for *nix style file systems + parentFH, err := os.Open(s.parentDir) + defer parentFH.Close() + if err != nil { + s.logger.Printf("[ERR] snapshot: Failed to open snapshot parent directory %v, error: %v", s.parentDir, err) + return err + } - if err = parentFH.Sync(); err != nil { - s.logger.Printf("[ERR] snapshot: Failed syncing parent directory %v, error: %v", s.parentDir, err) - return err + if err = parentFH.Sync(); err != nil { + s.logger.Printf("[ERR] snapshot: Failed syncing parent directory %v, error: %v", s.parentDir, err) + return err + } } // Reap any old snapshots diff --git a/vendor/github.com/hashicorp/raft/observer.go b/vendor/github.com/hashicorp/raft/observer.go index 22500fa875..76c4d555df 100644 --- a/vendor/github.com/hashicorp/raft/observer.go +++ b/vendor/github.com/hashicorp/raft/observer.go @@ -24,6 +24,12 @@ type FilterFn func(o *Observation) bool // Observer describes what to do with a given observation. type Observer struct { + // numObserved and numDropped are performance counters for this observer. + // 64 bit types must be 64 bit aligned to use with atomic operations on + // 32 bit platforms, so keep them at the top of the struct. + numObserved uint64 + numDropped uint64 + // channel receives observations. channel chan Observation @@ -37,10 +43,6 @@ type Observer struct { // id is the ID of this observer in the Raft map. id uint64 - - // numObserved and numDropped are performance counters for this observer. - numObserved uint64 - numDropped uint64 } // NewObserver creates a new observer that can be registered diff --git a/vendor/github.com/hashicorp/raft/state.go b/vendor/github.com/hashicorp/raft/state.go index f6d658b8bb..a58cd0d19e 100644 --- a/vendor/github.com/hashicorp/raft/state.go +++ b/vendor/github.com/hashicorp/raft/state.go @@ -42,6 +42,10 @@ func (s RaftState) String() string { // and provides an interface to set/get the variables in a // thread safe manner. type raftState struct { + // currentTerm commitIndex, lastApplied, must be kept at the top of + // the struct so they're 64 bit aligned which is a requirement for + // atomic ops on 32 bit platforms. + // The current term, cache of StableStore currentTerm uint64 diff --git a/vendor/vendor.json b/vendor/vendor.json index ce6369cd22..b8d7f744ce 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -57,7 +57,7 @@ {"checksumSHA1":"vt+P9D2yWDO3gdvdgCzwqunlhxU=","path":"github.com/hashicorp/logutils","revision":"0dc08b1671f34c4250ce212759ebd880f743d883","revisionTime":"2015-06-09T07:04:31Z"}, {"checksumSHA1":"ml0MTqOsKTrsqv/mZhy78Vz4SfA=","path":"github.com/hashicorp/memberlist","revision":"d6c1fb0b99c33d0a8e22acea9da9709b369b5d39","revisionTime":"2017-08-15T22:46:17Z"}, {"checksumSHA1":"qnlqWJYV81ENr61SZk9c65R1mDo=","path":"github.com/hashicorp/net-rpc-msgpackrpc","revision":"a14192a58a694c123d8fe5481d4a4727d6ae82f3","revisionTime":"2015-11-16T02:03:38Z"}, - {"checksumSHA1":"5GHIYEtOr1rsHOZUac6RA/82d3I=","path":"github.com/hashicorp/raft","revision":"0a6e1b039ba3d8057e9f16c919d2afb813884f74","revisionTime":"2017-08-04T15:11:58Z","version":"library-v2-stage-one","versionExact":"library-v2-stage-one"}, + {"checksumSHA1":"RVDP6/BNLtrGbyoiGU2GjTun9Kk=","path":"github.com/hashicorp/raft","revision":"2356637a1c1ffe894b753680363ad970480215aa","revisionTime":"2017-08-24T21:39:20Z","version":"library-v2-stage-one","versionExact":"library-v2-stage-one"}, {"checksumSHA1":"QAxukkv54/iIvLfsUP6IK4R0m/A=","path":"github.com/hashicorp/raft-boltdb","revision":"d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee","revisionTime":"2015-02-01T20:08:39Z"}, {"checksumSHA1":"/oss17GO4hXGM7QnUdI3VzcAHzA=","comment":"v0.7.0-66-g6c4672d","path":"github.com/hashicorp/serf/coordinate","revision":"c2e4be24cdc9031eb0ad869c5d160775efdf7d7a","revisionTime":"2017-05-25T23:15:04Z"}, {"checksumSHA1":"3WPnGSL9ZK6EmkAE6tEW5SCxrd8=","comment":"v0.7.0-66-g6c4672d","path":"github.com/hashicorp/serf/serf","revision":"b84a66cc5575994cb672940d244a2404141688c0","revisionTime":"2017-08-17T21:22:02Z"},