Browse Source

Update raft deps to fix snapshot races in -dev mode (#2498)

pull/2499/head
Kyle Havlovitz 8 years ago committed by James Phillips
parent
commit
b2cdba8fcf
  1. 19
      vendor/github.com/hashicorp/raft/inmem_snapshot.go
  2. 6
      vendor/vendor.json

19
vendor/github.com/hashicorp/raft/inmem_snapshot.go generated vendored

@ -5,6 +5,7 @@ import (
"fmt"
"io"
"io/ioutil"
"sync"
)
// InmemSnapshotStore implements the SnapshotStore interface and
@ -12,6 +13,7 @@ import (
type InmemSnapshotStore struct {
latest *InmemSnapshotSink
hasSnapshot bool
sync.RWMutex
}
// InmemSnapshotSink implements SnapshotSink in memory
@ -39,8 +41,11 @@ func (m *InmemSnapshotStore) Create(version SnapshotVersion, index, term uint64,
name := snapshotName(term, index)
sink := m.latest
sink.meta = SnapshotMeta{
m.Lock()
defer m.Unlock()
sink := &InmemSnapshotSink{
meta: SnapshotMeta{
Version: version,
ID: name,
Index: index,
@ -48,15 +53,20 @@ func (m *InmemSnapshotStore) Create(version SnapshotVersion, index, term uint64,
Peers: encodePeers(configuration, trans),
Configuration: configuration,
ConfigurationIndex: configurationIndex,
},
contents: &bytes.Buffer{},
}
sink.contents = &bytes.Buffer{}
m.hasSnapshot = true
m.latest = sink
return sink, nil
}
// List returns the latest snapshot taken
func (m *InmemSnapshotStore) List() ([]*SnapshotMeta, error) {
m.RLock()
defer m.RUnlock()
if !m.hasSnapshot {
return []*SnapshotMeta{}, nil
}
@ -65,6 +75,9 @@ func (m *InmemSnapshotStore) List() ([]*SnapshotMeta, error) {
// Open wraps an io.ReadCloser around the snapshot contents
func (m *InmemSnapshotStore) Open(id string) (*SnapshotMeta, io.ReadCloser, error) {
m.RLock()
defer m.RUnlock()
if m.latest.meta.ID != id {
return nil, nil, fmt.Errorf("[ERR] snapshot: failed to open snapshot id: %s", id)
}

6
vendor/vendor.json vendored

@ -506,10 +506,10 @@
"revisionTime": "2015-11-16T02:03:38Z"
},
{
"checksumSHA1": "ed1YY/S0BSb57IRRSDUbFp7r0IE=",
"checksumSHA1": "hwvKyyRujRkxMtrdwigHuE5SIyo=",
"path": "github.com/hashicorp/raft",
"revision": "def7451ceceb8a919cbb1f6d1c0f7648e9311879",
"revisionTime": "2016-10-31T16:57:40Z"
"revision": "aaad9f10266e089bd401e7a6487651a69275641b",
"revisionTime": "2016-11-10T00:52:40Z"
},
{
"checksumSHA1": "QAxukkv54/iIvLfsUP6IK4R0m/A=",

Loading…
Cancel
Save