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

fix(tsm): should not check write-ahead-log size against default size #20585

Merged
merged 3 commits into from
Feb 10, 2021

Conversation

foobar
Copy link
Contributor

@foobar foobar commented Jan 25, 2021

it should check against the local saved SegmentSize instead of the
default const DefaultSegmentSize.

@danxmoran danxmoran self-requested a review February 2, 2021 15:01
@danxmoran
Copy link
Contributor

Thanks for the submission @foobar! Could you please:

  1. Add a line to CHANGELOG.md describing the impact of this change (I assume a bug fix)?
  2. Add a new test to wal_test.go that checks this change works as intended? Or if an automated test would have too much overhead, could you describe how you manually tested this so I can reproduce?

@foobar foobar force-pushed the 2.0-check-wal-seg-size branch from d14466c to 9cfeef7 Compare February 9, 2021 03:30
@foobar
Copy link
Contributor Author

foobar commented Feb 9, 2021

  1. Add a line to CHANGELOG.md describing the impact of this change (I assume a bug fix)?

done

  1. Add a new test to wal_test.go that checks this change works as intended? Or if an automated test would have too much overhead, could you describe how you manually tested this so I can reproduce?

added test case

@foobar foobar force-pushed the 2.0-check-wal-seg-size branch 2 times, most recently from 797ef38 to c198f38 Compare February 9, 2021 03:37
CHANGELOG.md Outdated Show resolved Hide resolved
"cpu,host=C#!~#value": []tsm1.Value{tsm1.NewValue(1, 1.0)},
}
if _, err := w.WriteMulti(values); err != nil {
fatal(t, "write points", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not t.Fatalf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's just following the convention of other functions in this file. fatal() wraps Fatalf


encodeSize := int64(0)
if files, err := ioutil.ReadDir(w.Path()); err != nil {
fatal(t, "ReadDir", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not t.Fatalf?


for i := 0; i < 100; i++ {
if _, err := w.WriteMulti(values); err != nil {
fatal(t, "write points", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatalf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto

}
files, err := ioutil.ReadDir(w.Path())
if err != nil {
fatal(t, "ReadDir", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

t.Fatalf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto

fatal(t, "ReadDir", err)
}
for _, f := range files {
if f.Size() > int64(segSize)+encodeSize {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if f.Size() > int64(segSize)+encodeSize {
if f.Size() > int64(segSize) + encodeSize {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gofmt doesn't add space here

} else if len(files) != 1 {
t.Fatalf("unexpected segments size %d", len(files))
} else {
encodeSize = files[0].Size()
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: I don't think this needs to be wrapped in the else, since the other cases cause the test to bail out

Copy link
Contributor

Choose a reason for hiding this comment

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

And if you move it out of the else, you could remove encodeSize := int64(0) above and define it a single time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. thanks!

it should check against the local saved SegmentSize instead of the
default const DefaultSegmentSize.
@foobar foobar force-pushed the 2.0-check-wal-seg-size branch from 66f94ac to 8a5a13e Compare February 10, 2021 01:45
Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM! I'll wrangle it from here

@danxmoran danxmoran self-assigned this Feb 10, 2021
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.

2 participants