Skip to content

Commit

Permalink
Wal file size bug fix (Bump Raft to 3.5.9) release-2.5 (#4343)
Browse files Browse the repository at this point in the history
Upgraded etcd Raft 3.5.1 -> 3.5.9

Signed-off-by: Emil Elizarov <emil.elizarov@ibm.com>
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart authored Aug 1, 2023
1 parent 1a34aff commit bcd3eb5
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 178 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ require (
github.com/sykesm/zap-logfmt v0.0.4
github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954
github.com/tedsuo/ifrit v0.0.0-20220120221754-dd274de71113
go.etcd.io/etcd/client/pkg/v3 v3.5.1
go.etcd.io/etcd/raft/v3 v3.5.1
go.etcd.io/etcd/server/v3 v3.5.1
go.etcd.io/etcd/client/pkg/v3 v3.5.9
go.etcd.io/etcd/raft/v3 v3.5.9
go.etcd.io/etcd/server/v3 v3.5.9
go.uber.org/zap v1.19.0
golang.org/x/crypto v0.1.0
golang.org/x/tools v0.1.12
Expand Down Expand Up @@ -106,7 +106,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.1 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.9 // indirect
go.opencensus.io v0.22.4 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
Expand Down
64 changes: 9 additions & 55 deletions go.sum

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions orderer/consensus/etcdraft/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,31 @@ var _ = Describe("Chain", func() {
})

Context("when a node starts up", func() {
It("WAL 32MB file size should be within size limits", func() {
close(cutter.Block)
cutter.CutNext = true
// Wait for the leader to be chosen
campaign(chain, observeC)

By("Create large TX")
large_size_env := &common.Envelope{
Payload: marshalOrPanic(&common.Payload{
Header: &common.Header{ChannelHeader: marshalOrPanic(&common.ChannelHeader{Type: int32(common.HeaderType_MESSAGE), ChannelId: channelID})},
Data: make([]byte, 32_000_000),
}),
}

By("Send TX to chain")
Expect(chain.Order(large_size_env, 0)).To(Succeed())
By("Wait for TX to be written to WAL")
Eventually(support.WriteBlockCallCount, LongEventualTimeout).Should(Equal(1))
By("Stop the chain")
chain.Halt()

By("Create new chain")
_, err := etcdraft.NewChain(support, opts, configurator, nil, cryptoProvider, noOpBlockPuller, nil, observeC)
Expect(err).NotTo(HaveOccurred())
})
It("properly configures the communication layer", func() {
expectedNodeConfig := nodeConfigFromMetadata(consenterMetadata)
Eventually(configurator.ConfigureCallCount, LongEventualTimeout).Should(Equal(1))
Expand Down
8 changes: 2 additions & 6 deletions orderer/consensus/etcdraft/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func assertFileCount(t *testing.T, wal, snap int) {
func TestOpenWAL(t *testing.T) {
t.Run("Last WAL file is broken", func(t *testing.T) {
setup(t)
defer clean(t)

// create 10 new wal files
for i := 0; i < 10; i++ {
Expand All @@ -84,7 +83,7 @@ func TestOpenWAL(t *testing.T) {
)
}
assertFileCount(t, 1, 0)
lasti, _ := store.ram.LastIndex() // it never returns err
store.ram.LastIndex() // it never returns err

// close current storage
err = store.Close()
Expand All @@ -108,10 +107,7 @@ func TestOpenWAL(t *testing.T) {
// create new storage
ram = raft.NewMemoryStorage()
store, err = CreateStorage(logger, walDir, snapDir, ram)
require.NoError(t, err)
lastI, _ := store.ram.LastIndex()
require.True(t, lastI > 0) // we are still able to read some entries
require.True(t, lasti > lastI) // but less than before because some are broken
require.ErrorContains(t, err, "failed to create or read WAL: failed to read WAL and cannot repair")
})
}

Expand Down
60 changes: 60 additions & 0 deletions vendor/go.etcd.io/etcd/client/pkg/v3/fileutil/filereader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions vendor/go.etcd.io/etcd/client/pkg/v3/fileutil/fileutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion vendor/go.etcd.io/etcd/client/pkg/v3/fileutil/purge.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions vendor/go.etcd.io/etcd/raft/v3/confchange/confchange.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 55 additions & 56 deletions vendor/go.etcd.io/etcd/raft/v3/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bcd3eb5

Please sign in to comment.