-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We add a parameter that allows the behavior of the time encoding to be changed by `NetworkTransportConfig.MsgpackUseNewTimeFormat`. The default value is `false`, which keeps the current behavior of time encoding is compatible with with `go-msgpack` v0.5.5 (the version in `go.mod` prior to this change). However, users who upgrade to this version of Raft will no longer have their own version of pre-v2 `go-msgpack` honored, which could cause unexpected binary compatibility problems. This will be a problem for HashiCorp products who might blindly upgrade: * [Vault](https://github.com/hashicorp/vault/blob/f2f532ec802d356346c2302e9c38734f2a594f3f/go.mod#L98) (`go-msgpack` v1.1.5) * [Nomad](https://github.com/hashicorp/nomad/blob/cb2363f2fbbb771af9c8a62ed09a60250df647a2/go.mod#L64) (`go-msgpack` v1.1.5). I don't believe this will be a problem for [Consul](https://github.com/hashicorp/consul/blob/8eb074e7c17a0a2077436637c06f521b036407f5/go.mod#L199) (`go-msgpack` v0.5.5). For the sake of non-HashiCorp products using this library, I'd recommend merging this and making a release with a full `v2` so that people are not surprised. I'll follow-up this PR and release with PRs to upgrade Vault, Consul, and Nomad. I tested this branch with Vault using `NetworkTransportConfig.MsgpackUseNewTimeFormat` set to `true` and verified it was able to replicate to Vault 1.15.0 (which uses `go-msgpack` v1.1.5). (I also tested that the same setting of `false` would fail to replicate to Vault 1.15.0 with a time decoding error, as expected). I also added a quick benchmark in `bench_test.go`, and did not notice any significant performance differences before and after this change (which is not surprising, since I don't assume msgpack is a significant cost for snapshots).
- Loading branch information
Christopher Swenson
committed
Oct 18, 2023
1 parent
d09d941
commit e837280
Showing
11 changed files
with
158 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package raft | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/hashicorp/go-hclog" | ||
) | ||
|
||
func BenchmarkStoreLogInMem(b *testing.B) { | ||
conf := DefaultConfig() | ||
conf.LocalID = "first" | ||
conf.HeartbeatTimeout = 50 * time.Millisecond | ||
conf.ElectionTimeout = 50 * time.Millisecond | ||
conf.LeaderLeaseTimeout = 50 * time.Millisecond | ||
conf.CommitTimeout = 5 * time.Millisecond | ||
conf.SnapshotThreshold = 100 | ||
conf.TrailingLogs = 10 | ||
conf.LogLevel = "OFF" | ||
raft := MakeRaft(b, conf, true) | ||
raft.logger.SetLevel(hclog.Off) | ||
|
||
NoErr(WaitFor(raft, Leader), b) | ||
|
||
applyAndWait := func(leader *RaftEnv, n, sz int) { | ||
// Do some commits | ||
var futures []ApplyFuture | ||
for i := 0; i < n; i++ { | ||
futures = append(futures, leader.raft.Apply(logBytes(i, sz), 0)) | ||
} | ||
for _, f := range futures { | ||
NoErr(WaitFuture(f), b) | ||
leader.logger.Debug("applied", "index", f.Index(), "size", sz) | ||
} | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
// Do some commits | ||
applyAndWait(raft, 100, 10) | ||
// Do a snapshot | ||
NoErr(WaitFuture(raft.raft.Snapshot()), b) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
module github.com/hashicorp/raft/fuzzy | ||
|
||
go 1.16 | ||
go 1.20 | ||
|
||
require ( | ||
github.com/boltdb/bolt v1.3.1 // indirect | ||
github.com/hashicorp/go-hclog v1.5.0 | ||
github.com/hashicorp/go-msgpack v0.5.5 | ||
github.com/hashicorp/go-msgpack/v2 v2.1.1 | ||
github.com/hashicorp/raft v1.2.0 | ||
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea | ||
golang.org/x/sys v0.1.0 // indirect | ||
) | ||
|
||
require ( | ||
github.com/armon/go-metrics v0.4.1 // indirect | ||
github.com/boltdb/bolt v1.3.1 // indirect | ||
github.com/fatih/color v1.13.0 // indirect | ||
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect | ||
github.com/hashicorp/go-msgpack v0.5.5 // indirect | ||
github.com/hashicorp/golang-lru v0.5.0 // indirect | ||
github.com/mattn/go-colorable v0.1.12 // indirect | ||
github.com/mattn/go-isatty v0.0.14 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
) | ||
|
||
replace github.com/hashicorp/raft => ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.