From c9d5e174108ceaa49f8f3c38097bf9199fec4a45 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Thu, 17 Aug 2017 16:35:06 -0500 Subject: [PATCH] Update serf to pick up fixes for fsyncing snapshots and panic when coordinates are disabled --- .../hashicorp/serf/serf/keymanager.go | 2 +- vendor/github.com/hashicorp/serf/serf/serf.go | 26 ++++----- .../hashicorp/serf/serf/snapshot.go | 53 +++++++++++-------- vendor/vendor.json | 2 +- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/vendor/github.com/hashicorp/serf/serf/keymanager.go b/vendor/github.com/hashicorp/serf/serf/keymanager.go index fd53182fc5..bea038cd24 100644 --- a/vendor/github.com/hashicorp/serf/serf/keymanager.go +++ b/vendor/github.com/hashicorp/serf/serf/keymanager.go @@ -189,4 +189,4 @@ func (k *KeyManager) ListKeysWithOptions(opts *KeyRequestOptions) (*KeyResponse, defer k.l.RUnlock() return k.handleKeyRequest("", listKeysQuery, opts) -} \ No newline at end of file +} diff --git a/vendor/github.com/hashicorp/serf/serf/serf.go b/vendor/github.com/hashicorp/serf/serf/serf.go index af48e53a2d..7256eafab1 100644 --- a/vendor/github.com/hashicorp/serf/serf/serf.go +++ b/vendor/github.com/hashicorp/serf/serf/serf.go @@ -1655,18 +1655,20 @@ func (s *Serf) Stats() map[string]string { return strconv.FormatUint(v, 10) } stats := map[string]string{ - "members": toString(uint64(len(s.members))), - "failed": toString(uint64(len(s.failedMembers))), - "left": toString(uint64(len(s.leftMembers))), - "health_score": toString(uint64(s.memberlist.GetHealthScore())), - "member_time": toString(uint64(s.clock.Time())), - "event_time": toString(uint64(s.eventClock.Time())), - "query_time": toString(uint64(s.queryClock.Time())), - "intent_queue": toString(uint64(s.broadcasts.NumQueued())), - "event_queue": toString(uint64(s.eventBroadcasts.NumQueued())), - "query_queue": toString(uint64(s.queryBroadcasts.NumQueued())), - "encrypted": fmt.Sprintf("%v", s.EncryptionEnabled()), - "coordinate_resets": toString(uint64(s.coordClient.Stats().Resets)), + "members": toString(uint64(len(s.members))), + "failed": toString(uint64(len(s.failedMembers))), + "left": toString(uint64(len(s.leftMembers))), + "health_score": toString(uint64(s.memberlist.GetHealthScore())), + "member_time": toString(uint64(s.clock.Time())), + "event_time": toString(uint64(s.eventClock.Time())), + "query_time": toString(uint64(s.queryClock.Time())), + "intent_queue": toString(uint64(s.broadcasts.NumQueued())), + "event_queue": toString(uint64(s.eventBroadcasts.NumQueued())), + "query_queue": toString(uint64(s.queryBroadcasts.NumQueued())), + "encrypted": fmt.Sprintf("%v", s.EncryptionEnabled()), + } + if !s.config.DisableCoordinates { + stats["coordinate_resets"] = toString(uint64(s.coordClient.Stats().Resets)) } return stats } diff --git a/vendor/github.com/hashicorp/serf/serf/snapshot.go b/vendor/github.com/hashicorp/serf/serf/snapshot.go index 8e15f3f31d..7017dd01fb 100644 --- a/vendor/github.com/hashicorp/serf/serf/snapshot.go +++ b/vendor/github.com/hashicorp/serf/serf/snapshot.go @@ -36,27 +36,27 @@ const snapshotErrorRecoveryInterval = 30 * time.Second // Snapshotter is responsible for ingesting events and persisting // them to disk, and providing a recovery mechanism at start time. type Snapshotter struct { - aliveNodes map[string]string - clock *LamportClock - coordClient *coordinate.Client - fh *os.File - buffered *bufio.Writer - inCh <-chan Event - lastFlush time.Time - lastClock LamportTime - lastEventClock LamportTime - lastQueryClock LamportTime - leaveCh chan struct{} - leaving bool - logger *log.Logger - maxSize int64 - path string - offset int64 - outCh chan<- Event - rejoinAfterLeave bool - shutdownCh <-chan struct{} - waitCh chan struct{} - lastAttemptedCompaction time.Time + aliveNodes map[string]string + clock *LamportClock + coordClient *coordinate.Client + fh *os.File + buffered *bufio.Writer + inCh <-chan Event + lastFlush time.Time + lastClock LamportTime + lastEventClock LamportTime + lastQueryClock LamportTime + leaveCh chan struct{} + leaving bool + logger *log.Logger + maxSize int64 + path string + offset int64 + outCh chan<- Event + rejoinAfterLeave bool + shutdownCh <-chan struct{} + waitCh chan struct{} + lastAttemptedCompaction time.Time } // PreviousNode is used to represent the previously known alive nodes @@ -423,11 +423,20 @@ func (s *Snapshotter) compact() error { // Flush the new snapshot err = buf.Flush() - fh.Close() + if err != nil { return fmt.Errorf("failed to flush new snapshot: %v", err) } + err = fh.Sync() + + if err != nil { + fh.Close() + return fmt.Errorf("failed to fsync new snapshot: %v", err) + } + + fh.Close() + // We now need to swap the old snapshot file with the new snapshot. // Turns out, Windows won't let us rename the files if we have // open handles to them or if the destination already exists. This diff --git a/vendor/vendor.json b/vendor/vendor.json index d8a5c9a255..5f7292f5c6 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -60,7 +60,7 @@ {"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":"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":"o1VR3OEjCXQW/vT1wpUBOYfGrPQ=","comment":"v0.7.0-66-g6c4672d","path":"github.com/hashicorp/serf/serf","revision":"6669b5d30985da6dd423ecf65f033cee400203fe","revisionTime":"2017-07-07T06:54:45Z"}, + {"checksumSHA1":"3WPnGSL9ZK6EmkAE6tEW5SCxrd8=","comment":"v0.7.0-66-g6c4672d","path":"github.com/hashicorp/serf/serf","revision":"b84a66cc5575994cb672940d244a2404141688c0","revisionTime":"2017-08-17T21:22:02Z"}, {"checksumSHA1":"ZhK6IO2XN81Y+3RAjTcVm1Ic7oU=","path":"github.com/hashicorp/yamux","revision":"d1caa6c97c9fc1cc9e83bbe34d0603f9ff0ce8bd","revisionTime":"2016-07-20T23:31:40Z"}, {"checksumSHA1":"xZuhljnmBysJPta/lMyYmJdujCg=","path":"github.com/mattn/go-isatty","revision":"66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8","revisionTime":"2016-08-06T12:27:52Z"}, {"checksumSHA1":"OUZ1FFXyKs+Cfg9M9rmXqqweQck=","path":"github.com/miekg/dns","revision":"db96a2b759cdef4f11a34506a42eb8d1290c598e","revisionTime":"2016-07-26T03:20:27Z"},