diff --git a/go.mod b/go.mod index 75d12c7c..363161f3 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/hashicorp/go-msgpack v1.1.5 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/raft v1.3.3 + github.com/hashicorp/raft-boltdb/v2 v2.2.0 github.com/hashicorp/serf v0.9.7 // indirect github.com/labstack/gommon v0.3.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect @@ -21,6 +22,7 @@ require ( github.com/rqlite/go-sqlite3 v1.22.0 github.com/rqlite/raft-boltdb v0.0.0-20211018013422-771de01086ce github.com/rqlite/rqlite-disco-clients v0.0.0-20220119185651-ab01e15666dd + go.etcd.io/bbolt v1.3.6 go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect go.uber.org/zap v1.20.0 // indirect diff --git a/go.sum b/go.sum index 4b12e84e..e7d4ad89 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -145,6 +146,10 @@ github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= github.com/hashicorp/raft v1.3.3 h1:Xr6DSHC5cIM8kzxu+IgoT/+MeNeUNeWin3ie6nlSrMg= github.com/hashicorp/raft v1.3.3/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= +github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea h1:RxcPJuutPRM8PUOyiweMmkuNO+RJyfy2jds2gfvgNmU= +github.com/hashicorp/raft-boltdb v0.0.0-20210409134258-03c10cc3d4ea/go.mod h1:qRd6nFJYYS6Iqnc/8HcUmko2/2Gw8qTFEmxDLii6W5I= +github.com/hashicorp/raft-boltdb/v2 v2.2.0 h1:/CVN9LSAcH50L3yp2TsPFIpeyHn1m3VF6kiutlDE3Nw= +github.com/hashicorp/raft-boltdb/v2 v2.2.0/go.mod h1:SgPUD5TP20z/bswEr210SnkUFvQP/YjKV95aaiTbeMQ= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/serf v0.9.7 h1:hkdgbqizGQHuU5IPqYM1JdSMV8nKfpuOnZYXssk9muY= github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= @@ -271,6 +276,7 @@ github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd/api/v3 v3.5.1 h1:v28cktvBq+7vGyJXF8G+rWJmj+1XUmMtqcLnH8hDocM= @@ -359,6 +365,7 @@ golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/log/log.go b/log/log.go index f8eefe0b..7596c5dc 100644 --- a/log/log.go +++ b/log/log.go @@ -4,7 +4,8 @@ import ( "fmt" "github.com/hashicorp/raft" - "github.com/rqlite/raft-boltdb" + "github.com/hashicorp/raft-boltdb/v2" + "go.etcd.io/bbolt" ) // Log is an object that can return information about the Raft log. @@ -12,8 +13,8 @@ type Log struct { *raftboltdb.BoltStore } -// NewLog returns an instantiated Log object. -func NewLog(path string) (*Log, error) { +// New returns an instantiated Log object. +func New(path string) (*Log, error) { bs, err := raftboltdb.NewBoltStore(path) if err != nil { return nil, fmt.Errorf("new bolt store: %s", err) @@ -60,7 +61,7 @@ func (l *Log) LastCommandIndex() (uint64, error) { return 0, nil } -// Stats returns stats about the BoltDB database. -func (l *Log) Stats() raftboltdb.Stats { +// Stats returns stats about the BBoltDB database. +func (l *Log) Stats() bbolt.Stats { return l.BoltStore.Stats() } diff --git a/log/log_test.go b/log/log_test.go index 5d28a3ec..e2c39ba9 100644 --- a/log/log_test.go +++ b/log/log_test.go @@ -13,7 +13,7 @@ func Test_LogNewEmpty(t *testing.T) { path := mustTempFile() defer os.Remove(path) - l, err := NewLog(path) + l, err := New(path) if err != nil { t.Fatalf("failed to create log: %s", err) } @@ -62,7 +62,7 @@ func Test_LogNewExistNotEmpty(t *testing.T) { t.Fatalf("failed to close bolt db: %s", err) } - l, err := NewLog(path) + l, err := New(path) if err != nil { t.Fatalf("failed to create new log: %s", err) } @@ -107,7 +107,7 @@ func Test_LogNewExistNotEmpty(t *testing.T) { t.Fatalf("failed to close bolt db: %s", err) } - l, err = NewLog(path) + l, err = New(path) if err != nil { t.Fatalf("failed to create new log: %s", err) } @@ -165,7 +165,7 @@ func Test_LogLastCommandIndexNotExist(t *testing.T) { t.Fatalf("failed to close bolt db: %s", err) } - l, err := NewLog(path) + l, err := New(path) if err != nil { t.Fatalf("failed to create new log: %s", err) } @@ -210,7 +210,7 @@ func Test_LogLastCommandIndexNotExist(t *testing.T) { t.Fatalf("failed to close bolt db: %s", err) } - l, err = NewLog(path) + l, err = New(path) if err != nil { t.Fatalf("failed to create new log: %s", err) } diff --git a/store/store.go b/store/store.go index 892fe825..740e3298 100644 --- a/store/store.go +++ b/store/store.go @@ -304,7 +304,7 @@ func (s *Store) Open() (retErr error) { s.snapsExistOnOpen = len(snaps) > 0 // Create the log store and stable store. - s.boltStore, err = rlog.NewLog(filepath.Join(s.raftDir, raftDBPath)) + s.boltStore, err = rlog.New(filepath.Join(s.raftDir, raftDBPath)) if err != nil { return fmt.Errorf("new log store: %s", err) }