Skip to content

fix(tsi1/partition/test): fix data races in test code (#57)#25338

Merged
devanbenz merged 3 commits intomaster-1.xfrom
db-backport-57-1.x
Sep 17, 2024
Merged

fix(tsi1/partition/test): fix data races in test code (#57)#25338
devanbenz merged 3 commits intomaster-1.xfrom
db-backport-57-1.x

Conversation

@devanbenz
Copy link
Copy Markdown

  • fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter method for MaxLogFileSize which allows unexporting that value and MaxLogFileAge. There are actually two places locks were needed in test code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

Closes #

Describe your proposed changes here.

  • I've read the contributing section of the project README.
  • Signed CLA (if not already signed).

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)
Copy link
Copy Markdown
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

A few suggestions. Perhaps put them into another PR if you want to cherry-pick them to other branches.

func (p *Partition) SetMaxLogFileSize(new int64) (old int64) {
p.mu.Lock()
old = p.maxLogFileSize
p.maxLogFileSize = new
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can do this more idiomatically with

old, p.maxLogFileSize = p.maxLogFileSize, new

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

👍 Sounds good

defer p.mu.Unlock()

var err error
if p.fileSet == nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice

var err error
for _, f := range p.fileSet.files {
if localErr := f.Close(); localErr != nil {
err = localErr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use a []error and errors.Join() here to return all the errors.

https://pkg.go.dev/errors#Join

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh thats a really cool error handling feature. Will do 👍

Copy link
Copy Markdown
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

Small change to the use of errrors.Join

for _, f := range p.fileSet.files {
if localErr := f.Close(); localErr != nil {
err = localErr
err = errors.Join(err, localErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

errors.Join ignores nil errors, so no test for not nil is necessary. The code as it is written will make nested errors; the best thing to do is use a slice.

See here for an example

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done 👍

Copy link
Copy Markdown
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

LGTM

@devanbenz devanbenz merged commit 5c9e45f into master-1.x Sep 17, 2024
@devanbenz devanbenz deleted the db-backport-57-1.x branch September 17, 2024 01:26
devanbenz added a commit that referenced this pull request Sep 17, 2024
* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

closes #25341
---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)
devanbenz added a commit that referenced this pull request Sep 17, 2024
* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)
devanbenz added a commit that referenced this pull request Sep 17, 2024
…25345)

* feat: add hook for optimizing series reads based on authorizer (#25207)

* fix(tsi1/partition/test): fix data races in test code (#57) (#25338)

* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)

---------

Co-authored-by: Geoffrey Wossum <gwossum@influxdata.com>
devanbenz added a commit that referenced this pull request Sep 17, 2024
…25344)

* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

closes #25341
---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)
devanbenz added a commit that referenced this pull request Sep 17, 2024
…25344)

* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

closes #25341
---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)
(cherry picked from commit b88e74e)

closes #25342
devanbenz added a commit that referenced this pull request Sep 17, 2024
* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

closes #25341
---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)
(cherry picked from commit b88e74e)

closes #25342
devanbenz added a commit that referenced this pull request Sep 17, 2024
#25352)

* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

closes #25341
---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)
(cherry picked from commit b88e74e)

closes #25342
devanbenz added a commit that referenced this pull request Oct 8, 2024
… (#25438)

* feat: add hook for optimizing series reads based on authorizer (#25207)

* fix(tsi1/partition/test): fix data races in test code (#57) (#25338)

* fix(tsi1/partition/test): fix data races in test code (#57)

* fix(tsi1/partition/test): fix data races in test code

This PR is like #24613 but solves it with a setter
method for MaxLogFileSize which allows unexporting that value and
MaxLogFileAge. There are actually two places locks were needed in test
code. The behavior of production code is unchanged.

(cherry picked from commit f0235c4daf4b97769db932f7346c1d3aecf57f8f)

* feat: modify error handling to be more idiomatic

closes #24042

* fix: errors.Join() filters nil errors

---------

Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com>
(cherry picked from commit 5c9e45f)

* fix(ci): Update test_pkgs_64bit image to non-eol ubuntu image (#25354)

* fix(ci): Update test_pkgs_64bit image to non-eol ubuntu image

* fix: trying edge img

* fix(ci): update ubuntu image in ci
Update test_pkgs_64bit image to non-eol ubuntu image

Please see: discuss.circleci.com/t/linux-image-deprecations-and-eol-for-2024/50177

closes #25355

(cherry picked from commit fdf0df7)

---------

Co-authored-by: Geoffrey Wossum <gwossum@influxdata.com>
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