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

Make it harder to misuse iterators #2428

Merged
merged 7 commits into from Apr 17, 2023
Merged

Make it harder to misuse iterators #2428

merged 7 commits into from Apr 17, 2023

Conversation

AlekSi
Copy link
Member

@AlekSi AlekSi commented Apr 14, 2023

Description

Just close them.

Readiness checklist

  • I added/updated unit tests.
  • I added/updated integration/compatibility tests.
  • I added/updated comments and checked rendering.
  • I made spot refactorings.
  • I updated user documentation.
  • I ran task all, and it passed.
  • I ensured that PR title is good enough for the changelog.
  • (for maintainers only) I set Reviewers (@FerretDB/core), Assignee, Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

@AlekSi AlekSi added the code/chore Code maintenance improvements label Apr 14, 2023
@AlekSi AlekSi added this to the v1.1.0 milestone Apr 14, 2023
@AlekSi AlekSi requested a review from a team as a code owner April 14, 2023 08:11
@AlekSi AlekSi self-assigned this Apr 14, 2023
@AlekSi AlekSi enabled auto-merge (squash) April 14, 2023 08:11
@codecov
Copy link

codecov bot commented Apr 14, 2023

Codecov Report

Merging #2428 (0a821db) into main (53a76ec) will decrease coverage by 37.47%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #2428       +/-   ##
===========================================
- Coverage   64.34%   26.88%   -37.47%     
===========================================
  Files         392      393        +1     
  Lines       19251    19289       +38     
===========================================
- Hits        12388     5185     -7203     
- Misses       5961    13549     +7588     
+ Partials      902      555      -347     
Impacted Files Coverage Δ
internal/handlers/common/filter_iterator.go 0.00% <0.00%> (-100.00%) ⬇️
internal/handlers/common/limit_iterator.go 0.00% <0.00%> (-84.00%) ⬇️
internal/handlers/common/projection_iterator.go 0.00% <0.00%> (-75.00%) ⬇️
internal/handlers/common/skip_iterator.go 0.00% <0.00%> (-88.00%) ⬇️
internal/handlers/common/sort_iterator.go 0.00% <0.00%> (-100.00%) ⬇️
internal/handlers/pg/msg_find.go 0.00% <0.00%> (-70.41%) ⬇️
internal/handlers/tigris/msg_find.go 0.00% <0.00%> (ø)
internal/util/iterator/closer.go 0.00% <0.00%> (ø)
internal/util/iterator/slice.go 100.00% <ø> (ø)
internal/util/iterator/values.go 94.73% <ø> (-2.64%) ⬇️
... and 1 more

... and 118 files with indirect coverage changes

Flag Coverage Δ
integration 4.71% <0.00%> (-52.62%) ⬇️
mongodb 4.71% <0.00%> (-0.01%) ⬇️
pg ?
unit 25.54% <0.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Contributor

@w84thesun w84thesun left a comment

Choose a reason for hiding this comment

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

I think one could create Closer and still forget to call closer.Close but that change still would simplify the use of iterators. 😄

internal/handlers/common/projection_iterator.go Outdated Show resolved Hide resolved
internal/handlers/common/limit_iterator.go Outdated Show resolved Hide resolved
internal/handlers/common/filter_iterator.go Outdated Show resolved Hide resolved
internal/handlers/common/skip_iterator.go Outdated Show resolved Hide resolved
internal/handlers/common/sort_iterator.go Outdated Show resolved Hide resolved
internal/util/iterator/iterator.go Outdated Show resolved Hide resolved
@AlekSi
Copy link
Member Author

AlekSi commented Apr 14, 2023

I think one could create Closer and still forget to call closer.Close

That would trigger a panic inside finalizer. I will add it to Closer too to make it easier to spot

noisersup
noisersup previously approved these changes Apr 14, 2023
@AlekSi AlekSi merged commit 06b2fa3 into FerretDB:main Apr 17, 2023
17 of 19 checks passed
@AlekSi AlekSi deleted the closer branch April 17, 2023 09:01
fenogentov pushed a commit to fenogentov/FerretDB that referenced this pull request Apr 17, 2023
fenogentov pushed a commit to fenogentov/FerretDB that referenced this pull request Apr 20, 2023
fenogentov pushed a commit to fenogentov/FerretDB that referenced this pull request Apr 20, 2023
fenogentov pushed a commit to fenogentov/FerretDB that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/chore Code maintenance improvements
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants