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

DRIVERS-2533: add RunCursorCommand API #1412

Merged
merged 82 commits into from May 23, 2023

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Apr 27, 2023

Summary

Adds a new runCursorCommand database API that can handle running a generic command that returns a cursor from the server. MongoDB cursors need the client to track some pieces of metadata that are generally internal to a driver implementation (session.lsid, cursor.id, server/connection, namespace) so this API is aware that the command being run needs to maintain these components for subsequent iteration of the cursor, via getMore commands.

Changes

  • Update the find_getmore_killcursors spec
    • Describe the shape of a getMore command
    • Add more description to what a tailable / tailable_await cursor is
    • Add a requirement to update id and ns upon every getMore response
  • Update the run-command spec
    • Add note about gossiping $clusterTime - an additional property the driver MUST attach to the command sent to the server on behalf of the user
    • Add runCursorCommand specification
      • The options interface
      • Handling of: Sessions, Server Selection, Load Balancers, Iteration, Tail-ability, Resource Clean up, and CSOT
  • Add yaml tests for the various options supported by the API
    • successfully executes checkMetadataConsistency cursor creating command
    • errors if the command response is not a cursor
    • creates an implicit session that is reused across getMores
    • accepts an explicit session that is reused across getMores
    • returns pinned connections to the pool when the cursor is exhausted
    • returns pinned connections to the pool when the cursor is closed
    • supports configuring getMore batchSize
    • supports configuring getMore maxTimeMS
    • supports configuring getMore comment
    • does not close the cursor when receiving an empty batch
  • Update the Unified Test Format spec
    • New runCursorCommand operation that iterates a cursor to exhaustion in one operation
    • New createCommandCursor operation that saves an entity to be iterated later
    • close and iterateUntilDocumentOrError are expected to support the new entity
  • Add valid-pass tests
    • runCursorCommand creates and exhausts cursor by running getMores
    • createCommandCursor creates a cursor and stores it as an entity that can be iterated one document at a time
    • createCommandCursor cursor can be closed and will perform a killCursors operation
  • Add CSOT tests
    • errors if timeoutMode is set without timeoutMS
    • error if timeoutMode is cursorLifetime and cursorType is tailableAwait
    • error if getMore maxTimeMS setting is greater than timeoutMS
    • error if getMore maxTimeMS setting is equal to timeoutMS
    • Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset
    • Non=tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure
    • Tailable cursor iteration timeoutMS is refreshed for getMore - failure
    • Tailable cursor awaitData iteration timeoutMS is refreshed for getMore - failure

Tasks

@nbbeeken nbbeeken requested a review from dariakp April 27, 2023 21:22
source/run-command/run-command.rst Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Show resolved Hide resolved
source/run-command/tests/unified/runCursorCommand.json Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/run-command/run-command.rst Outdated Show resolved Hide resolved
source/unified-test-format/unified-test-format.rst Outdated Show resolved Hide resolved
@nbbeeken nbbeeken requested review from dariakp and jmikola May 3, 2023 17:59
@nbbeeken nbbeeken marked this pull request as ready for review May 3, 2023 17:59
@nbbeeken nbbeeken requested review from a team as code owners May 3, 2023 17:59
Copy link
Contributor

@prestonvasquez prestonvasquez left a comment

Choose a reason for hiding this comment

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

LGTM!

@prestonvasquez prestonvasquez self-requested a review May 22, 2023 20:25
@prestonvasquez prestonvasquez dismissed their stale review May 22, 2023 20:27

Approved by accident. Still working through serverless CSOT test cases.

@dariakp dariakp merged commit a839581 into master May 23, 2023
3 checks passed
@dariakp dariakp deleted the DRIVERS-2533-runCursorCommand-api branch May 23, 2023 19:57
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.

None yet

5 participants