-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat: Add maxBatchingDelayMs Option. #987
Open
nginsberg-google
wants to merge
4
commits into
googleapis:main
Choose a base branch
from
nginsberg-google:batching-delay
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
from google.cloud.spanner_v1._helpers import _retry | ||
from google.cloud.spanner_v1._helpers import _check_rst_stream_error | ||
from google.api_core.exceptions import InternalServerError | ||
from google.protobuf.duration_pb2 import Duration | ||
|
||
|
||
class _BatchBase(_SessionWrapper): | ||
|
@@ -145,9 +146,14 @@ def _check_state(self): | |
if self.committed is not None: | ||
raise ValueError("Batch already committed") | ||
|
||
def commit(self, return_commit_stats=False, request_options=None): | ||
def commit(self, max_batching_delay_ms=None, return_commit_stats=False, request_options=None): | ||
"""Commit mutations to the database. | ||
|
||
:type max_batching_delay_ms: Optional[int] | ||
:param max_batching_delay_ms: | ||
If present, the The amount of latency this request is willing to incur in order to | ||
improve throughput. | ||
|
||
:type return_commit_stats: bool | ||
:param return_commit_stats: | ||
If true, the response will return commit stats which can be accessed though commit_stats. | ||
|
@@ -182,11 +188,16 @@ def commit(self, return_commit_stats=False, request_options=None): | |
# Request tags are not supported for commit requests. | ||
request_options.request_tag = None | ||
|
||
Duration max_batching_delay = None | ||
if max_batching_delay_ms is not None: | ||
max_batching_delay.nanos = 1000000 * [max_batching_delay_ms] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is this default decided? |
||
|
||
request = CommitRequest( | ||
session=self._session.name, | ||
mutations=self._mutations, | ||
single_use_transaction=txn_options, | ||
return_commit_stats=return_commit_stats, | ||
max_batching_delay=max_batching_delay, | ||
request_options=request_options, | ||
) | ||
with trace_call("CloudSpanner.Commit", self._session, trace_attributes): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
from google.cloud.spanner_v1 import RequestOptions | ||
from google.api_core import gapic_v1 | ||
from google.api_core.exceptions import InternalServerError | ||
from google.protobuf.duration_pb2 import Duration | ||
|
||
|
||
class Transaction(_SnapshotBase, _BatchBase): | ||
|
@@ -180,9 +181,14 @@ def rollback(self): | |
self.rolled_back = True | ||
del self._session._transaction | ||
|
||
def commit(self, return_commit_stats=False, request_options=None): | ||
def commit(self, max_batching_delay_ms=None, return_commit_stats=False, request_options=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above comment |
||
"""Commit mutations to the database. | ||
|
||
:type max_batching_delay_ms: Optional[int] | ||
:param max_batching_delay_ms: | ||
If present, the The amount of latency this request is willing to incur in order to | ||
improve throughput. | ||
|
||
:type return_commit_stats: bool | ||
:param return_commit_stats: | ||
If true, the response will return commit stats which can be accessed though commit_stats. | ||
|
@@ -223,11 +229,16 @@ def commit(self, return_commit_stats=False, request_options=None): | |
# Request tags are not supported for commit requests. | ||
request_options.request_tag = None | ||
|
||
Duration max_batching_delay = None | ||
if max_batching_delay_ms is not None: | ||
max_batching_delay.nanos = 1000000 * [max_batching_delay_ms] | ||
|
||
request = CommitRequest( | ||
session=self._session.name, | ||
mutations=self._mutations, | ||
transaction_id=self._transaction_id, | ||
return_commit_stats=return_commit_stats, | ||
max_batching_delay=max_batching_delay, | ||
request_options=request_options, | ||
) | ||
with trace_call("CloudSpanner.Commit", self._session, trace_attributes): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Adding new argument
max_batching_delay_ms
as second parameter might break any existing applications that have not used key explicitly while callingcommit
.Can we move this to end?
@surbhigarg92 Can you please correct me this is incorrect?