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

mod: bump dragonboat to pebble 1.0.0 #341

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

coufalja
Copy link
Contributor

@coufalja coufalja commented Jan 12, 2024

This is based off work of @tylerwilliams in #339 as I am eagerly waiting for this to be merged, I took the liberty to rebase the PR and open it again.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1d6e2d7) 84.49% compared to head (ad763cb) 84.44%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #341      +/-   ##
==========================================
- Coverage   84.49%   84.44%   -0.04%     
==========================================
  Files          10       10              
  Lines        4280     4280              
==========================================
- Hits         3616     3614       -2     
- Misses        406      407       +1     
- Partials      258      259       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@coufalja
Copy link
Contributor Author

@lni What about the staticcheck errors should I fix them as well (they seem all to be related to bump of Go version rather than to core of this PR)

@tylerwilliams
Copy link
Contributor

@coufalja thanks for picking this up :)

@coufalja
Copy link
Contributor Author

I have fixed the static-check issues in a separate commit.

@coufalja
Copy link
Contributor Author

@lni Any feedback?

@coufalja
Copy link
Contributor Author

coufalja commented Feb 8, 2024

It looks that meanwhile 1.1.0 was published, should I update this? It again breaks the lni/vfs so we will need to go through the full loop again.

Copy link
Contributor

@kevburnsjr kevburnsjr left a comment

Choose a reason for hiding this comment

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

Firstly, I applaud the premise of this PR.
Pinning to a tagged version of Pebble (v1.0.0) is much better than pinning to an untagged version (v0.0.0).

However, this PR could be smaller if you remove the refactors:

  1. Remove the crypto/rand stuff (not necessary)
  2. Remove the explicit blank assignments

These refactors have nothing to do with pebble and should be proposed in a separate PR.

I suggest you close this PR and create a new, clean PR for Pebble 1.1.0 without any refactoring.

@@ -69,7 +70,7 @@ func benchmarkEncodedPayload(b *testing.B, ct dio.CompressionType, sz uint64) {
b.ReportAllocs()
b.SetBytes(int64(sz))
input := make([]byte, sz)
rand.Read(input)
_, _ = rand.Read(input)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would a test require crypto/rand?
Is math/rand not good enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing lint issue. Like I would be fine with math but that would require changing the linter config which I felt I shouldn't touch.

@@ -351,7 +351,7 @@ func TestCompactionReleaseStorageSpace(t *testing.T) {
key := newKey(entryKeySize, nil)
key.SetEntryKey(100, 1, i)
data := make([]byte, 64)
rand.Read(data)
_, _ = rand.Read(data)
Copy link
Contributor

@kevburnsjr kevburnsjr Feb 26, 2024

Choose a reason for hiding this comment

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

If you aren't going to use the values, it is more idiomatic to omit the assignment rather than forcing explicit blank assignment.

rand.Read(data)

See Golang std lib source code where unaccessed values do not use blank assignment.
https://github.com/golang/go/blob/master/src/crypto/rand/rand_test.go#L27-L28


"github.com/lni/dragonboat/v4/config"
"github.com/lni/dragonboat/v4/internal/fileutil"
pb "github.com/lni/dragonboat/v4/raftpb"
sm "github.com/lni/dragonboat/v4/statemachine"
)

func init() {
rand.Seed(time.Now().UnixNano())
Copy link
Contributor

@kevburnsjr kevburnsjr Feb 26, 2024

Choose a reason for hiding this comment

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

I agree that seeding the global RNG with a random value in a test suite is not a good idea.
Though neither is writing tests that depend on the determinism of a global RNG so 🤷‍♂️.
Is there any good reason that this needs to change?

Edit: I see the static check failures on @tylerwilliams PR #339 regarding deprecation of math/rand.
Looks good to me, but I recommend proposing this cleanup in a separate 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.

Yeah I did a split into the separate commit given the CI is not passing. I could revert the commit with the rand changes. Actually I think that the lint failures was an oversight from previous merge bumping to Go 1.20.

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.

4 participants