Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement raft-wal #21460

Merged
merged 47 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ca1c92f
Implement raft-wal
raskchanky Jun 26, 2023
c45413f
go mod tidy
raskchanky Jun 26, 2023
27aede1
add metrics, fix a panic
raskchanky Jun 27, 2023
3f0c104
fix the panic for real this time
raskchanky Jun 27, 2023
d669640
Merge branch 'main' into raft-wal
raskchanky Aug 23, 2023
fd567dd
PR feedback
raskchanky Aug 23, 2023
567243f
refactor tests to use a helper and reduce duplication
raskchanky Aug 23, 2023
3d03e8c
add a test to verify we don't use raft-wal if raft.db exists
raskchanky Aug 24, 2023
bee2d0b
Merge branch 'main' into raft-wal
raskchanky Aug 24, 2023
766c53b
add config to enable the verifier
raskchanky Aug 28, 2023
b00ae66
add tests for parsing verification intervals
raskchanky Aug 28, 2023
bed9e34
run the verifier in the background
raskchanky Aug 28, 2023
555afb4
wire up the verifier
raskchanky Aug 29, 2023
1fb11f4
go mod tidy
raskchanky Aug 30, 2023
3110582
Merge branch 'main' into raft-wal
raskchanky Aug 30, 2023
753a2dc
Merge branch 'main' into raft-wal
raskchanky Sep 8, 2023
2e17d60
refactor config parsing
raskchanky Sep 14, 2023
03081f3
remove unused function
raskchanky Sep 14, 2023
c2156b0
trying to get the verifier working
raskchanky Oct 11, 2023
1a5dfac
wire up some more verifier bits
raskchanky Oct 23, 2023
6aafd64
Merge branch 'main' into raft-wal
raskchanky Nov 6, 2023
d2a79dc
sorted out an error, added a new test, lots of debug logging that nee…
raskchanky Nov 7, 2023
26d11e2
fix a bug and remove all the debugging statements
raskchanky Nov 7, 2023
f4e6022
make sure we close raft-wal stablestore too
raskchanky Nov 8, 2023
fcf2d0a
Merge branch 'main' into raft-wal
hghaf099 Nov 30, 2023
2fcd0d8
Merge branch 'main' into raft-wal
raskchanky Dec 4, 2023
2a03747
Merge branch 'main' into raft-wal
hghaf099 Dec 7, 2023
57a1f2c
Merge branch 'main' into raft-wal
hghaf099 Dec 8, 2023
2fae68d
Merge branch 'main' into raft-wal
raskchanky Dec 12, 2023
dbb0f8c
Merge branch 'main' into raft-wal
raskchanky Dec 20, 2023
b4aa0fd
run verifier tests for both boltdb and raft-wal
raskchanky Dec 20, 2023
a7b31cc
Merge branch 'main' into raft-wal
raskchanky Jan 5, 2024
9f567cd
Merge branch 'main' into raft-wal
raskchanky Jan 8, 2024
d70b266
Merge branch 'main' into raft-wal
raskchanky Jan 9, 2024
6071268
PR feedback
raskchanky Jan 11, 2024
1bb29b3
Vault 20270 docker test raft wal (#24463)
hghaf099 Jan 17, 2024
4c5f434
Merge branch 'main' into raft-wal
raskchanky Jan 23, 2024
fa90807
Update physical/raft/raft.go
raskchanky Jan 23, 2024
395984b
PR feedback
raskchanky Jan 24, 2024
54448fb
change verifier function
raskchanky Jan 24, 2024
af9b42f
Merge branch 'main' into raft-wal
raskchanky Jan 24, 2024
7d42da4
make this shorter
raskchanky Jan 24, 2024
b9e433e
Merge branch 'main' into raft-wal
raskchanky Jan 24, 2024
83ea124
add changelog
raskchanky Jan 24, 2024
293f027
Fix Close behavior
banks Jan 25, 2024
fab75fe
make supporting empty logs more explicit
raskchanky Jan 25, 2024
dfd68eb
add some godocs
raskchanky Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/21460.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
storage/raft: Add experimental support for raft-wal, a new backend engine for integrated storage.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raskchanky next time please use the correct new feature formatting for new features in the changelog.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reminder. I did correct this in a subsequent PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good candidate for a new CI check, so that we don't have to rely on humans remembering to always do the right thing in several different scenarios.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raskchanky I've added an agenda item to discuss new requirements for the changelog checking tooling.

```
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ require (
github.com/hashicorp/golang-lru v1.0.2
github.com/hashicorp/hcl v1.0.1-vault-5
github.com/hashicorp/hcl/v2 v2.16.2
github.com/hashicorp/hcp-link v0.1.0
github.com/hashicorp/hcp-scada-provider v0.2.1
github.com/hashicorp/hcp-link v0.2.1
github.com/hashicorp/hcp-scada-provider v0.2.2
raskchanky marked this conversation as resolved.
Show resolved Hide resolved
banks marked this conversation as resolved.
Show resolved Hide resolved
github.com/hashicorp/hcp-sdk-go v0.75.0
github.com/hashicorp/nomad/api v0.0.0-20230519153805-2275a83cbfdf
github.com/hashicorp/raft v1.6.0
github.com/hashicorp/raft-autopilot v0.2.0
github.com/hashicorp/raft-boltdb/v2 v2.3.0
github.com/hashicorp/raft-snapshot v1.0.4
github.com/hashicorp/raft-wal v0.4.0
github.com/hashicorp/vault-hcp-lib v0.0.0-20231208101417-1123df6d540b
github.com/hashicorp/vault-plugin-auth-alicloud v0.16.1
github.com/hashicorp/vault-plugin-auth-azure v0.16.2
Expand Down Expand Up @@ -293,6 +294,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.18.7 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/benbjohnson/immutable v0.4.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/boltdb/bolt v1.3.1 // indirect
Expand All @@ -312,10 +314,12 @@ require (
github.com/containerd/containerd v1.7.12 // indirect
github.com/containerd/continuity v0.4.2 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/coreos/etcd v3.3.27+incompatible // indirect
github.com/coreos/go-oidc v2.2.1+incompatible // indirect
github.com/coreos/go-oidc/v3 v3.5.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect
github.com/couchbase/gocb/v2 v2.6.3 // indirect
github.com/couchbase/gocbcore/v10 v10.2.3 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
Expand Down Expand Up @@ -472,6 +476,7 @@ require (
github.com/prometheus/procfs v0.8.0 // indirect
github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
Expand Down
18 changes: 14 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,8 @@ github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/immutable v0.4.0 h1:CTqXbEerYso8YzVPxmWxh2gnoRQbbB9X1quUC8+vGZA=
github.com/benbjohnson/immutable v0.4.0/go.mod h1:iAr8OjJGLnLmVUr9MZ/rz4PWUy6Ouc2JLYuMArmvAJM=
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down Expand Up @@ -1462,6 +1464,8 @@ github.com/containers/ocicrypt v1.1.6/go.mod h1:WgjxPWdTJMqYMjf3M6cuIFFA1/MpyyhI
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.27+incompatible h1:QIudLb9KeBsE5zyYxd1mjzRSkzLg9Wf9QlRwFgd6oTA=
github.com/coreos/etcd v3.3.27+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
github.com/coreos/go-iptables v0.5.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU=
Expand All @@ -1487,6 +1491,8 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf h1:GOPo6vn/vTN+3IwZBvXX0y5doJfSC7My0cdzelyOCsQ=
github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/couchbase/gocb/v2 v2.6.3 h1:5RsMo+RRfK0mVxHLAfpBz3/tHlgXZb1WBNItLk9Ab+c=
github.com/couchbase/gocb/v2 v2.6.3/go.mod h1:yF5F6BHTZ/ZowhEuZbySbXrlI4rHd1TIhm5azOaMbJU=
github.com/couchbase/gocbcore/v10 v10.2.3 h1:PEkRSNSkKjUBXx82Ucr094+anoiCG5GleOOQZOHo6D4=
Expand Down Expand Up @@ -2217,10 +2223,10 @@ github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31
github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM=
github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0=
github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng=
github.com/hashicorp/hcp-link v0.1.0 h1:F6F1cpADc+o5EBI5CbJn5RX4qdFSLpuA4fN69eeE5lQ=
github.com/hashicorp/hcp-link v0.1.0/go.mod h1:BWVDuJDHrKJtWc5qI07bX5xlLjSgWq6kYLQUeG1g5dM=
github.com/hashicorp/hcp-scada-provider v0.2.1 h1:yr+Uxini7SWTZ2t49d3Xi+6+X/rbsSFx8gq6WVcC91c=
github.com/hashicorp/hcp-scada-provider v0.2.1/go.mod h1:Q0WpS2RyhBKOPD4X/8oW7AJe7jA2HXB09EwDzwRTao0=
github.com/hashicorp/hcp-link v0.2.1 h1:8w4YVJxRb2C7oXN+hCPSyDbBeo7RQsIYTR6nQXJt6f8=
github.com/hashicorp/hcp-link v0.2.1/go.mod h1:6otT7bD+nBW1cyzgz8Z4BPziZfwxTtAEkYUrF/MOT8o=
github.com/hashicorp/hcp-scada-provider v0.2.2 h1:S4Kz+Vc02XOz/5Sm9Gug6ivfyfgchM6qv48cgz0uRls=
github.com/hashicorp/hcp-scada-provider v0.2.2/go.mod h1:Q0WpS2RyhBKOPD4X/8oW7AJe7jA2HXB09EwDzwRTao0=
github.com/hashicorp/hcp-sdk-go v0.75.0 h1:5SLvNpcTeZnG7YnwWIaZlqCottFCGKldEIQnaYjOIq8=
github.com/hashicorp/hcp-sdk-go v0.75.0/go.mod h1:5GwdT+HGhEQsh4n1yK+RADnQkfOo6vHgr2BpYUt2t9U=
github.com/hashicorp/jsonapi v0.0.0-20210826224640-ee7dae0fb22d h1:9ARUJJ1VVynB176G1HCwleORqCaXm/Vx0uUi0dL26I0=
Expand Down Expand Up @@ -2252,6 +2258,8 @@ github.com/hashicorp/raft-boltdb/v2 v2.3.0 h1:fPpQR1iGEVYjZ2OELvUHX600VAK5qmdnDE
github.com/hashicorp/raft-boltdb/v2 v2.3.0/go.mod h1:YHukhB04ChJsLHLJEUD6vjFyLX2L3dsX3wPBZcX4tmc=
github.com/hashicorp/raft-snapshot v1.0.4 h1:EuDuayAJPdiDmVk1ygTDnG2zDzrs0/6/yBuma1IYSow=
github.com/hashicorp/raft-snapshot v1.0.4/go.mod h1:5sL9eUn72lH5DzsFIJ9jaysITbHksSSszImWSOTC8Ic=
github.com/hashicorp/raft-wal v0.4.0 h1:oHCQLPa3gBTrfuBVHaDg2b/TVXpU0RIyeH/mU9ovk3Y=
github.com/hashicorp/raft-wal v0.4.0/go.mod h1:A6vP5o8hGOs1LHfC1Okh9xPwWDcmb6Vvuz/QyqUXlOE=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY=
github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4=
Expand Down Expand Up @@ -2990,6 +2998,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sethvargo/go-limiter v0.7.1 h1:wWNhTj0pxjyJ7wuJHpRJpYwJn+bUnjYfw2a85eu5w9U=
Expand Down
98 changes: 89 additions & 9 deletions physical/raft/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package raft
import (
"bytes"
"context"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/hashicorp/go-raftchunking"
"github.com/hashicorp/go-secure-stdlib/strutil"
"github.com/hashicorp/raft"
"github.com/hashicorp/raft-wal/verifier"
"github.com/hashicorp/vault/sdk/helper/jsonutil"
"github.com/hashicorp/vault/sdk/physical"
"github.com/hashicorp/vault/sdk/plugin/pb"
Expand All @@ -36,6 +38,7 @@ const (
putOp
restoreCallbackOp
getOp
verifierCheckpointOp

chunkingPrefix = "raftchunking/"
databaseFilename = "vault.db"
Expand All @@ -58,6 +61,12 @@ var (
_ raft.BatchingFSM = (*FSM)(nil)
)

var logVerifierMagicBytes [8]byte

func init() {
binary.LittleEndian.PutUint64(logVerifierMagicBytes[:], verifier.ExtensionMagicPrefix)
}

type restoreCallback func(context.Context) error

type FSMEntry struct {
Expand All @@ -76,6 +85,69 @@ type FSMApplyResponse struct {
EntrySlice []*FSMEntry
}

type logVerificationChunkingShim struct {
chunker *raftchunking.ChunkingBatchingFSM
}

// Apply implements raft.BatchingFSM.
func (s *logVerificationChunkingShim) Apply(l *raft.Log) interface{} {
return s.ApplyBatch([]*raft.Log{l})[0]
}

// ApplyBatch implements raft.BatchingFSM
func (s *logVerificationChunkingShim) ApplyBatch(logs []*raft.Log) []interface{} {
// This is a hack because raftchunking doesn't play nicely with lower-level
// usage of Extensions field like we need for LogStore verification.

// When we write a verifier log, we write a single byte that consists of the verifierCheckpointOp,
// and then we encode the verifier.ExtensionMagicPrefix into the raft log
// Extensions field. Both of those together should ensure that verifier
// raft logs can never be mistaken for chunked protobufs. See the docs on
// verifier.ExtensionMagicPrefix for the reasoning behind the specific value
// that was chosen, and how it ensures this property.

// So here, we need to check for the exact conditions that we encoded when we wrote the
// verifier log out. If they match, we're going to insert a dummy raft log. We do this because 1) we
// don't want the chunking FSM to blow up on our verifier op that it won't understand and
// 2) we need to preserve the length of the incoming slice of raft logs because raft expects
// the length of the return value to match 1:1 to the length of the input operations.
newBatch := make([]*raft.Log, 0, len(logs))

for _, l := range logs {
if s.isVerifierLog(l) {
// Replace checkpoint with an empty op, but keep the index and term so
// downstream FSMs don't get confused about having a 0 index suddenly.
newBatch = append(newBatch, &raft.Log{
Index: l.Index,
Term: l.Term,
AppendedAt: l.AppendedAt,
})
} else {
newBatch = append(newBatch, l)
}
}

return s.chunker.ApplyBatch(newBatch)
}

// Snapshot implements raft.BatchingFSM
func (s *logVerificationChunkingShim) Snapshot() (raft.FSMSnapshot, error) {
return s.chunker.Snapshot()
}

// Restore implements raft.BatchingFSM
func (s *logVerificationChunkingShim) Restore(snapshot io.ReadCloser) error {
return s.chunker.Restore(snapshot)
}

func (s *logVerificationChunkingShim) RestoreState(state *raftchunking.State) error {
return s.chunker.RestoreState(state)
}

func (s *logVerificationChunkingShim) isVerifierLog(l *raft.Log) bool {
return isRaftLogVerifyCheckpoint(l)
}

// FSM is Vault's primary state storage. It writes updates to a bolt db file
// that lives on local disk. FSM implements raft.FSM and physical.Backend
// interfaces.
Expand Down Expand Up @@ -103,7 +175,7 @@ type FSM struct {
// retoreCb is called after we've restored a snapshot
restoreCb restoreCallback

chunker *raftchunking.ChunkingBatchingFSM
chunker *logVerificationChunkingShim

localID string
desiredSuffrage string
Expand Down Expand Up @@ -134,10 +206,12 @@ func NewFSM(path string, localID string, logger log.Logger) (*FSM, error) {
localID: localID,
}

f.chunker = raftchunking.NewChunkingBatchingFSM(f, &FSMChunkStorage{
f: f,
ctx: context.Background(),
})
f.chunker = &logVerificationChunkingShim{
chunker: raftchunking.NewChunkingBatchingFSM(f, &FSMChunkStorage{
f: f,
ctx: context.Background(),
}),
}

dbPath := filepath.Join(path, databaseFilename)
f.l.Lock()
Expand Down Expand Up @@ -608,11 +682,16 @@ func (f *FSM) ApplyBatch(logs []*raft.Log) []interface{} {
switch l.Type {
case raft.LogCommand:
command := &LogData{}
err := proto.Unmarshal(l.Data, command)
if err != nil {
f.logger.Error("error proto unmarshaling log data", "error", err)
panic("error proto unmarshaling log data")

// explicitly check for zero length Data, which will be the case for verifier no-ops
if len(l.Data) > 0 {
err := proto.Unmarshal(l.Data, command)
if err != nil {
f.logger.Error("error proto unmarshaling log data", "error", err, "data", l.Data)
panic("error proto unmarshaling log data")
}
}

commands = append(commands, command)
case raft.LogConfiguration:
configuration := raft.DecodeConfiguration(l.Data)
Expand Down Expand Up @@ -659,6 +738,7 @@ func (f *FSM) ApplyBatch(logs []*raft.Log) []interface{} {
entrySlice := make([]*FSMEntry, 0)
switch command := commandRaw.(type) {
case *LogData:
// empty logs will have a zero length slice of Operations, so this loop will be a no-op
for _, op := range command.Operations {
var err error
switch op.OpType {
Expand Down
Loading
Loading