-
Notifications
You must be signed in to change notification settings - Fork 268
PHPLIB-1563 and PHPLIB-1564: batchSize and singleBatch fixes for find operations #1532
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
PHPLIB-1563 and PHPLIB-1564: batchSize and singleBatch fixes for find operations #1532
Conversation
Bumps [tests/specifications](https://github.com/mongodb/specifications) from `a32d445` to `11022ca`. - [Release notes](https://github.com/mongodb/specifications/releases) - [Commits](mongodb/specifications@a32d445...11022ca) --- updated-dependencies: - dependency-name: tests/specifications dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]>
dc0650e
to
48376d0
Compare
48376d0
to
ff31e58
Compare
@jmikola This PR automatically fixes PHPLIB-1562 and PHPLIB-1591. I've included changes necessary for PHPLIB-1563 and PHPLIB-1564. Since our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM but I'll wait for feedback.
I'm not a fan of adding actual commits for tickets in these dependabot PRs, as that makes the PR related to even more JIRA issues than it would have originally via just spec test updates. There's also a risk of issue references getting dropped at merge time (I've caught GitHub's UI doing that before when suggesting a single commit message).
@@ -418,6 +419,16 @@ private function createQueryOptions(): array | |||
$options['modifiers'] = is_object($modifiers) ? document_to_array($modifiers) : $modifiers; | |||
} | |||
|
|||
// Ensure no cursor is left behind when limit == batchSize by increasing batchSize | |||
if (isset($options['limit'], $options['batchSize']) && $options['limit'] === $options['batchSize']) { | |||
assert(is_integer($options['batchSize'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary for static analysis? The constructor should already enforce that batchSize
is an integer if set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this is for static analysis only.
} | ||
|
||
if (isset($options['limit']) && $options['limit'] === 1) { | ||
$options['singleBatch'] = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the step of automatically setting singleBatch when limit is set to 1, even though this can affect find operations where users themself set limit to 1. Let me know if you see any potential issues with that approach, the alternative would be to introduce singleBatch as an undocumented option to Find.
@alcaeus: Is that any different than what already happens in PHPC? Read on.
The CRUD spec's Q&A says this about why singleBatch
was omitted from FindOptions in the API:
Rather than introduce a singleBatch option to FindOptions, the spec preserves the existing API for limit and instructs drivers to convert negative values accordingly for servers >= 3.2.
That said, the option exists in PHPC. PHPC also supports a negative limit, which implies singleBatch: true
. That logic is implemented in php_phongo_query_init_limit_and_singlebatch
.
I think there are two possible actions to take here:
- Acknowledge the CRUD spec and leave support for negative limits in place. If so, we should update the docs.
- Deprecate negative limits in 1.x and remove it in 2.0 (to be on par with libmongoc's API). In that case we should introduce
singleBatch
as an explicit option in PHPLIB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I believe given that we no longer support 3.2 and older, we may want to consider introducing singleBatch
as an option for Find
. Reading the spec, it never says that a driver may not provide singleBatch
as an option, so we could certainly add it for PHP. We can always decide to leave it undocumented until the spec is updated. I can file a drivers ticket for adding singleBatch
.
That said, singleBatch
has scenarios where not all expected results are returned (so neither limit
nor batchSize
is reached). This is not relevant for findOne
, but I feel like that should be documented in the spec.
a32d445
to 11022ca
Note: this was originally a spec sync PR but was amended with fixes for the following tickets:
https://jira.mongodb.org/browse/PHPLIB-1563
https://jira.mongodb.org/browse/PHPLIB-1564
Bumps tests/specifications from
a32d445
to11022ca
.Commits
11022ca
DRIVERS-943 Convert retryable writes command construction tests to unified fo...ffe8b9e
Typo fix in logging spec, max document length environment var (#1728)2362d1a
DRIVERS-3009, DRIVERS-1447: Updates to find operations (#1691)d795d49
DRIVERS-3033 SDAM logging tests should allow durationMS as a float (#1723)376b98a
DRIVERS-1785: clarify ordering of CMAP events when pool is cleared (#1690)152257b
DRIVERS-3040: Split updateWithPipelines test file by operation (#1727)ccb9816
DRIVERS-2091: remove references to getLastError (#1698)Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions
will show all of the ignore conditions of the specified dependency@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)