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

Upgrade go-msgpack to v2 2.1.1 #38

Merged
merged 3 commits into from
Nov 15, 2023
Merged

Conversation

swenson
Copy link

@swenson swenson commented Oct 19, 2023

This adds the option to specify what version of the time.Time encoding format is desired. The default option is false, which preserves compatibility with the current dependency of
hashicorp/go-msgpack 0.5.5 in go.mod, but users of this library will probably want to override the the setting.

While we're here, upgrade the go.mod file.

I tested that this appears to work with Nomad.

This needs to be updated and merged after
hashicorp/raft#577

This adds the option to specify what version of the `time.Time` encoding
format is desired. The default option is false, which preserves
compatibility with the current dependency of
`hashicorp/go-msgpack 0.5.5` in go.mod, but users of this library will
probably want to override the the setting.

While we're here, upgrade the go.mod file.

I tested that this appears to work with Nomad.

This needs to be updated and merged after
hashicorp/raft#577
@swenson swenson requested a review from mkeeler October 19, 2023 20:49
swenson pushed a commit to hashicorp/vault that referenced this pull request Oct 19, 2023
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version in
`go.mod`.

v2 2.1.1 was specifically designed to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with a node
also running Vault 1.15.0 (before the upgrade). Before I made the
changes to set the right `time.Time` option, the previous-version node
would throw a bunch of time-decoding errors. After fixing the option,
the node came up smoothly, even after changing leadership between them.

This relies on
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577

and will need to be updated after they are merged to get the `go.mod`
fixes removed.
// use the newer format of time.Time when encoding, used in versions <=0.5.5
// by default. Decoding is not affected, as all decoders know how to decode
// both formats.
MsgpackUseNewTimeFormat bool
Copy link
Member

Choose a reason for hiding this comment

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

If this is the format from 0.5.5 and before, shouldn't this be MsgpackUse Old TimeFormat? I swear I'm not trying to be pedantic and am genuinely confused. 😅

Copy link
Member

@mkeeler mkeeler Oct 24, 2023

Choose a reason for hiding this comment

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

MsgpackUseNewTimeFormat being true will cause TimeNotBuiltin to be set to false when configuring the msgpack Codec.

TimeNotBuiltin forces the msgpack library to not treat time as a builtin but instead rely on the binary marshaller (or text marshaller interfaces according to the docs).

I think the behavior is correct and also that having the zero value here cause disabling of the not-backwards-compatible time encoding is best so that we don't break Consul or Nomad.

I do think that the comment about the field is a little off as it sort of says that it causes the newer format to be used and that the format would be the default in versions less than 0.5.5. Should it be versions greater than 0.5.5?

Copy link
Author

Choose a reason for hiding this comment

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

@mkeeler is correct. I got the comment slightly wrong, and will correct it.

It's confusing due to the double-negative and trying to work with the default-false behavior of Go.

swenson pushed a commit to hashicorp/nomad that referenced this pull request Oct 25, 2023
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version
in `go.mod`.

v2 2.1.1 was specifically designe to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with
a node also running the prior version of Nomad (before the upgrade).
Before I made the changes to set the right `time.Time` option, the
previous-version node would throw a bunch of time-decoding errors.
After fixing the option, the node came up smoothly, even after
changing leadership between them.

This relies on
- [ ] hashicorp/serf#705
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577
- [ ] hashicorp/memberlist#292

and maybe
- [ ] hashicorp/net-rpc-msgpackrpc#12
swenson pushed a commit to hashicorp/vault that referenced this pull request Oct 25, 2023
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version in
`go.mod`.

v2 2.1.1 was specifically designed to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with a node
also running Vault 1.15.0 (before the upgrade). Before I made the
changes to set the right `time.Time` option, the previous-version node
would throw a bunch of time-decoding errors. After fixing the option,
the node came up smoothly, even after changing leadership between them.

This relies on
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577

and will need to be updated after they are merged to get the `go.mod`
fixes removed.
@swenson
Copy link
Author

swenson commented Nov 15, 2023

Thanks!

@swenson swenson merged commit 027066e into master Nov 15, 2023
1 check passed
@swenson swenson deleted the vault-19781/msgpack-upgrade branch November 15, 2023 18:00
swenson pushed a commit to hashicorp/vault that referenced this pull request Nov 15, 2023
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version in
`go.mod`.

v2 2.1.1 was specifically designed to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with a node
also running Vault 1.15.0 (before the upgrade). Before I made the
changes to set the right `time.Time` option, the previous-version node
would throw a bunch of time-decoding errors. After fixing the option,
the node came up smoothly, even after changing leadership between them.

This relies on
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577

and will need to be updated after they are merged to get the `go.mod`
fixes removed.
swenson pushed a commit to hashicorp/vault that referenced this pull request Dec 22, 2023
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version in
`go.mod`.

v2 2.1.1 was specifically designed to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with a node
also running Vault 1.15.0 (before the upgrade). Before I made the
changes to set the right `time.Time` option, the previous-version node
would throw a bunch of time-decoding errors. After fixing the option,
the node came up smoothly, even after changing leadership between them.

This relies on
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577

and will need to be updated after they are merged to get the `go.mod`
fixes removed.
swenson pushed a commit to hashicorp/vault that referenced this pull request Jan 8, 2024
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version in
`go.mod`.

v2 2.1.1 was specifically designed to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with a node
also running Vault 1.15.0 (before the upgrade). Before I made the
changes to set the right `time.Time` option, the previous-version node
would throw a bunch of time-decoding errors. After fixing the option,
the node came up smoothly, even after changing leadership between them.

This relies on
- [ ] hashicorp/raft-boltdb#38
- [ ] hashicorp/raft#577

and will need to be updated after they are merged to get the `go.mod`
fixes removed.
swenson pushed a commit to hashicorp/vault that referenced this pull request Jan 8, 2024
And set the `time.Time` option to use the go-msgpack-1.1.5-compatible
encoding in all the places, since that is the (now previous) version in
`go.mod`.

v2 2.1.1 was specifically designed to honor backwards compatibility
with 1.1.5 and 0.5.5, and to clean up the code base to be more
maintainable. There may performance lost with the 1.1.5 to 2.1.1
migration since the fastpath code was removed, but the increased safety
is probably worth it. See
[the release notes for go-msgkack 2.1.0](https://github.com/hashicorp/go-msgpack/releases/tag/v2.1.0)
for more details.

I tested this by running this code, and booting up a cluster with a node
also running Vault 1.15.0 (before the upgrade). Before I made the
changes to set the right `time.Time` option, the previous-version node
would throw a bunch of time-decoding errors. After fixing the option,
the node came up smoothly, even after changing leadership between them.

This relies on
- hashicorp/raft-boltdb#38
- hashicorp/raft#577

I did a simple pair of benchmarks (one with a final sync, one without)
and ran them before and after on both my Mac (M2 Max) laptop and my
Linux (AMD Threadripper 3970X) desktop.

tl;dr There was no performance difference for this benchmark.

```
goos: darwin
goarch: arm64
pkg: github.com/hashicorp/vault/physical/raft
                   │    a.txt    │            b.txt             │
                   │   sec/op    │   sec/op     vs base         │
RaftWithNetwork-10   58.65m ± 2%   58.62m ± 2%  ~ (p=0.937 n=6)
```

```
goos: linux
goarch: amd64
pkg: github.com/hashicorp/vault/physical/raft
cpu: AMD Ryzen Threadripper 3970X 32-Core Processor
                   │    c.txt    │            d.txt             │
                   │   sec/op    │   sec/op     vs base         │
RaftWithNetwork-64   5.861m ± 1%   5.837m ± 0%  ~ (p=0.240 n=6)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants