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

Validate scale param for dbStats and collStats correctly #2418

Merged
merged 35 commits into from
Apr 18, 2023

Conversation

rumyantseva
Copy link
Contributor

@rumyantseva rumyantseva commented Apr 12, 2023

Description

Closes #1346.

This PR is one of a few PRs for #1346. It is sent separately as it covers logic related to scale param validation and doesn't depend on the rest of the issue.

There is a minor refactoring: errLongExceeded error is split into errLongExceededNegative and errLongExceededPositive because, for the params like skip or scale, in case of negative overflow, we should still return a different error -- the value must be non-negative (for skip) or positive (for scale).

See also FerretDB/dance#407 for diff tests.

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.

@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #2418 (3abcf2e) into main (f901668) will increase coverage by 0.08%.
The diff coverage is 77.31%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2418      +/-   ##
==========================================
+ Coverage   64.38%   64.46%   +0.08%     
==========================================
  Files         393      394       +1     
  Lines       19291    19349      +58     
==========================================
+ Hits        12421    12474      +53     
- Misses       5966     5972       +6     
+ Partials      904      903       -1     
Impacted Files Coverage Δ
internal/handlers/tigris/msg_collstats.go 0.00% <0.00%> (ø)
internal/handlers/tigris/msg_dbstats.go 0.00% <0.00%> (ø)
internal/handlers/pg/msg_update.go 55.55% <37.50%> (+1.23%) ⬆️
internal/handlers/pg/msg_dbstats.go 69.38% <62.50%> (+1.99%) ⬆️
internal/handlers/common/update.go 87.29% <85.71%> (ø)
internal/handlers/common/scale.go 95.65% <95.65%> (ø)
internal/handlers/common/aggregations/collstats.go 96.07% <100.00%> (-0.08%) ⬇️
internal/handlers/common/params.go 95.98% <100.00%> (-0.02%) ⬇️
internal/handlers/common/skip.go 92.30% <100.00%> (+0.81%) ⬆️
internal/handlers/pg/msg_collstats.go 72.00% <100.00%> (+0.57%) ⬆️

... and 1 file with indirect coverage changes

Flag Coverage Δ
integration 57.48% <77.31%> (+0.10%) ⬆️
mongodb 4.70% <0.00%> (-0.02%) ⬇️
pg 57.40% <77.31%> (+0.10%) ⬆️
unit 25.46% <1.68%> (-0.11%) ⬇️

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

@AlekSi AlekSi changed the title wip SchemaStats Apr 12, 2023
@rumyantseva rumyantseva changed the title SchemaStats Validate scale param for dbStats and collStats correctly Apr 12, 2023
@rumyantseva rumyantseva added code/chore Code maintenance improvements code/enhancement Some user-visible feature could work better and removed code/chore Code maintenance improvements labels Apr 12, 2023
@rumyantseva rumyantseva self-assigned this Apr 12, 2023
@rumyantseva rumyantseva marked this pull request as ready for review April 12, 2023 22:10
@rumyantseva rumyantseva requested a review from a team as a code owner April 12, 2023 22:10
@rumyantseva rumyantseva enabled auto-merge (squash) April 12, 2023 22:10
@rumyantseva rumyantseva requested review from a team and noisersup April 12, 2023 22:10
Copy link
Member

@chilagrow chilagrow left a comment

Choose a reason for hiding this comment

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

I'm seeing that there will be other PRs, so the change I suggest can be done there too.

The failing one needs attention though 🤗

integration/commands_administration_compat_test.go Outdated Show resolved Hide resolved
internal/handlers/common/scale.go Show resolved Hide resolved
internal/handlers/common/scale.go Show resolved Hide resolved
chilagrow
chilagrow previously approved these changes Apr 17, 2023
Copy link
Member

@chilagrow chilagrow left a comment

Choose a reason for hiding this comment

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

awesome work!

@AlekSi AlekSi added this to the v1.1.0 milestone Apr 17, 2023
@rumyantseva rumyantseva dismissed stale reviews from w84thesun, noisersup, and chilagrow via 56e1dc5 April 17, 2023 15:13
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.

👍

Copy link
Member

@AlekSi AlekSi left a comment

Choose a reason for hiding this comment

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

LGTM for docs, but please add and update comments in the next PR

@@ -121,7 +121,8 @@ var (
errNotBinaryMask = fmt.Errorf("not a binary mask")
errUnexpectedLeftOpType = fmt.Errorf("unexpected left operand type")
errUnexpectedRightOpType = fmt.Errorf("unexpected right operand type")
errLongExceeded = fmt.Errorf("long exceeded")
errLongExceededPositive = fmt.Errorf("long exceeded - positive value")
errLongExceededNegative = fmt.Errorf("long exceeded - negative value")
Copy link
Member

Choose a reason for hiding this comment

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

I added/updated comments and checked rendering.

Before submitting a pull request, please make sure that:
[…]
2. Comments are added or updated for all new or changed code.
Please add missing comments for all (both exported and unexported)
new and changed top-level declarations (functions, types, etc).

Both points were ignored.

Updated possible error results are also not documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlekSi could you please leave more specific feedback? What exactly needs to be documented here?
Sometimes when I leave comments (e.g. for structure fields) you say that they are obvious and not needed. What needs to be documented here?

Copy link
Member

Choose a reason for hiding this comment

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

Fields are not top-level declarations. Global variables are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I document what each error in this list means?
Or should I document each function/method where these errors could be returned?
Or both? Or something else?

@rumyantseva rumyantseva merged commit 548114f into FerretDB:main Apr 18, 2023
@rumyantseva rumyantseva deleted the issue-1346-stats branch April 18, 2023 07:44
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
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/enhancement Some user-visible feature could work better
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fix SchemaStats to return (somewhat) correct data
6 participants